From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Olson Newsgroups: gmane.emacs.devel Subject: Re: with-temp-buffer, insert-file-content and errors Date: Mon, 18 Jul 2005 18:11:30 -0500 Message-ID: <87k6jn90bh.fsf@tuxtanker.mwolson.org> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0689191687==" X-Trace: sea.gmane.org 1121732197 12818 80.91.229.2 (19 Jul 2005 00:16:37 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 19 Jul 2005 00:16:37 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jul 19 02:16:36 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DufmX-00071n-IK for ged-emacs-devel@m.gmane.org; Tue, 19 Jul 2005 02:16:22 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DufoU-00081t-Uz for ged-emacs-devel@m.gmane.org; Mon, 18 Jul 2005 20:18:22 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Dufn6-0007Ew-Od for emacs-devel@gnu.org; Mon, 18 Jul 2005 20:16:56 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Dufmx-000792-22 for emacs-devel@gnu.org; Mon, 18 Jul 2005 20:16:48 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Dufmw-00077l-DH for emacs-devel@gnu.org; Mon, 18 Jul 2005 20:16:46 -0400 Original-Received: from [80.91.229.2] (helo=ciao.gmane.org) by monty-python.gnu.org with esmtp (TLS-1.0:RSA_AES_128_CBC_SHA:16) (Exim 4.34) id 1DufoO-0001lT-LY for emacs-devel@gnu.org; Mon, 18 Jul 2005 20:18:17 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1DuffE-00065u-VQ for emacs-devel@gnu.org; Tue, 19 Jul 2005 02:08:48 +0200 Original-Received: from pool-71-115-27-140.sbndin.dsl-w.verizon.net ([71.115.27.140]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 19 Jul 2005 02:08:48 +0200 Original-Received: from mwolson by pool-71-115-27-140.sbndin.dsl-w.verizon.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 19 Jul 2005 02:08:48 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-To: emacs-devel@gnu.org Original-Lines: 70 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: pool-71-115-27-140.sbndin.dsl-w.verizon.net Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEU1QytIVTlZY0dqc1N6 hGGJl3qZpZCtuKXsjxzFAAACW0lEQVR42l2UXXrqIBCGk67Aoe29Ac4CTPDcGwZ73wLdQDOuQLP9 8wHG9hT1Mc6bb/5jp7Xed92TVrqeCYfKRVc+XdfDbqbJ8TixG1UDu2a3xkf2H+z+A6Qn7Xk71AA8 kdJmZg4xpcTshgr2JQSurAswhwDFYQN9r4yxx1BIQqBTBbvqahw9hxRSLOBdFVA89TTOvgSoMaLf ABTWOg5Z8lLRNyD7x4WSVHU1DZurThn2HI9Oa561JhTSDUWxq64YqRlmrcdhA73y3rmJY1okotDT NzDO2XNGZPnS7A4b6NQ8foQFN2eJmEBR7Du1Q/DRh7R4O50BrGmu0F8i49Iya+ScvtDNqkADB8zD pwU9wTu9c8msdNYOO0JvYYyREd9xBOh7zSNc2WMZUYzIDHOpU0Kxe5o9o0eccsr5mNLcwHhC8DoM SQkJ5wbUxAdlbDELEpDbclc8sT2gV2HJIrj/si7hDgzPpY4sqxTV+pWkgt7EGesDIFWUnGuK7pkn erZoieCVZPG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61Zzvxd07GRfIFQt QwFIG80DPp6ddJjZEsKRYeYAnlzhpblBFJ+vI+jmNQD98YFz2931Yd7WNQZgGkMgy02bu5z3fNi2 +dk3SHlJi+2yvwMfpG3c9xkI+gmQ/TW8GHsKey6/LecEowalj2+5lxRAHx9ffxFMuHf1uD65mN5v iFhnxfbKacIAAAAASUVORK5CYII= User-Agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux) Cancel-Lock: sha1:7mmssvXzio+Nz/zOGsuEwgeDKno= 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:41056 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:41056 --===============0689191687== Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" --=-=-= Content-Transfer-Encoding: quoted-printable "Richard M. Stallman" writes: > I think it is incorrect to use insert-file-contents with VISIT > non-nil on a temp buffer, so I think we don't need to try to fix > this. (It would not be easy, since the unwind-protect cleanup has > to execute before the error message gets displayed.) drkm was using code from my emacs-wiki program as an example for this. You're right in that using a non-nil VISIT argument was a bad idea. I've also worked around the "prompted to save a temp buffer" problem by making a macro called `emacs-wiki-with-temp-buffer' as follows. The condition-case call is mainly used for displaying diagnostic information, so it might not be generally useful. A part of the cleanup code, (when (buffer-live-p ,temp-buffer) (with-current-buffer ,temp-buffer (set-buffer-modified-p nil)) (... (kill-buffer ,temp-buffer))) might perhaps be generally useful, but this is mostly an FYI rather than a feature request. (defmacro emacs-wiki-with-temp-buffer (&rest body) "Create a temporary buffer, and evaluate BODY there like `progn'. See also `with-temp-file' and `with-output-to-string'. Unlike `with-temp-buffer', this will never attempt to save the temp buffer." (let ((temp-buffer (make-symbol "temp-buffer"))) `(let ((,temp-buffer (generate-new-buffer " *emacs-wiki-temp*"))) (unwind-protect (condition-case err (with-current-buffer ,temp-buffer ,@body) (error (if (fboundp 'display-warning) (display-warning 'emacs-wiki (format "%s: Error occurred: %s" (emacs-wiki-page-name) err) :warning) (message "%s: Error occurred: %s" (emacs-wiki-page-name) err)))) (when (buffer-live-p ,temp-buffer) (with-current-buffer ,temp-buffer (set-buffer-modified-p nil)) (unless debug-on-error (kill-buffer ,temp-buffer))))))) (put 'emacs-wiki-with-temp-buffer 'lisp-indent-function 0) (put 'emacs-wiki-with-temp-buffer 'edebug-form-spec '(body)) =2D-=20 Michael Olson -- FSF Associate Member #652 -- http://www.mwolson.org/ Interests: anime, Debian, XHTML, wiki, Emacs Lisp /` |\ | | | IRC: mwolson on freenode.net: #hcoop, #muse, #pulug |_] | \| |_| Jabber: mwolson_at_hcoop.net --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQBC3Dck+1Ho2POo0xkRAreSAJsHaOrV8IqL5rPUkuFLEWz1OjILcgCgsytU sxW0dPOMRRpcrQ810C+eorc= =yRYy -----END PGP SIGNATURE----- --=-=-=-- --===============0689191687== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel --===============0689191687==--