]> git.eshelyaron.com Git - emacs.git/commitdiff
Connection-local variables are applied in buffers visiting a remote file
authorMichael Albinus <michael.albinus@gmx.de>
Sat, 25 Mar 2023 17:28:55 +0000 (18:28 +0100)
committerMichael Albinus <michael.albinus@gmx.de>
Sat, 25 Mar 2023 17:28:55 +0000 (18:28 +0100)
* etc/NEWS: Connection-local variables are applied in buffers
visiting a remote file.

* test/lisp/net/tramp-tests.el (tramp-test34-connection-local-variables):
Fix test.

etc/NEWS
test/lisp/net/tramp-tests.el

index 2a87bf0840674f173a8218a85bb655c570163f0a..6c558553c58ef9900ee416cb7ce90d47329293a3 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -279,11 +279,17 @@ their customization options.
 * Incompatible Lisp Changes in Emacs 30.1
 
 ---
-** The escape sequence \x not followed by hex digits is now an error.
-Previously, \x without at least one hex digit denoted character code
+** The escape sequence '\x' not followed by hex digits is now an error.
+Previously, '\x' without at least one hex digit denoted character code
 zero (NUL) but as this was neither intended nor documented or even
 known by anyone, it is now treated as an error by the Lisp reader.
 
+---
+** Connection-local variables are applied in buffers visiting a remote file.
+This overrides possible directory-local or file-local variables with
+the same name.
+
+---
 ** User option 'tramp-completion-reread-directory-timeout' has been removed.
 This user option has been obsoleted in Emacs 27, use
 'remote-file-name-inhibit-cache' instead.
index 677dd35d79678f14e4eab00986288368e20b36de..835763e02377b05d3ee9b9f68e64fc2908a7bf7f 100644 (file)
@@ -6005,22 +6005,42 @@ INPUT, if non-nil, is a string sent to the process."
            (should (eq local-variable 'connect))
            (kill-buffer (current-buffer)))
 
-         ;; `local-variable' is dir-local due to existence of .dir-locals.el.
+         ;; `local-variable' is still connection-local due to Tramp.
+         ;; `find-file-hook' overrides dir-local settings.
          (write-region
           "((nil . ((local-variable . dir))))" nil
           (expand-file-name ".dir-locals.el" tmp-name1))
          (should (file-exists-p (expand-file-name ".dir-locals.el" tmp-name1)))
-         (with-current-buffer (find-file-noselect tmp-name2)
-           (should (eq local-variable 'dir))
-           (kill-buffer (current-buffer)))
-
-         ;; `local-variable' is file-local due to specifying as file variable.
+         (when (memq #'tramp-set-connection-local-variables-for-buffer
+                     find-file-hook)
+           (with-current-buffer (find-file-noselect tmp-name2)
+             (should (eq local-variable 'connect))
+             (kill-buffer (current-buffer))))
+         ;; `local-variable' is dir-local due to existence of .dir-locals.el.
+         (let ((find-file-hook
+                (remq #'tramp-set-connection-local-variables-for-buffer
+                      find-file-hook)))
+           (with-current-buffer (find-file-noselect tmp-name2)
+             (should (eq local-variable 'dir))
+             (kill-buffer (current-buffer))))
+
+         ;; `local-variable' is still connection-local due to Tramp.
+         ;; `find-file-hook' overrides dir-local settings.
          (write-region
           "-*- mode: comint; local-variable: file; -*-" nil tmp-name2)
           (should (file-exists-p tmp-name2))
-         (with-current-buffer (find-file-noselect tmp-name2)
-           (should (eq local-variable 'file))
-           (kill-buffer (current-buffer))))
+         (when (memq #'tramp-set-connection-local-variables-for-buffer
+                     find-file-hook)
+           (with-current-buffer (find-file-noselect tmp-name2)
+             (should (eq local-variable 'connect))
+             (kill-buffer (current-buffer))))
+         ;; `local-variable' is file-local due to specifying as file variable.
+         (let ((find-file-hook
+                (remq #'tramp-set-connection-local-variables-for-buffer
+                      find-file-hook)))
+           (with-current-buffer (find-file-noselect tmp-name2)
+             (should (eq local-variable 'file))
+             (kill-buffer (current-buffer)))))
 
       ;; Cleanup.
       (custom-set-variables