emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: "Fraga, Eric" <e.fraga@ucl.ac.uk>
Cc: Emacs Org mode mailing list <emacs-orgmode@gnu.org>
Subject: Re: folding problems
Date: Fri, 05 Aug 2022 09:45:38 +0800	[thread overview]
Message-ID: <87edxvpinx.fsf@localhost> (raw)
In-Reply-To: <87fsichwo0.fsf@ucl.ac.uk>

[-- Attachment #1: Type: text/plain, Size: 1583 bytes --]

"Fraga, Eric" <e.fraga@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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-export-Do-not-try-to-load-file-directory-locals-.patch --]
[-- Type: text/x-patch, Size: 2627 bytes --]

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


  reply	other threads:[~2022-08-05  1:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-04 13:24 folding problems Fraga, Eric
2022-08-04 14:34 ` Ihor Radchenko
2022-08-04 14:46   ` Fraga, Eric
2022-08-04 15:10   ` Fraga, Eric
2022-08-05  1:45     ` Ihor Radchenko [this message]
2022-08-05  9:35       ` Fraga, Eric
2022-08-05 11:37         ` Ihor Radchenko
2022-08-05 12:16           ` Fraga, Eric
2022-08-05 13:55             ` Fraga, Eric
2022-08-04 16:23   ` Fraga, Eric

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87edxvpinx.fsf@localhost \
    --to=yantar92@gmail.com \
    --cc=e.fraga@ucl.ac.uk \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).