Function: org-preserve-local-variables
org-preserve-local-variables is a macro defined in org-macs.el.gz.
Signature
(org-preserve-local-variables &rest BODY)
Documentation
Execute BODY while preserving local variables.
Source Code
;; Defined in /usr/src/emacs/lisp/org/org-macs.el.gz
(defmacro org-preserve-local-variables (&rest body)
"Execute BODY while preserving local variables."
(declare (debug (body)))
`(let ((local-variables
(org-with-wide-buffer
(goto-char (point-max))
(let ((case-fold-search t))
(and (re-search-backward "^[ \t]*# +Local Variables:"
(max (- (point) 3000) 1)
t)
(let ((buffer-undo-list t))
(delete-and-extract-region (point) (point-max)))))))
(tick-counter-before (buffer-modified-tick)))
(unwind-protect (progn ,@body)
(when local-variables
(org-with-wide-buffer
(goto-char (point-max))
(unless (bolp) (insert "\n"))
(let ((modified (< tick-counter-before (buffer-modified-tick)))
(buffer-undo-list t))
(insert local-variables)
(unless modified
(restore-buffer-modified-p nil))))))))