summaryrefslogtreecommitdiff
path: root/lisp/format.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2010-01-10 00:22:54 -0500
committerStefan Monnier <monnier@iro.umontreal.ca>2010-01-10 00:22:54 -0500
commit4e5617ee4096a9f036b078f16f508147cf3653a1 (patch)
treeeb1bfc026f2291aafb64e3ddb2d339adc0ba648f /lisp/format.el
parenta069f06729651c5128ea07873924d38518ece677 (diff)
downloademacs-4e5617ee4096a9f036b078f16f508147cf3653a1.tar.gz
(format-annotate-function): Only set
write-region-post-annotation-function after running to-fn so as not to affect nested write-region calls (bug#5273).
Diffstat (limited to 'lisp/format.el')
-rw-r--r--lisp/format.el12
1 files changed, 9 insertions, 3 deletions
diff --git a/lisp/format.el b/lisp/format.el
index 37dd95bd1c4..f19a207180f 100644
--- a/lisp/format.el
+++ b/lisp/format.el
@@ -222,9 +222,6 @@ For most purposes, consider using `format-encode-region' instead."
(multibyte enable-multibyte-characters)
(coding-system buffer-file-coding-system))
(with-current-buffer copy-buf
- (set (make-local-variable
- 'write-region-post-annotation-function)
- 'kill-buffer)
(setq selective-display sel-disp)
(set-buffer-multibyte multibyte)
(setq buffer-file-coding-system coding-system))
@@ -232,6 +229,15 @@ For most purposes, consider using `format-encode-region' instead."
(set-buffer copy-buf)
(format-insert-annotations write-region-annotations-so-far from)
(format-encode-run-method to-fn (point-min) (point-max) orig-buf)
+ (when (buffer-live-p copy-buf)
+ (with-current-buffer copy-buf
+ ;; Set write-region-post-annotation-function to
+ ;; delete the buffer once the write is done, but do
+ ;; it after running to-fn so it doesn't affect
+ ;; write-region calls in to-fn.
+ (set (make-local-variable
+ 'write-region-post-annotation-function)
+ 'kill-buffer)))
nil)
;; Otherwise just call function, it will return annotations.
(funcall to-fn from to orig-buf)))))