Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: Emacs Anywhere (github.com)
248 points by curryz on Mar 4, 2018 | hide | past | web | favorite | 90 comments

You’ve got that right! I built this as a knee-jerk reaction to vim-anywhere. XD

How is this different from “it’s all text”?

For one it seems to be system-wide rather than Firefox-specific (too bad It's All text doesn't work after Quantum). Apparently relies on the clipboard instead of filesystem

I respect your honesty here. ;)

"Why do we have to hide from the police, Daddy?"

"Because we use vi, son. They use emacs."

It really doesn't have to be a war anymore. Nowadays, you have both EMACS/VIM hybrids best of both worlds.

No, modal editing is utterly insane in today's environment.

Thank God we don't live under a soviet-era communist editor dictatorship

Okay, next weekend...

let's do nano-everywhere!

Maybe instead someone will reinvent the editor. Voice assistant integration, for example. Perhaps better understand code structure.

HEATHEN! The holy, never-ending war must continue.

Seriously, what voice commands would be better than clacking on a keyboard?

For code structure we have AST-fueled refactoring tools, auto linters, auto formatters... the main problem with these is that you're forcing people to use a single IDE/editor with a particular set of plugins with a particular configuration. And usually it's not even VIM or Emacs!

Tavis Rudd uses voice recognition to do his editing (in Emacs, no less):


The key is that he basically made up his own language to handle some things like special characters.

Thanks for this. Will keep it in mind when RSI kicks in.

Here's a synopsis of the talk http://ergoemacs.org/emacs/using_voice_to_code.html

Couldn't find the repo for the dragon stuff he promised to publish on his GH profile :/.

Edit: Found this summary he re-tweeted recently https://medium.com/bambuu/state-of-voice-coding-2017-3d2ff41....

Use your imagination. It’s not really to hard to figure out how to use voice in an editor.

Think higher level than next Word, next word.

Pretend you aren’t hunched over the keyboard with your fingers at the ready.

And I didn’t say replace the keyboard.

I did.

You could re-implement the Vim command building language in a natural language. You'll hit walls sooner or later.

Don't get me wrong, it would be awesome for ergonomics and a pretty powerful tool, but for now Google Assistant has issues in recognizing if I want a timer for 13 or 30 minutes. 1/5 of speech recognition searches are gibberish, especially when I use own names.

Correcting a typo takes far less time than backtracking speech - that's one of the main issues I see when people use any speech-to-text converter. People weigh their words carefully or they're in a world of pain trying to backtrack an error.

If we supplement the keyboard then what is faster and easier to do?

"replace all" $potato "with" $banana > hit enter < OR say "enter"


If you have an actual use case in mind that would dwarf keyboard input then give an example, please.

Why do you think you need to say “hit enter”? You’re constraining yourself to the current model. You’re free to make the assistant intelligent.

“Create function userName that returns a string”

“Rename current function to lastName”

“Rename variable myVariableName to newVariableName then run app”

For some reason, I couldn't help but imagine someone using Parinfer using voice commands and innocent bystanders recoiling in disgust because of the constant "slurp!", "barf!", "slurp!" interjections. xD

You can do this in Bash already (Ctrl x Ctrl e is bound to readline's edit-and-execute-command, which will open $EDITOR with the current command), but being able to do this everywhere is nice!

What?! That's amazing! You never stop learning bash I guess :)

Similar...look into rlwrap[1]

It attempts to launch an external program with your $EDITOR (vi or emacs) preferred key bindings.

[1] https://linux.die.net/man/1/rlwrap

Thank you! I tried to google how to do this some time ago with no success!

However it looks like it only works with emacs editing mode (set -o emacs). Is there a way to do this in vim editing mode (set -o vi)?

Also it doesn't appear to work in zsh. Is there a zsh equivalent?

For Zsh, add “bindkey '^x^e' edit-command-line” somewhere in your ~/.zshrc and you have it.

In vim editing mode, enter normal mode and push v and the line will be opened in a temp file.

For those of us who use Zsh, the equivalent is “Alt-x edit-command-line”, which can easily be bound to “Ctrl x, Ctrl e” by adding “bindkey '^x^e' edit-commandline” in ~/.zshrc.

I'm using 25.2 and that command is not defined in my emacs.

Sorry if I've misunderstood your comment, but the parent was mentioning a bash key binding, not an emacs one.

Nice! I spent in inordinate amount of time recreating emacs key bindings in MacOS using Karabiner -- everything from editing text to scrolling to switching windows -- before the latest release of MacOS broke it. I found a replacement but it's not as good.

Have you tried hooking it up to Hammerspoon? I’ve found that there’s a whole lot you can emulate from Karabiner in Karabiner-Elements using a combination of those two.

I'll check it out, thanks.

I switched to Karabiner Elements. The json config is nice.

Last time I checked (maybe 6-9 months ago) it was missing a lot. Did they make progress in reaching parity?

It does everything I need. I doubt it's 100% parity, but it's got a lot of the old.

Please share the Karabiner replacement you are using

This is the Karabiner alternative for >10.12: https://github.com/tekezo/Karabiner-Elements

Keyboard Maestro. I think it's something like $10

Awesome. I have one suggestion though: the project description could be easier to understand.

I wouldn't understand anything without the screenshot altho I use Emacs for 11 years. Imagine beginners reading it...

What should it read? I’m open to any suggestions.

I found the description pretty good, but maybe an extra 'headline' might be helpful:

What it does: Use emacs to input text in any program at any time

How it work: A keyboard shortcut of your choosing...

I like it!

It would be nice if there's a plugin that launches vim/emacs with a tmp file in the background, and replaces the textarea with a terminal like canvas that connects to it. Upon exit, the content gets copied into the textarea.

This is amazing, I have always wanted something like this. Given that it requires xdotool, I was wondering if it would work in a Wayland system (I don't use Wayland yet, I'm just curious) ?

Good eye! I don’t think it does on account of xdotool. If you can suggest something better than xdotool I’m open to using it. I only use two commands from xdotool at the moment.

Similarly I made an app the other day to allow custom key shortcuts on macOS. The defaults use vim keys but I plan to eventually add key chords too. https://github.com/sdegutis/Vimac

I'm typing this comment in Emacs! This is so exciting!

It even works in Facebook! If it can handle the ten layers of browser UI capture there, it can handle anything...


Great idea. I will use this.

Minor nit, can you fix the grammar here: "inserted into the application your using"

Should be "you're using" as in "you are using".

Thanks for this.


Does anyone use emacs with colemak or dvorak.? The default key bindings seem unintuitive with it.

I use dvorak and I can agree that there are at least a few popular chords that are inconvenient, like Cx Cf. But I've gotten used to this and haven't changed any core key bindings.

And, of course, the upside is that on any random machine with emacs is 100% compatible.

Oh, and one more tip :-): bind 'vim' to 'emacs -nw -Q' which loads emacs really fast (without requiring the daemon to be running).

I use evil-mode with colemak for insert mode only: https://pastebin.com/raw/Lnf5GL3G

The big problem is that all(?) applications use logical instead of physical keys for hotkeys combinations so any custom layout would break everything.

I do. Since C-x is very common I swapped T with X. Here's the snippet from my init:

    ;; Swap C-t and C-x, so it's easier to type on Dvorak layout
    ;; `keyboard-translate` does not work when attaching an emacsclient to
    ;; a running emacs in daemon mode, so instead we define the key in the
    ;; key-translation-map.
    ;; http://lists.gnu.org/archive/html/help-gnu-emacs/2009-10/msg00505.html
    (define-key key-translation-map [?\C-x] [?\C-t])
    (define-key key-translation-map [?\C-t] [?\C-x])
With this modification I find Emacs with Dvorak very comfortable.

I use emacs with programmer dvorak[0]. I use the default key bindings and it didn't get me too long to adjust. I tried changing the bindings to new locations but they're so many and in the end they're just arbitrary. I've been using that same setup for almost 4 years now and I don't have any intention of changing it :)

[0]: http://www.kaufmann.no/roland/dvorak/

I use emacs with colemak. I find it more ergonomic than emacs with qwerty. Is there anything specific you find cumbersome?

I do. I actually found the defaults to be more comfortable with Dvorak. Which chords feel unintuitive to you?

Happy Colemak user here. I have been using Colemak for two years, and Emacs for a little more than one year.

However I use Spacemacs with Vim keybindings :D

I do, with dvorak. I also map control to alt-gr for the best ergonomics, so all keys have equally easy control combos.

I've done it recently using Hammerspoon, if anyone interested https://github.com/agzam/spacehammer

Could this be done in android too? I use emacs in android through termux and I like it.

How did you set that up?

Just install termux from android. Then install emacs from terminal. It works flawlessly.

I'm getting 'No such file or directory' errors following these instructions.

I use spacemacs but I don't think this should cause any issues. I'm new to both though.

Got it. The macOS instructions were updated correctly in the readme I see.

I even wrote this comment in emacs!!

FWIW, I can confirm it works in spacemacs (after killing and restarting the emacs server).

I've read the README, Can someone please explain this to me?

It looks like this just opens an editor with a shortcut and pastes the text on exit...

Lovely idea. I used to use emacs with Firefox via plugin many years ago and I still miss it. Hope one day you can figure out Windows!

only if it was vim... :P


It's about time it caught up to vi on the 'being available anywhere' front.

Vim is better

True, that's why Emacs has Vim emulation (evil mode).

Exactly, vim is better than emacs, and I've always known this. It wasnt until recently that i found out emacs is a better vim than vim. Spacemacs really is a masterpiece.

Indeed it is. Still early and getting better all the time but it's very usable and much less broken than vim as it stands. With the spacemacs package cache and version pinning it will become even better out of the box.

NeoVim is the better (best) vim! Fixes a lot of the problems with vim while still staying true to its spirit.

Yeah, neovim is a great project but still lacks imo compared to emacs. maybe when the ecosystem and plugins get more stabilized will it be a really compelling option for me to switch. once you get past some of the emacs oddities it's pretty much a better vim. The thing about neovim is that bram added the feature that neovim was initially forked off because of and he made vim's version incompatible with neovim's async. being able to have transient buffers in emacs is a very powerful feature that is used all over the place (magit is one that does this very effectively). I am not sure neovim has all the necessary fundamental building blocks to compete and allow these extremely rich plugins like orgmode, magit, helm, swoop, evil, etc. I could be wrong on that but the plugins on the emacs side are much more robust which leads me to believe that emacs is better at customization. only having lua as a baked in language is limiting just like only having viml as the builtin language for vim was limiting as to what could be done easily... most plugins will simply not use any other language for compatibility and ease of install even though it's possible to use ruby/python/etc. In addition the concepts of major(vim filetypes) and minor modes(editor enhancements) is pretty great too.

don't get me wrong, all that said, I couldn't and wouldn't use emacs if it didn't have a rich vim emulator.


Nice idea. But AFAIK it cannot work with most "modern" web sites, because they are increasingly using some Javascript nonsense instead of a textarea. (Disclaimer: have not tried this, but some "everything is text" extension years ago)

This tool does not rely upon the application you use it with. You can use it anywhere with any application which allows you to paste text.

> You can use it anywhere with any application which allows you to paste text.

Thanks for this clarification. (Even pasting becomes increasingly impossible. For e.g. Google does not allow me anymore to paste my username at login, and my (work) username is very long... I suppose pasting might offer an easier way scripted attacks. But yeah, most applications still allow it.)

Where does google prevent that? I tried on the web login page and I can paste without problem. I'm not sure why they'd prevent you from pasting your login in the first place.

In general there's always a simple way to bypass these websites limitations, like those who try to disable the right click.

Maybe it's a "security feature" of some AV software or IE/edge. Wouldn't surprise me.

I use Firefox on Linux.

I didn't mean to insult you :)

Since you talked about your "(work) username" I thought your employer chose your OS/browser for this particular case.

I didn't take it as an insult :)

While my employer does not chose my OS/browser I am in the lucky situation that most of us use Linux with their favorite distro.

gmail.com (would not be surprised if the pages are browser and country specific, at least google.com is) I use Firefox.

Reminds me of a hipster riding a Penny-farthing.

I’m a Vi user rather than emacs but I can perfectly understand wanting to have the same keyboard interface across platforms.

Could you explain what’s bad about that or why you think classic keyboard interfaces are a fad? (I’ve been using Vi interfaces in one form or another since 1989).

In other words, you're not a hipster... just some old dude who likes being offended by shit.

Registration is open for Startup School 2019. Classes start July 22nd.

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