From 197bbbd91c54b28516ec6818f57bb07539fcfd9f Mon Sep 17 00:00:00 2001 Message-Id: <197bbbd91c54b28516ec6818f57bb07539fcfd9f.1659663319.git.yantar92@gmail.com> From: Ihor Radchenko 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.fsf@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-f08b14fa58ff@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