summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Albinus <michael.albinus@gmx.de>2023-03-25 18:28:55 +0100
committerMichael Albinus <michael.albinus@gmx.de>2023-03-25 18:28:55 +0100
commit267d9d5e3d1b1c5e1c9a61c5370581f26efda010 (patch)
tree6cf5822ae0728db5f521a5fc19216b41df8a1cf7
parentd02f0221c41bf8b248d79e3aaebdec68789001da (diff)
downloademacs-267d9d5e3d1b1c5e1c9a61c5370581f26efda010.tar.gz
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.
-rw-r--r--etc/NEWS10
-rw-r--r--test/lisp/net/tramp-tests.el38
2 files changed, 37 insertions, 11 deletions
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