all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Niels Giesen <niels.giesen@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Remote .emacs
Date: Mon, 07 Apr 2008 08:11:10 +0200	[thread overview]
Message-ID: <87skxykxdt.fsf@gmail.com> (raw)
In-Reply-To: mailman.10084.1207521928.18990.help-gnu-emacs@gnu.org

"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


       reply	other threads:[~2008-04-07  6:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.10084.1207521928.18990.help-gnu-emacs@gnu.org>
2008-04-07  6:11 ` Niels Giesen [this message]
2008-04-07  9:43   ` Remote .emacs Paulo J. Matos
2008-04-07 16:59   ` Tom Tromey
2008-04-06 22:45 Paulo J. Matos
2008-04-07  8:50 ` Tassilo Horn
2008-04-07  9:44   ` Paulo J. Matos
2008-04-08  1:27 ` Mike Mattie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87skxykxdt.fsf@gmail.com \
    --to=niels.giesen@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.