Tiny Automator workflows to make it easier to re-use your running Emacs.
Emacs users like to keep a single instance of their editor running,
and merely open files in it. To do this easily from outside Emacs,
Emacs comes with a tiny executable called
emacsclient. From a
command line, just run emacsclient file
.
From GUIs like macOS's Finder, you can drag and drop a file onto your Emacs window, but it is nice to bypass this as we do with other apps.
Choose either the app or the service, instructions below: you might not need both.
-
Warning these are hardcoded to the path Homebrew uses for emacsclient:
/usr/local/bin/emacsclient
. If your emacsclient is elsewhere, you must edit the workflow. -
This only works well with folders and text files. It behaves very oddly, for example, with PNG images, and does not open the image file.
(steps 2 and 3 are optional - you can run an app from anywhere, but it might be easier for you to find in your Applications folder)
cd && git clone https://github.com/paironaut/emacsclient-automator.git
cd emacsclient-automator
cp -R withEmacsApp.app /Applications
To use it:
- start the Emacs
server
(for example with
M-x server-start
oremacs --daemon
) - open a Finder window and ctrl-click a file.
- select 'Open with' then 'Other...'
- a file sector pops up: find and select withEmacs
- optionally, if you want to always use emacsclient to open this file, select the 'Always Open With' checkbox
- select 'Open'
- when you are finished editing type
C-x #
orM-x server-edit
.
There are many other options in macOS for using an app like this to open a file, such as the 'Open with: Change All ...' button in the Finder Info window. Investigate these with Apple's documentation.
cd && git clone https://github.com/paironaut/emacsclient-automator.git
cd emacsclient-automator
open
- In Finder, double-click on withEmacs.workflow and agree to install it.
To use it:
- start the Emacs
server
(for example with
M-x server-start
oremacs --daemon
) - open a Finder window and ctrl-click a file.
- select 'Services >' from the bottom of the popup menu (if it appears)
- select 'withEmacs'.
- when you are finished editing type
C-x #
orM-x server-edit
.
The idea for this came from a Reddit post that I can't find at the moment. So I don't have to relearn Automator each time I configure a Mac, I have posted the resulting code in this public git repository.
For configuration tips, see https://stackoverflow.com/a/39907215
- a custom icon
- make the icon appear on associated files
- drag and drop files onto the app icon
Control Emacs from your watch.
Use Automator.app built in to macOS to edit these workflows. We'll consider helpful pull requests. See the wishlist above.
Copyright 2018, David Corking and the emacsclient-automator contributors. Open source MIT License, see LICENSE.txt