From: Juri Linkov Date: Mon, 24 Feb 2025 17:51:13 +0000 (+0200) Subject: Better support for nil enable-local-variables in vc-find-revision-no-save X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ecd3b7b7cdc83210564b0f47a45eefe60cfbe5e3;p=emacs.git Better support for nil enable-local-variables in vc-find-revision-no-save * 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) --- diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el index 07b47a3a6d6..2906f2973da 100644 --- a/lisp/vc/diff-mode.el +++ b/lisp/vc/diff-mode.el @@ -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). diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 72057180a15..c5a630749a2 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -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))