"Fraga, Eric" <e.fr...@ucl.ac.uk> writes: > Maybe unrelated but I will add that the recent changes to how local > variables are processed is breaking my usage of org quite seriously. To > be clear: I am not complaining: it's my fault for tracking the bleeding > edge of development for both org and Emacs. π But I thought I would > mention what I am seeing just in case it's useful. > > An example: when exporting a long document which has many src blocks, > each of those blocks is now being loaded and local variables (which > include dir local variables) are being evaluated (which they were not > before, I guess?). I don't know if this is an org change or an Emacs > change? > > The src blocks are likely loaded by org because I am using engraved for > formatting the src blocks on export. This is a nightmare if any of the > variables are considered unsafe as it requires confirmation for each > such case. > > And if some src block mode needs a special input method, this is causing > the export to fail: > > activate-input-method: Canβt activate input method βTeXβ > > although I am not sure, at this point, where/when this is happening.
If you have some time, can you try the attached patch? > I will need to revert to an older version of org as I need to get work > done. There's too much breaking to spend the time at the moment > investigating. π But no worries: that's what git is for! π Sorry for this. This is one of those innocently-looking changes that can cause unforeseen consequences. Best, Ihor
>From 197bbbd91c54b28516ec6818f57bb07539fcfd9f Mon Sep 17 00:00:00 2001 Message-Id: <197bbbd91c54b28516ec6818f57bb07539fcfd9f.1659663319.git.yanta...@gmail.com> From: Ihor Radchenko <yanta...@gmail.com> Date: Fri, 5 Aug 2022 09:33:44 +0800 Subject: [PATCH] org-export: Do not try to load file/directory-locals in export buffer * lisp/org.el (org-inhibit-local-variables): New variable controlling loading file-local and directory-local variables when `org-mode' is being loaded. (org-mode): Use `org-inhibit-local-variables'. * lisp/ox.el (org-export--generate-copy-script): Disable loading local variables in the export buffer. Fixes https://orgmode.org/list/87fsichwo0....@ucl.ac.uk --- lisp/org.el | 5 ++++- lisp/ox.el | 8 ++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 9549ec5f0..12214ecbb 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -4691,6 +4691,8 @@ (defvar org-element-cache-persistent); Defined in org-element.el (defvar org-element-use-cache); Defined in org-element.el (defvar org-mode-loading nil "Non-nil during Org mode initialisation.") +(defvar org-inhibit-local-variables nil + "Unless nil, Org mode will not load file/directory-local variables.") ;;;###autoload (define-derived-mode org-mode outline-mode "Org" "Outline-based notes management and organizer, alias @@ -4719,7 +4721,8 @@ (define-derived-mode org-mode outline-mode "Org" ;; Apply file-local and directory-local variables, so that Org ;; startup respects them. See ;; https://list.orgmode.org/587be554-906c-5370-2cf2-f08b14fa5...@gmail.com/T/#u - (hack-local-variables 'ignore-mode-settings) + (unless org-inhibit-local-variables + (hack-local-variables 'ignore-mode-settings)) (org-load-modules-maybe) (org-install-agenda-files-menu) (when (and org-link-descriptive diff --git a/lisp/ox.el b/lisp/ox.el index fa6f3f19a..57d375b35 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -2623,8 +2623,12 @@ (defun org-export--generate-copy-script (buffer) (lambda () (let ((inhibit-modification-hooks t)) ;; Set major mode. Ignore `org-mode-hook' as it has been run - ;; already in BUFFER. - (let ((org-mode-hook nil) (org-inhibit-startup t)) (org-mode)) + ;; already in BUFFER. Ignore loading local variables as + ;; well. + (let ((org-mode-hook nil) + (org-inhibit-startup t) + (org-inhibit-local-variables t)) + (org-mode)) ;; Copy specific buffer local variables and variables set ;; through BIND keywords. (pcase-dolist (`(,var . ,val) varvals) -- 2.35.1