From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Jesper Harder Newsgroups: gmane.emacs.help Subject: Re: Form to store/recover buffer modified state? Date: Wed, 03 Sep 2003 17:48:42 +0200 Organization: http://purl.org/harder/ Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: <4yznhtczpt.fsf@skjellgran.ii.uib.no> <4yhe3uz6zm.fsf@skjellgran.ii.uib.no> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1062660901 12631 80.91.224.253 (4 Sep 2003 07:35:01 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 4 Sep 2003 07:35:01 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Sep 04 09:34:59 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19uodv-0006CC-00 for ; Thu, 04 Sep 2003 09:34:59 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.22) id 19uocl-0002Rm-IM for geh-help-gnu-emacs@m.gmane.org; Thu, 04 Sep 2003 03:33:47 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!logbridge.uoregon.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!not-for-mail Original-Newsgroups: gnu.emacs.help X-Face: ^RrvqCr7c,P$zTR:QED"@h9+BTm-"fjZJJ-3=OU7.)i/K]<.J88}s>'Z_$r; 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 Xref: main.gmane.org gmane.emacs.help:12265 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:12265 Joakim Hove writes: > Jesper Harder writes: > >> (defmacro save-modified (&rest body) >> (let ((temp (make-symbol "modified"))) >> `(let ((,temp (buffer-modified-p))) >> (unwind-protect >> (progn >> ,@body) >> (unless ,temp >> (set-buffer-modified-p nil)))))) > > Thanks a lot, it works like intended, but (e)lisp code containing the > "magic" characters "@", "," and "`" is beyond me. The backquote constructs aren't essential to the macro. They just make it easier to write (and read, IMHO). You could also write the macro this way without using backquote: (defmacro save-modified (&rest body) (let ((temp (make-symbol "modified"))) (list 'let (list (list temp (list 'buffer-modified-p))) (list 'unwind-protect (append '(progn) body) (list 'unless temp (list 'set-buffer-modified-p nil))))))