@defvar connection-local-default-application
The default application, a symbol, to be applied in
-@code{with-connection-local-variables} and
+@code{with-connection-local-variables}, @code{connection-local-p} and
@code{connection-local-value}. It defaults to @code{tramp}, but you
can let-bind it to change the application temporarily (@pxref{Local
Variables}).
This variable must not be changed globally.
@end defvar
+@defmac connection-local-p symbol &optional application
+This macro returns non-@code{nil} if @var{symbol} has a
+connection-local binding for @var{application}. If @var{application}
+is @code{nil}, the value of
+@code{connection-local-default-application} is used.
+@end defmac
+
@defmac connection-local-value symbol &optional application
This macro returns the connection-local value of @var{symbol} for
@var{application}. If @var{application} is @code{nil}, the value of
** Connection local variables
+++
-*** New macro 'connection-local-value'.
-This macro returns the connection-local value of a variable if any, or
-its current value.
+*** New macros 'connection-local-p' and 'connection-local-value'.
+The former macro returns non-nil if a variable has a connection-local
+binding. The latter macro returns the connection-local value of a
+variable if any, or its current value.
\f
* Changes in Emacs 30.1 on Non-Free Operating Systems
connection-local-criteria
connection-local-profile-name-for-setq)))))
+;;;###autoload
+(defmacro connection-local-p (variable &optional application)
+ "Non-nil if VARIABLE has a connection-local binding in `default-directory'.
+If APPLICATION is nil, the value of
+`connection-local-default-application' is used."
+ (declare (debug (symbolp &optional form)))
+ (unless (symbolp variable)
+ (signal 'wrong-type-argument (list 'symbolp variable)))
+ `(let (connection-local-variables-alist file-local-variables-alist)
+ (hack-connection-local-variables
+ (connection-local-criteria-for-default-directory ,application))
+ (and (assq ',variable connection-local-variables-alist) t)))
+
;;;###autoload
(defmacro connection-local-value (variable &optional application)
"Return connection-local VARIABLE for APPLICATION in `default-directory'.
`connection-local-default-application' is used.
If VARIABLE does not have a connection-local binding, the return
value is the default binding of the variable."
+ (declare (debug (symbolp &optional form)))
(unless (symbolp variable)
(signal 'wrong-type-argument (list 'symbolp variable)))
`(let (connection-local-variables-alist file-local-variables-alist)
?\N{KHMER SIGN CAMNUC PII KUUH})
"List of characters equivalent to trailing colon in \"password\" prompts."))
+;; Macro `connection-local-p' is new in Emacs 30.1.
+(if (macrop 'connection-local-p)
+ (defalias 'tramp-compat-connection-local-p #'connection-local-p)
+ (defmacro tramp-compat-connection-local-p (variable &optional application)
+ "Non-nil if VARIABLE has a connection-local binding in `default-directory'.
+If APPLICATION is nil, the value of
+`connection-local-default-application' is used."
+ `(let (connection-local-variables-alist file-local-variables-alist)
+ (hack-connection-local-variables
+ (connection-local-criteria-for-default-directory ,application))
+ (and (assq ',variable connection-local-variables-alist) t))))
+
(dolist (elt (all-completions "tramp-compat-" obarray 'functionp))
(function-put (intern elt) 'tramp-suppress-trace t))
"Cleanup crypt resources determined by VEC."
(let ((tramp-cleanup-connection-hook
(remove
- #'tramp-crypt-cleanup-connection tramp-cleanup-connection-hook)))
+ #'tramp-crypt-cleanup-connection tramp-cleanup-connection-hook))
+ (tramp-crypt-enabled t))
(dolist (dir tramp-crypt-directories)
(when (tramp-file-name-equal-p vec (tramp-dissect-file-name dir))
(tramp-cleanup-connection (tramp-crypt-dissect-file-name dir))))))
(defconst files-x-test--variables5
'((remote-lazy-var . nil)
(remote-null-device . "/dev/null")))
+(defvar remote-shell-file-name)
(defvar remote-null-device)
(defvar remote-lazy-var nil)
(put 'remote-shell-file-name 'safe-local-variable #'identity)
(connection-local-set-profiles
nil 'remote-ksh 'remote-nullfile)
+ (connection-local-set-profile-variables
+ 'remote-lazy files-x-test--variables5)
(connection-local-set-profiles
- files-x-test--application 'remote-bash)
+ files-x-test--application 'remote-lazy 'remote-bash)
(with-temp-buffer
;; We need a remote `default-directory'.
(should (string-equal (symbol-value 'remote-null-device) "null"))
;; The proper variable values are set.
+ (should (connection-local-p remote-shell-file-name))
(should
(string-equal
(connection-local-value remote-shell-file-name) "/bin/ksh"))
+ (should (connection-local-p remote-null-device))
(should
(string-equal
(connection-local-value remote-null-device) "/dev/null"))
+ (should-not (connection-local-p remote-lazy-var))
;; Run with a different application.
+ (should
+ (connection-local-p
+ remote-shell-file-name (cadr files-x-test--application)))
(should
(string-equal
(connection-local-value
remote-shell-file-name (cadr files-x-test--application))
"/bin/bash"))
+ (should
+ (connection-local-p
+ remote-null-device (cadr files-x-test--application)))
(should
(string-equal
(connection-local-value
remote-null-device (cadr files-x-test--application))
"/dev/null"))
+ (should
+ (connection-local-p
+ remote-lazy-var (cadr files-x-test--application)))
;; The previous bindings haven't changed.
(should-not connection-local-variables-alist)
(should (eq (file-attribute-type attr) t)))
;; Cleanup.
- (ignore-errors (delete-directory tmp-name1))
+ (ignore-errors (delete-directory tmp-name1 'recursive))
(ignore-errors (delete-file tmp-name1))
(ignore-errors (delete-file tmp-name2))))))
(tramp-remote-path tramp-remote-path)
(orig-tramp-remote-path tramp-remote-path)
path)
+ ;; The "flatpak" method modifies `tramp-remote-path'.
+ (skip-unless (not (tramp-compat-connection-local-p tramp-remote-path)))
(unwind-protect
(progn
;; Non existing directories are removed.