tecosaur / emacs-everywhere

Mirror of https://git.tecosaur.net/tec/emacs-everywhere
GNU General Public License v3.0
553 stars 58 forks source link
emacs keyboard-shortcuts mirror

+title: Emacs Everywhere

+author: TEC

+date: 2021-02-06

+html:

+html:

+html:

+html:

+html:

+html:

A re-implementation of the fantastic idea in [[https://github.com/zachcurry/emacs-anywhere][zachcurry/emacs-anywhere]].

[[https://user-images.githubusercontent.com/20903656/107152385-814f2c00-69a2-11eb-978f-b3e78067b3f3.gif]]

Just install from [[https://melpa.org/][MELPA]], and you're ready to go.

** Doom

Available with the =:app everywhere= module (and with a nice modeline).

** Dependencies

On Linux, ensure you have the following dependencies satisfied: =xclip=, =xdotool=, =xprop=, and =xwininfo=.

Invoke the Emacs Everywhere executable^{†}. I recommend doing this by [[*Binding a Shortcut][binding a shortcut]] to:

+begin_src shell

emacsclient --eval "(emacs-everywhere)"

+end_src

A new Emacs frame will appear, within which you can type away to your heart's content. It will remember which window you have focused.

By default, ~emacs-everywhere-insert-selection~ is a hook in ~emacs-everywhere-init-hooks~, and will insert the last text selection into your new buffer. To clear this, type =DEL= or =C-SPC= /before anything else/.

Once you've finished and want to insert the text into the window you triggered Emacs Everywhere from, just press =C-c C-c= or =C-x 5 0= to close the frame and paste the content into the window (as long as ~emacs-everywhere-paste-command~ is non-nil).

If you do /not/ wish to paste the buffer content into the original window, =C-c C-k= still copies the content to the clipboard, but never pastes.


^{} This requires the Emacs daemon to be running, but that's super easy. Just call =emacs --daemon= and you're sorted!

Emacs-everywhere needs a way to launch when a not-emacs application has focus. The easiest way to do this is to have a global keybinding/keyboard shortcut dedicated to launching (same as above): ~emacsclient --eval "(emacs-everywhere)"~

On linux/bsd, use your desktop environment, windows manager, or a dedicated processes (like sxhkd, xbindkeys). The [[https://help.ubuntu.com/stable/ubuntu-help/keyboard-shortcuts-set.html.en][ubuntu]] and [[https://wiki.archlinux.org/title/Keyboard_shortcuts#Customization][archlinux]] guides are informative.

On MacOS, options include [[http://www.hammerspoon.org/][hammerspoon]], [[https://www.alfredapp.com/help/workflows/triggers/hotkey/][alfred]], [[https://apps.apple.com/us/app/thor-launcher/id1120999687?mt=12][thor]], or [[https://github.com/pqrs-org/Karabiner-Elements/issues/134#issuecomment-439658876][karabiner]]. (Untested, see [[https://github.com/tecosaur/emacs-everywhere/issues/1#issuecomment-781329521][the relevant issue]])

** Example

For xbindkeys, =~/.xbindkeysrc= would include the entry

+begin_src shell

"emacsclient --eval '(emacs-everywhere)'" Alt + Mod4 + e

+end_src