From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Sean McAfee Newsgroups: gmane.emacs.help Subject: Re: Processing a file that may already be open Date: Mon, 17 Oct 2011 23:45:49 -0700 Organization: A noiseless patient Spider Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1332966867 1048 80.91.229.3 (28 Mar 2012 20:34:27 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 28 Mar 2012 20:34:27 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Mar 28 22:34:26 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SCzZY-0001gI-Tx for geh-help-gnu-emacs@m.gmane.org; Wed, 28 Mar 2012 22:34:25 +0200 Original-Received: from localhost ([::1]:52556 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SCzZY-0006Qa-3c for geh-help-gnu-emacs@m.gmane.org; Wed, 28 Mar 2012 16:34:24 -0400 Original-Path: usenet.stanford.edu!newsserver.news.garr.it!newscore.univie.ac.at!newsfeed.utanet.at!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 32 Injection-Info: mx04.eternal-september.org; posting-host="XVJ+HMFWLEVITYyjSp06tg"; logging-data="31626"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/cuwmaww5A1GA/onk3PptWcefrLPAzj1Q=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.90 (darwin) Cancel-Lock: sha1:Sk4gUyKZ2QH28tdWDGFcmFZnmO8= sha1:D0fRXRmBwr5LI+4CAmY/a4qUZH8= Original-Xref: usenet.stanford.edu gnu.emacs.help:189381 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:84152 Archived-At: Stefan Monnier writes: >> (defmacro with-visited-file (path &rest body) [...] > - use make-symbol rather than gensym: it's faster, doesn't pollute the > global symbol table (aka obarray), and doesn't rely on CL. gensym is just a thin wrapper around make-symbol; how could it pollute the global symbol table? I usually prefer gensym because I don't like to be obliged to give the new symbol a name. I don't care what it's named. And I don't mind relying on CL. It's the closest I get to being able to use Common Lisp on a regular basis. > - avoid evaluating "file" multiple times (in case the caller does > (with-visited-file (setq foo (concat foo ".el")) blabla)) Good point. > - avoid find-file: find-file is a user-level command, Elisp code should > use find-file-noselect instead. find-file will call switch-to-buffer > to display the buffer, which can fail or pop up a new window or a new > frame, none of which we want to see happen here. Also a good point. Thanks. There's still a few minor issues to be worked out, though. Like, should I save the buffer after editing it? Obviously yes, if the buffer didn't exist before. But if any buffers were already visiting the file, I should probably only save it if none of them have been modified since the file was last saved.