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 03:29:29 +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> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1062628340 4038 80.91.224.253 (3 Sep 2003 22:32:20 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 3 Sep 2003 22:32:20 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Sep 04 00:32:18 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 19ugAk-0005If-00 for ; Thu, 04 Sep 2003 00:32:18 +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 19ug7H-0001rf-K4 for geh-help-gnu-emacs@m.gmane.org; Wed, 03 Sep 2003 18:28:43 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!cyclone.bc.net!skynet.be!skynet.be!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:12253 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:12253 Joakim Hove writes: > I have some buffer manipulating[1] functions which are wrapped in a > construct like this: > > (let ((modified (buffer-modified-p))) > ;; > (lots of code) > ;; > (if (not modified) (set-buffer-modifed-p nil))) > > To ensure that the buffer is not marked as modified when the function > has finished executing. Is there a special form, i.e. resembling > (save-excursion ) to achieve this? I don't think there's an existing special form. But you can always create you own macro that works like a special form. Something like: (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))))))