help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Form to store/recover buffer modified state?


From: Jesper Harder
Subject: Re: Form to store/recover buffer modified state?
Date: Wed, 03 Sep 2003 17:48:42 +0200
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux)

Joakim Hove <hove@bccs.no> writes:

> Jesper Harder <harder@myrealbox.com> 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))))))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]