Saturday, October 22, 2011

Loading Lisp file from URL in Emacs

On a given day, I have to login and work from multiple Linux boxes. One thing I find annoying is that every time I make a change to my .emacs file, I have to copy the changes to all the hosts.

There are multiple ways to circumvent this issue. One way I find useful is to maintain my custom file as a gist in github (or any where you can host your .emacs file) and use the following code snippet in the .emacs to load the file from the URL.

  (shell-command "curl -Ls" (current-buffer))
Let me explain what this code snippet does:
  1. It creates a temporary buffer.
  2. With the temporary buffer as the current buffer, it fetches the contents of the URL into the current buffer.
  3. It evaluates the current buffer.
  4. Remove the temporary buffer.

If the sample code above works for you, if you eval the "(hello-world)", it will say "hello world" in the mini buffer.

1 comment:

Anonymous said...

Interesting, but why not just store your .emacs in Dropbox?