From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Niels Giesen Newsgroups: gmane.emacs.help Subject: Re: Remote .emacs Date: Mon, 07 Apr 2008 08:11:10 +0200 Organization: www.tudelft.nl Message-ID: <87skxykxdt.fsf@gmail.com> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1207550461 26914 80.91.229.12 (7 Apr 2008 06:41:01 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 7 Apr 2008 06:41:01 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Apr 07 08:41:31 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Jil2p-0003qS-Di for geh-help-gnu-emacs@m.gmane.org; Mon, 07 Apr 2008 08:41:31 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jil2C-0004lW-Al for geh-help-gnu-emacs@m.gmane.org; Mon, 07 Apr 2008 02:40:52 -0400 Original-Path: shelby.stanford.edu!headwall.stanford.edu!newsfeed.esat.net!colt.net!feeder.news-service.com!feed.xsnews.nl!border-1.ams.xsnews.nl!feeder1.cambrium.nl!feed.tweaknews.nl!tudelft.nl!binfeed2.tudelft.nl!news1.tudelft.nl!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) Cancel-Lock: sha1:mR1PfmTKq49JUnVp7rUBTQlCmgI= Original-X-Complaints-To: sysadmin@tudelft.nl Original-Lines: 65 Original-NNTP-Posting-Host: 204pc207.sshunet.nl (145.97.207.204) Original-NNTP-Posting-Date: Mon, 07 Apr 2008 08:10:33 +0200 Original-X-Trace: 733e047f9bad934c46a6931977 Original-Xref: shelby.stanford.edu gnu.emacs.help:157752 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:53124 Archived-At: "Paulo J. Matos" 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