> (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
_______________________________________________
gnu-emacs-sources mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/gnu-emacs-sources