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 14:22:39 -0400 Message-ID: References: <7dbe73ed0607240317g1bcdd564g66d075f809bcb7b2@mail.gmail.com> Reply-To: rms@gnu.org NNTP-Posting-Host: main.gmane.org Content-Type: text/plain; charset=ISO-8859-15 X-Trace: sea.gmane.org 1153765568 17806 80.91.229.2 (24 Jul 2006 18:26:08 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 24 Jul 2006 18:26:08 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jul 24 20:26:03 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 1G557j-00070P-IO for ged-emacs-devel@m.gmane.org; Mon, 24 Jul 2006 20:25:47 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1G557i-0002Ki-SM for ged-emacs-devel@m.gmane.org; Mon, 24 Jul 2006 14:25:46 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1G554l-0008Mn-MS for emacs-devel@gnu.org; Mon, 24 Jul 2006 14:22:43 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1G554i-0008Kz-JX for emacs-devel@gnu.org; Mon, 24 Jul 2006 14:22:41 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1G554h-0008KW-Uf for emacs-devel@gnu.org; Mon, 24 Jul 2006 14:22:40 -0400 Original-Received: from [199.232.76.164] (helo=fencepost.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.52) id 1G555q-0006ye-Od for emacs-devel@gnu.org; Mon, 24 Jul 2006 14:23:50 -0400 Original-Received: from rms by fencepost.gnu.org with local (Exim 4.34) id 1G554h-0002Ol-5n; Mon, 24 Jul 2006 14:22:39 -0400 Original-To: "Mathias Dahl" In-reply-to: <7dbe73ed0607240317g1bcdd564g66d075f809bcb7b2@mail.gmail.com> (mathias.dahl@gmail.com) 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:57560 Archived-At: I am currently optimizing some defuns in tumme.el and found that I do the following repeatdely: (setq buf (find-file tumme-db-file)) ;; do a lot of stuff in it (save-buffer) ;; optionally (kill-buffer buf) We don't usually call find-file for such temporary purposes. We usually use code like this: (with-temp-buffer (insert-file-contents file) operate on the file) except that if the file's already visited in a buffer, it is more efficient to use that buffer (and not kill it). To develop a general macro for this would be useful. It is not a trivial thing. Please start working on it if you want. The case of just examining a file without altering it, since that is more common, and easier. I suspect that we may need two totally different macros for the read-only case and the case of altering the file.