Monday, January 14, 2013

Using Emacs with ItsAllText on Fedora

ItsAllText (project website on GitHub) is a nifty Firefox add-on that allows you to edit the contents of a textbox with your favourite text editor, in my case Emacs. The configuration is quite simple. All you need to do is mention the path to the executable for your text-editor, and the add-on will use that to open the temporary file automatically. In the screen-shot below, I've used /usr/bin/emacs as the executable.


The trouble with using /usr/bin/emacs is that it opens a new Emacs window, which may become annoying after a while. To avoid this, you can use the emacsclient command, which opens the file in the Emacs instance that is running the Emacs server.

To enable the Emacs server, you need to add the following line to your .emacs file.

(server-start)

Or, if Emacs is already running, you can start the server using M-x server-start

Now, modify the ItsAllText configuration to use the emacsclient command instead of emacs, as shown in the screen-shot below.



On recent versions of Fedora, including FC 17 which I'm using, Firefox changes the default tmp directory to /var/tmp. Because of this, the emacsclient command cannot find the socket file used by the Emacs server, which is in /tmp. As a workaround, you can use the following script, that modifies the TMPDIR variable, to run emacsclient using /tmp.

#!/bin/sh
export TMPDIR=/tmp
/usr/bin/emacsclient "$@"

Now, set the path to this script as the editor in the ItsAllText preferences window. You can see the full description on the associated GitHub issue