]> git.eshelyaron.com Git - emacs.git/commitdiff
Better support for nil enable-local-variables in vc-find-revision-no-save
authorJuri Linkov <juri@linkov.net>
Mon, 24 Feb 2025 17:51:13 +0000 (19:51 +0200)
committerEshel Yaron <me@eshelyaron.com>
Wed, 26 Feb 2025 09:35:28 +0000 (10:35 +0100)
* lisp/vc/diff-mode.el (diff-syntax-fontify-props):
* lisp/vc/vc.el (vc-find-revision-no-save):
Use enable-local-variables as is only when it's one of these values:
:safe, :all, or nil.  Otherwise, for all remaining values that query,
use :safe.  Also use non-nil 'find-file' arg of 'normal-mode'.
https://lists.gnu.org/archive/html/emacs-devel/2025-02/msg00897.html

(cherry picked from commit 24e8477aa2f5ef228107707078735ade31e5d1c3)

lisp/vc/diff-mode.el
lisp/vc/vc.el

index 07b47a3a6d693605475bcc7f4ceed53c4cf79b00..2906f2973daf85c2de9faeec9359db049f69563a 100644 (file)
@@ -3144,7 +3144,12 @@ hunk text is not found in the source file."
     (cl-assert (null buffer-file-name))
     ;; Use `:safe' to find `mode:'.  In case of hunk-only, use nil because
     ;; Local Variables list might be incomplete when context is truncated.
-    (let ((enable-local-variables (unless hunk-only :safe))
+    (let ((enable-local-variables
+           (unless hunk-only
+             (if (memq enable-local-variables '(:safe :all nil))
+                 enable-local-variables
+               ;; Ignore other values that query.
+               :safe)))
           (buffer-file-name file))
       ;; Don't run hooks that might assume buffer-file-name
       ;; really associates buffer with a file (bug#39190).
index 72057180a15670690782dd3d52b125dcaa4db840..c5a630749a27f08bba94b1e2c386d45c251ea7a5 100644 (file)
@@ -2459,12 +2459,19 @@ Unlike `vc-find-revision-save', doesn't save the buffer to the file."
                 (goto-char (point-min))
                 (if buffer
                     ;; For non-interactive, skip any questions
-                    (let ((enable-local-variables :safe) ;; to find `mode:'
+                    (let ((enable-local-variables
+                           (if (memq enable-local-variables '(:safe :all nil))
+                               enable-local-variables
+                             ;; Ignore other values that query,
+                             ;; use `:safe' to find `mode:'.
+                             :safe))
                           (buffer-file-name file))
                       ;; Don't run hooks that might assume buffer-file-name
                       ;; really associates buffer with a file (bug#39190).
                       (ignore-errors (delay-mode-hooks (set-auto-mode))))
-                  (normal-mode))
+                  ;; Use non-nil 'find-file' arg of 'normal-mode'
+                  ;; to not ignore 'enable-local-variables' when nil.
+                  (normal-mode (not enable-local-variables)))
                (set-buffer-modified-p nil)
                 (setq buffer-read-only t)
                 (setq failed nil))