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

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

Re: sqlite-dump.el


From: Stefan Monnier
Subject: Re: sqlite-dump.el
Date: Mon, 04 Jan 2010 13:45:46 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux)

> (defmacro sqlite-dump--without-post-annotations (&rest body)
>   "Evaluate BODY without a local `write-region-post-annotation-function'.
> If `write-region-post-annotation-function' as a buffer-local
> value then it's set to nil for BODY, and restored by an
> `unwind-protect' afterwards.

> This is a workaround for a bug in Emacs 23 where it sets
> `write-region-post-annotation-function' to `kill-buffer', meaning
> any writes done by an encode function kill the buffer the encode
> is supposed to be operating on, usually making it mangle or
> destroy the contents of an unrelated buffer."

>   `(let* ((sqlite-dump--without-post-annotations--buffer (current-buffer))
>           (sqlite-dump--without-post-annotations--bound
>            (local-variable-p 'write-region-post-annotation-function
>                              sqlite-dump--without-post-annotations--buffer))
>           (sqlite-dump--without-post-annotations--value
>            (and sqlite-dump--without-post-annotations--bound
>                 write-region-post-annotation-function)))
>      (unwind-protect
>          (progn
>            (if sqlite-dump--without-post-annotations--bound
>                (setq write-region-post-annotation-function nil))
>            ;;(message "buf   %S" 
> sqlite-dump--without-post-annotations--buffer)
>            ;;(message "bound %S" sqlite-dump--without-post-annotations--bound)
>            ;;(message "value %S" sqlite-dump--without-post-annotations--value)
>            ;;(message "now   %S" write-region-post-annotation-function)
>            ,@body)
>        (and sqlite-dump--without-post-annotations--bound
>             (buffer-live-p sqlite-dump--without-post-annotations--buffer)
>             (with-current-buffer sqlite-dump--without-post-annotations--buffer
>               (set (make-local-variable 
> 'write-region-post-annotation-function)
>                    sqlite-dump--without-post-annotations--value))))))

Why not just

  (let ((write-region-post-annotation-function nil))
    ,@body)


-- Stefan




reply via email to

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