- Notifications
You must be signed in to change notification settings - Fork49
Configurable automation + hooks called with application information
License
zachcurry/emacs-anywhere
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Inspired bycknadler/vim-anywhere
Emacs Anywhere provides configurable automation and hooks containing window info, so you can bust moves anywhere in a quick, customizable fashion.
Table of Contents
curl -fsSL https://raw.github.com/zachcurry/emacs-anywhere/master/install | bashOpenSystem Preferences and navigate tokeyboard > shortcuts > Services.Check the box beside "Emacs Anywhere", click "Add Shortcut" and key a shortcut.
In order to useEmacs Anywhere, you must useXorg as your window manager. You canswitch your window manager inUbuntu by going to the login screen, clicking the cog icon, and selectingXorg.
Install these dependencies as needed
- xclip
- xdotool
- xwininfo
sudo apt-get install <dependency>curl -fsSL https://raw.github.com/zachcurry/emacs-anywhere/master/install | bashCreate a keyboard shortcut to run~/.emacs_anywhere/bin/run.
TBD
- Make sure your Emacs server is running. You can start the server like this
emacs --daemon- Focus an application window's text input. A text area in your browser will do.
- Key the keyboard shortcut you've chosen forEmacs Anywhere
- Write some text
- Delete the frame (
C-x 5 0, or:qif you use evil-mode).Emacs Anywhere will copy the text from the buffer "*Emacs Anywhere*" to clipboard, delete thebuffer, switch focus to the window from step two and paste the buffers content into the text input.
TheEA_EDITOR environment variable can be used to override the wayemacsclient is run. For example, you could put the following statement intoyour.bash_profile.
export EA_EDITOR='emacsclient -a "" -c'With the environment variable set, the invocation will look like this under thehood
emacsclient -a "" -c -e <elisp code>You can prefixemacsclient with it's path ifEmacs Anywhere can't findit in yourPATH environment variable.
| Command | Description |
|---|---|
| toggle-ea | If toggled to the "off" state,Emacs Anywhere will do nothing when the frame is deleted. |
| Variable | Description |
|---|---|
| ea-on | Boolean wheret andnil denote the "on" and "off** states ofEmacs Anywhere, respectively. The default value ist |
| ea-copy | If true, the "*Emacs Anywhere*" buffer will be copied to clipboard. The default value ist |
| ea-paste | If true,Emacs Anywhere will paste to the window from which it was launched. The default value ist |
| ea-app-name | The name of the application process for the window from whichEmacs Anywhere was launched. |
| ea-window-title | The title of the window from whichEmacs Anywhere was launched. |
| ea-x | The x-coordinate of the upper-left corner of the window from whichEmacs Anywhere was launched. |
| ea-y | The y-coordinate of the upper-left corner of the window from whichEmacs Anywhere was launched. |
| ea-width | The width of the window from whichEmacs Anywhere was launched. |
| ea-height | The height of the window from whichEmacs Anywhere was launched. |
Note: In OS X the window title, position and size informationis only available if the application is has accessiblity permissions enabled.
| Hook | Function Signature | Description |
|---|---|---|
| ea-popup-hook | (app-name window-title x y w h) | Functions run after anEmacs Anywhere session starts. |
;; Define a function or use a lambda of the same signature(defunpopup-handler (app-namewindow-titlexywh);; do stuff );; Hook your function(add-hook'ea-popup-hook'popup-handler)
In your hook function you can do things like set the major mode based on theapplication name or window title...
(defungithub-conversation-p (window-title) (or (string-match-p"Pull Request" window-title) (string-match-p"Issue" window-title);; ... ))(defunpopup-handler (app-namewindow-titlexywh);; set major mode (cond ((github-conversation-p window-title) (gfm-mode));; ... (t (markdown-mode)); default major mode ))
...or set the frame size and position to fit the bottom 400px of the window...
(defunpopup-handler (app-namewindow-titlexywh) (set-frame-position (selected-frame) x (+ y (- h400))) (unless (zerop w) (set-frame-size (selected-frame) w400t));; ... )
...or configure automation settings
(defunpopup-handler (app-namewindow-titlexywh) (when (equal app-name"Terminal");; Tell Emacs Anywhere not to paste if launched from Terminal (setq ea-pastenil));; ... )
~/.emacs_anywhere/update~/.emacs_anywhere/uninstall- Windows
TBD
MIT
Copyright © 2018, Zach Curry, All rights reserved.
About
Configurable automation + hooks called with application information
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Contributors9
Uh oh!
There was an error while loading.Please reload this page.
