Hacker News new | past | comments | ask | show | jobs | submit login
Emacs, Google this (github.com/malabarba)
88 points by sndean on May 1, 2016 | hide | past | favorite | 28 comments



Similarly, I use engine-mode (https://github.com/hrs/engine-mode) with Emacs, which allows you to set up basically any search engine. I use Google (on C-c / g) and Github (on C-c / h), but the engine-mode readme explains how to set it up with DuckDuckGo, stack overflow, etc.

It's configurable, but results can be displayed in eww, Emacs' built-in text-based web browser.


Emacs' built-in text-based web browser

Is it time to update Zawinski's Law to "Every program attempts to expand until it can browse the web."

Not that Emacs isn't already one of the best (if not the number one) examples of "kitchen sink" programs...


Emacs gets a bad rap as a "kitchen sink" program, but it isn't really, any more than something like the Bourne shell or Python. The majority of Emacs' built-ins are things like an elisp interpreter, some text processing stuff, and system libraries. Conversely, most of the really interesting things you can do with Emacs, like web browsing (eww), git repo management (magit), terminal emulation (ansi-term), etc. are really just programs written in elisp. Some of them also happen to be distributed with Emacs.


Neat idea. I've been using something like this with Acme from plan9port.

Acme's plumber lets the user customize behavior on a piece of text based on its context or a program that takes it as an argument.

A previous discussion about Acme on HN: https://news.ycombinator.com/item?id=4533156


Seems ages ago, but I wrote a post about its extensibility here: http://www.mostlymaths.net/2013/03/extensibility-programming...

I explained more or less how to use the plumber and endpoints, and gave a sample shell script and a reddit browser written in python you could plug into acme


oh yea, I remember your blog. As a matter of fact, it was one of few variable resources to learn about Acme's "API". Thanks for your work =)


Yes, there are very few resources about the "API", at least the original Acme/plumber papers are easy to read... And specially, the code is very straightforward in acme, the plumber or most of Plan9


Funny, just installed it two days ago after reading http://melpa.org/#/selected page which hints at it.


I use Launchbar (https://www.obdev.at/products/launchbar/index.html) for this. It works system wide, I just select the word or phrase and tap the Option key once. This brings up Launchbar with that text inputted, and then I can send that off to Google, Wikipedia, the system dictionary, YouTube, or anything else. I love it because instead of having different convoluted keybindings for every different type of search (C-c / g, C-c / h, etc.) I only have one, and then dispatch off a fuzzy frecency search that takes <2 letters for the result I want. So tap Alt, Tab, g, Enter searches Google, while Alt, Tab, w, Enter searches Wikipedia, etc. It does tons more with this same paradigm, I use it more than the command line, and can't recommend it enough to people who like to optimize their computer use.


I use LaunchBar and didn't know about this; cool! For those who also didn't know about it: it's the 'Instant Send' feature under 'Shortcuts' in the preferences.

It doesn't seem to work for words selected in the terminal, though, like in vim, or a scrollback buffer in tmux or less (you can click-and-drag to highlight things, but I mean highlighting in the apps themselves, like `viw` in vim to select the word under the cursor). That would be very nice.


Wait -- you need an app for this now? Ever since NEXTStep, Mac OS X has had the "Services" entry on the menu which can do things like this. Is that gone now?


Services are still there. Command-shift-L Googles the selection, though I don't know how standard this is.


Haha, interesting -- i've had a similar functionality that i hacked into my window manager (XMonad) forever ago. I have an arbitrary keystroke that grabs the highlighted (x clipboard) text, raises a running firefox instance, and plugs it into a StartPage search :). Especially useful when a terminal command barfs an error.


This functionality is sort of now available in the package xmonad-contrib[0].

[0] http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Actions-...


In a similar type of helpfulness (though the Google one could replace this in certain cases) helm-dash is an excellent plugin. You can bring up the helm-dash menu and search your Dash docs for functions by name, or search for the symbol at point. I have mine configured to open the docs in my browser, pointing to the local docs.

If you use OS X, something is broken in browse-url (I think) which causes anchors to not get opened correctly (annoying), so I added this[0] snippet to allow it. Not robust at all, but you get the idea. The "open -a" gives window focus to Chrome, mimicking the built in behavior.

[0] https://gist.github.com/asummers/8b8dfabf0e25a86ce0c320b39ba...


For context, Dash appears to be a documentation browser for OS X APIs.


Dash [1] is an OS X app for browsing documentation of many different APIs.

[1]: https://kapeli.com/dash


Emacs is a great operating system – it lacks a good editor, though.


I love Emacs as an editor but there's also Evil mode [1] (and I'd disagree if you told me Vim isn't a good editor).

[1] https://www.emacswiki.org/emacs/Evil


Great! Thanks for this. I had considered writing something like that for ages. Sometimes error messages seem to be created only as a key for a search on Stackoverflow.


Does Google's terms of use allow this?


Two questions. Why wouldn't they, and how could they tell?


I might have gotten this wrong, but it seems emacs open a browser window with the given query, then it's ok

I was thinking it would do a curl/wget on the url then show the results on emacs


I don't understand the practical difference between your two examlpes. What does a browser do, other than essentially "run curl on the URL and then show the results"


Technically of course, there's no difference, however: https://support.google.com/webmasters/answer/66357?hl=en


Why not? It's just another browser.


Why would I care? Honest question.


Emacs already has webjump which does pretty much the same thing but with arbitrary webpages.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: