Fix tramp-add-external-operation

* lisp/net/tramp.el (tramp-add-external-operation): Check
`default-directory' if `(car args)' is a relative file name, or nil.
This commit is contained in:
Michael Albinus 2025-10-26 12:44:29 +01:00
parent 515bbb8598
commit 035c43c46b

View file

@ -927,6 +927,7 @@ Customize. See also `tramp-change-syntax'."
(const :tag "Ange-FTP" simplified)
(const :tag "XEmacs" separate))
:require 'tramp
;; Starting with Emacs 31.1, we can use `custom-initialize-after-file' instead.
:initialize #'custom-initialize-default
:set #'tramp-set-syntax
:link '(info-link :tag "Tramp manual" "(tramp) Change file name syntax"))
@ -970,6 +971,7 @@ to be set, depending on VALUE."
;; Initialize the Tramp syntax variables. We want to override initial
;; value of `tramp-file-name-regexp'. We do not call
;; `custom-set-variable', this would load Tramp via custom.el.
;; Starting with Emacs 31.1, we can use `custom-initialize-after-file' instead.
(tramp--with-startup
(tramp-set-syntax 'tramp-syntax tramp-syntax))
@ -2556,7 +2558,9 @@ packages like `tramp-sh' (except `tramp-ftp')."
`(lambda (orig-fun &rest args)
(if-let* ((handler
(find-file-name-handler
(or (car args) default-directory) #',operation)))
(if (and (car args) (file-name-absolute-p (car args)))
(car args) default-directory)
#',operation)))
(apply handler #',operation args)
(apply orig-fun args)))
`((name . ,(concat "tramp-advice-" (symbol-name operation))))))))