[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 499f2085fa: Make application configurable in 'with-connection-loc
From: |
Michael Albinus |
Subject: |
master 499f2085fa: Make application configurable in 'with-connection-local-variables' |
Date: |
Fri, 18 Mar 2022 07:25:45 -0400 (EDT) |
branch: master
commit 499f2085fa6fce6c7a2868c8d27d465f43d53f0f
Author: Michael Albinus <michael.albinus@gmx.de>
Commit: Michael Albinus <michael.albinus@gmx.de>
Make application configurable in 'with-connection-local-variables'
* doc/lispref/variables.texi (Connection Local Variables):
Explain 'connection-local-default-application'.
* etc/NEWS: Mention 'connection-local-default-application'.
* lisp/files-x.el (connection-local-default-application): New variable.
(connection-local-criteria-for-default-directory): Use it. (Bug#54405)
* test/lisp/files-x-tests.el
(files-x-test-with-connection-local-variables): Extend test.
---
doc/lispref/variables.texi | 31 +++++++++++++++++++++++++++++++
etc/NEWS | 18 ++++++++++++++----
lisp/files-x.el | 14 +++++++++-----
test/lisp/files-x-tests.el | 18 ++++++++++++++++++
4 files changed, 72 insertions(+), 9 deletions(-)
diff --git a/doc/lispref/variables.texi b/doc/lispref/variables.texi
index d991ae9e27..cd39e6b647 100644
--- a/doc/lispref/variables.texi
+++ b/doc/lispref/variables.texi
@@ -2418,6 +2418,37 @@ are unwound. Example:
@end example
@end defmac
+@defvar connection-local-default-application
+The default application, a symbol, to be applied in
+@code{with-connection-local-variables}. It defaults to @code{tramp},
+but in case you want to overwrite Tramp's settings temporarily, you
+could let-bind it like
+
+@example
+@group
+(connection-local-set-profile-variables
+ 'my-remote-perl
+ '((perl-command-name . "/usr/local/bin/perl5")
+ (perl-command-switch . "-e %s")))
+@end group
+
+@group
+(connection-local-set-profiles
+ '(:application 'my-app :protocol "ssh" :machine "remotehost")
+ 'my-remote-perl)
+@end group
+
+@group
+(let ((default-directory "/ssh:remotehost:/working/dir/")
+ (connection-local-default-application 'my-app))
+ (with-connection-local-variables
+ do something useful))
+@end group
+@end example
+
+This variable must not be changed globally.
+@end defvar
+
@defvar enable-connection-local-variables
If @code{nil}, connection-local variables are ignored. This variable
shall be changed temporarily only in special modes.
diff --git a/etc/NEWS b/etc/NEWS
index e2546bb3ca..c20d683710 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -269,12 +269,22 @@ defaults to t, which makes Emacs use the toolkit
tooltips. The
existing GTK-specific option 'x-gtk-use-system-tooltips' is now an
alias of this new option.
+** Connection-local variables
+
+++
-** Some connection-local variables are now user options.
+*** Some connection-local variables are now user options.
The variables 'connection-local-profile-alist' and
'connection-local-criteria-alist' are now user options, in order to
make it more convenient to inspect and modify them.
++++
+*** The default connection-local application can be changed temporarily.
+Running 'with-connection-local-variables' defaults to application
+'tramp'. This can be changed by let-binding
+'connection-local-default-application' to another symbol. This is
+useful when running code in a buffer, where Tramp has already set some
+connection local variables.
+
---
** New minor mode 'pixel-scroll-precision-mode'.
When enabled, and if your mouse supports it, you can scroll the
@@ -647,7 +657,7 @@ It narrows to the current node.
+++
*** 'eudc-expansion-overwrites-query' to 'eudc-expansion-save-query-as-kill'.
-Rename 'eudc-expansion-overwrites-query' to
+'eudc-expansion-overwrites-query' is renamed to
'eudc-expansion-save-query-as-kill' to reflect the actual behaviour of
the customization variable.
@@ -933,7 +943,7 @@ the thumbnail file.
** Dired
*** New user option 'dired-mouse-drag-files'.
-If non-nil, dragging filenames with the mouse in a Dired buffer will
+If non-nil, dragging file names with the mouse in a Dired buffer will
initiate a drag-and-drop session allowing them to be opened in other
programs.
@@ -1000,7 +1010,7 @@ and friends.
---
*** Tramp supports abbreviating remote home directories now.
-When calling 'abbreviate-file-name' on a Tramp filename, the result
+When calling 'abbreviate-file-name' on a Tramp file name, the result
will abbreviate the user's home directory, for example by abbreviating
"/ssh:user@host:/home/user" to "/ssh:user@host:~".
diff --git a/lisp/files-x.el b/lisp/files-x.el
index 319bfe0565..0ae9fb076e 100644
--- a/lisp/files-x.el
+++ b/lisp/files-x.el
@@ -722,14 +722,18 @@ will not be changed."
(copy-tree connection-local-variables-alist)))
(hack-local-variables-apply)))
+(defvar connection-local-default-application 'tramp
+ "Default application in connection-local functions, a symbol.
+This variable must not be changed globally.")
+
(defsubst connection-local-criteria-for-default-directory (&optional
application)
"Return a connection-local criteria, which represents `default-directory'.
-If APPLICATION is nil, the symbol `tramp' is used."
+If APPLICATION is nil, `connection-local-default-application' is used."
(when (file-remote-p default-directory)
- `(:application ,(or application 'tramp)
- :protocol ,(file-remote-p default-directory 'method)
- :user ,(file-remote-p default-directory 'user)
- :machine ,(file-remote-p default-directory 'host))))
+ `(:application ,(or application connection-local-default-application)
+ :protocol ,(file-remote-p default-directory 'method)
+ :user ,(file-remote-p default-directory 'user)
+ :machine ,(file-remote-p default-directory 'host))))
;;;###autoload
(defmacro with-connection-local-variables (&rest body)
diff --git a/test/lisp/files-x-tests.el b/test/lisp/files-x-tests.el
index 60787e1cd3..7ee2f0c1a6 100644
--- a/test/lisp/files-x-tests.el
+++ b/test/lisp/files-x-tests.el
@@ -325,6 +325,9 @@
(should-not (boundp 'remote-shell-file-name))
(should (string-equal (symbol-value 'remote-null-device) "null"))
+ (connection-local-set-profiles
+ files-x-test--application 'remote-bash)
+
(with-connection-local-variables
;; All connection-local variables are set. They apply in
;; reverse order in `connection-local-variables-alist'.
@@ -344,6 +347,21 @@
(should (local-variable-p 'remote-shell-file-name))
(should (local-variable-p 'remote-null-device))
;; The proper variable values are set.
+ (should
+ (string-equal (symbol-value 'remote-shell-file-name) "/bin/ksh"))
+ (should
+ (string-equal (symbol-value 'remote-null-device) "/dev/null"))
+
+ ;; Run another instance of `with-connection-local-variables'
+ ;; with a different application.
+ (let ((connection-local-default-application (cadr
files-x-test--application)))
+ (with-connection-local-variables
+ ;; The proper variable values are set.
+ (should
+ (string-equal (symbol-value 'remote-shell-file-name) "/bin/bash"))
+ (should
+ (string-equal (symbol-value 'remote-null-device) "/dev/null"))))
+ ;; The variable values are reset.
(should
(string-equal (symbol-value 'remote-shell-file-name) "/bin/ksh"))
(should
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 499f2085fa: Make application configurable in 'with-connection-local-variables',
Michael Albinus <=