From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Richard Stallman Newsgroups: gmane.emacs.devel Subject: Re: Missing `with' macro? Date: Mon, 24 Jul 2006 23:09:11 -0400 Message-ID: References: <7dbe73ed0607240317g1bcdd564g66d075f809bcb7b2@mail.gmail.com> <87fygqyb7g.fsf@forcix.kollektiv-hamburg.de> Reply-To: rms@gnu.org NNTP-Posting-Host: main.gmane.org Content-Type: text/plain; charset=ISO-8859-15 X-Trace: sea.gmane.org 1153797016 15719 80.91.229.2 (25 Jul 2006 03:10:16 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 25 Jul 2006 03:10:16 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jul 25 05:10:14 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1G5DJE-000831-Vi for ged-emacs-devel@m.gmane.org; Tue, 25 Jul 2006 05:10:13 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1G5DJE-0001Pl-HO for ged-emacs-devel@m.gmane.org; Mon, 24 Jul 2006 23:10:12 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1G5DIX-0000yv-Gr for emacs-devel@gnu.org; Mon, 24 Jul 2006 23:09:29 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1G5DIW-0000xm-Jp for emacs-devel@gnu.org; Mon, 24 Jul 2006 23:09:28 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1G5DIW-0000xg-EC for emacs-devel@gnu.org; Mon, 24 Jul 2006 23:09:28 -0400 Original-Received: from [199.232.76.164] (helo=fencepost.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.52) id 1G5DJU-0004FX-1b for emacs-devel@gnu.org; Mon, 24 Jul 2006 23:10:28 -0400 Original-Received: from rms by fencepost.gnu.org with local (Exim 4.34) id 1G5DIF-0001Rb-CU; Mon, 24 Jul 2006 23:09:11 -0400 Original-To: Jorgen Schaefer In-reply-to: <87fygqyb7g.fsf@forcix.kollektiv-hamburg.de> (message from Jorgen Schaefer on Mon, 24 Jul 2006 22:55:31 +0200) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:57586 Archived-At: (defmacro with-file (file &rest body) "Run BODY in a buffer visiting FILE. If the buffer was not open before calling this macro, it's killed afterwards." (let ((file-sym (make-symbol "file")) (existsp-sym (make-symbol "existsp")) (buf-sym (make-symbol "buf"))) `(let* ((,file-sym ,file) (,existsp-sym (get-file-buffer ,file-sym)) (,buf-sym (find-file-noselect ,file-sym))) Using find-file-noselect could be the right thing in some cases, but there are many cases (especially where you just read the file or scan it quickly) where that is much too heavy.