Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

load .emacs from url

Tags:

emacs

I guess the real quesion is : how to evaluate a file via it's url?

Of course it wouldn't be the actual .emacs file, but it it would serve that purpose, so you can run your personal settings on any PC that has emacs installed.

I'm aware of the fact that loading a buffer in certain situations (mainly 'toggling stuff) is not the same as evaluating a buffer afterwards, but that's OK.

like image 297
Peter Avatar asked Apr 03 '12 06:04

Peter


1 Answers

browse-url-emacs from the standard url library makes this simple. It displays the resulting buffer, which you probably don't want in this case, but we can wrap it with save-window-excursion to circumvent that issue.

(save-window-excursion
  (eval-buffer (browse-url-emacs "http://foo/bar.el")))

or with some rudimentary error handling:

(condition-case e
    (save-window-excursion
      (eval-buffer
       (browse-url-emacs "http://foo/bar.el")))
  (error (message "Could not load remote library: %s" (cadr e))))
like image 194
phils Avatar answered Nov 15 '22 05:11

phils