From: Michael Albinus Date: Sat, 25 Mar 2023 17:28:55 +0000 (+0100) Subject: Connection-local variables are applied in buffers visiting a remote file X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=267d9d5e3d1b1c5e1c9a61c5370581f26efda010;p=emacs.git Connection-local variables are applied in buffers visiting a remote file * 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. --- diff --git a/etc/NEWS b/etc/NEWS index 2a87bf08406..6c558553c58 100644 --- 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. diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 677dd35d796..835763e0237 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -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