[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Remote .emacs
From: |
Niels Giesen |
Subject: |
Re: Remote .emacs |
Date: |
Mon, 07 Apr 2008 08:11:10 +0200 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) |
"Paulo J. Matos" <pocm@soton.ac.uk> writes:
> Hello all,
>
> I have several PCs I work regularly and where I regularly use emacs.
> Each time I update one .emacs, I have to update the others so that all
> are in sync.
>
> I wonder if there's already some code to:
> - Load a remote .emacs from the net. If there's no remote access then
> use the previous cached one. Otherwise load the one from the net and
> cache it.
> - I don't know much about emacs lisp but if there are ways through
> emacs lisp to get files from http or ftp or something, it shouldn't be
> hard to implement this as a library required by local .emacs and ran
> each time the local .emacs is executed.
>
How about something like this:
(defvar *cached-init-file* "~/cached-init.el")
(defvar *remote-init-file* "http://your/remote/.emacs")
(defun load-remote ()
"Load remote .emacs.
This assumes your .emacs file starts with at least three comment
characters (;;;) in order to skip the header returned by
the function `url-retrieve-synchronously'."
(let ((content
(save-excursion
(let ((buffer (condition-case nil (url-retrieve-synchronously
*remote-init-file*)
(error nil))))
(when buffer
(set-buffer buffer)
(re-search-forward "^;;" nil t)
(buffer-substring-no-properties (point) (point-max)))))))
(cond (content
(eval content)
(with-temp-file *cached-init-file*
(erase-buffer)
(insert content)
(eval-buffer)))
(t (load-file *cached-init-file*)))))
(load-remote)
Does lead me to wonder: how can we check for an internet connection without
actually making a (failing) request?
> Cheers,
>
> --
> Paulo Jorge Matos - pocm at soton.ac.uk
> http://www.personal.soton.ac.uk/pocm
> PhD Student @ ECS
> University of Southampton, UK
> Sponsor ECS runners - Action against Hunger:
> http://www.justgiving.com/ecsrunslikethewind
>
>
--
http://niels.kicks-ass.org
- Remote .emacs, Paulo J. Matos, 2008/04/06
- Re: Remote .emacs,
Niels Giesen <=