Add more `tramp-suppress-trace' properties in Tramp

* lisp/net/tramp-archive.el (tramp-archive-file-name-handler-alist):
Use `tramp-archive-handle-file-symlink-p'.
(tramp-archive-handle-file-symlink-p): New defun.

* lisp/net/tramp-cache.el (tramp-loaddefs): Don't require.
(tramp-get-hash-table, tramp-cache-print)
(tramp-dump-connection-properties): Declare `tramp-suppress-trace'
property.

* lisp/net/tramp-cmds.el (tramp-cleanup-dired-buffer-p)
(tramp-delete-tainted-remote-process-buffer-function):
Declare `tramp-suppress-trace' property.

* lisp/net/tramp-compat.el (tramp-loaddefs): Require.
(tramp-error): Declare.

* lisp/net/tramp-crypt.el (tramp-crypt-file-name-handler): Fix typo.

* lisp/net/tramp-integration.el (tramp-rfn-eshadow-setup-minibuffer)
(tramp-rfn-eshadow-update-overlay-regexp)
(tramp-rfn-eshadow-update-overlay): Declare `tramp-suppress-trace'
property.

* lisp/net/tramp-message.el (tramp-compat): Require (instead of
tramp-loaddefs.el).
(tramp-compat-string-replace, tramp-compat-temporary-file-directory):
Don't declare.
(tramp-byte-run--set-suppress-trace): Move to tramp.el.
(tramp-debug-outline-level)
(tramp-debug-buffer-command-completion-p, tramp-message)
(tramp-debug-button-action, tramp-debug-link-messages)
(tramp-debug-message-buttonize): Declare `tramp-suppress-trace' property.

* lisp/net/tramp.el (tramp-byte-run--set-suppress-trace):
New defun, moved from tramp-message.el.
(tramp-file-name-unify, tramp-file-name-equal-p)
(tramp-tramp-file-p, tramp-find-method, tramp-find-user)
(tramp-find-host, tramp-dissect-file-name)
(tramp-ensure-dissected-file-name, tramp-buffer-name)
(tramp-delete-temp-file-function, tramp-time-diff):
Declare `tramp-suppress-trace' property.
This commit is contained in:
Michael Albinus 2023-08-01 20:24:44 +02:00
parent ea0685e039
commit d83ceba705
8 changed files with 85 additions and 36 deletions

View file

@ -263,7 +263,7 @@ It must be supported by libarchive(3).")
(file-regular-p . tramp-handle-file-regular-p)
;; `file-remote-p' performed by default handler.
(file-selinux-context . tramp-handle-file-selinux-context)
(file-symlink-p . tramp-handle-file-symlink-p)
(file-symlink-p . tramp-archive-handle-file-symlink-p)
(file-system-info . tramp-archive-handle-file-system-info)
(file-truename . tramp-archive-handle-file-truename)
(file-user-uid . tramp-archive-handle-file-user-uid)
@ -666,6 +666,10 @@ offered."
"Like `file-readable-p' for file archives."
(file-readable-p (tramp-archive-gvfs-file-name filename)))
(defun tramp-archive-handle-file-symlink-p (filename)
"Like `file-symlink-p' for file archives."
(file-symlink-p (tramp-archive-gvfs-file-name filename)))
(defun tramp-archive-handle-file-system-info (filename)
"Like `file-system-info' for file archives."
(with-parsed-tramp-archive-file-name filename nil

View file

@ -80,7 +80,6 @@
;;; Code:
(require 'tramp-compat)
(require 'tramp-loaddefs)
(require 'time-stamp)
;;; -- Cache --
@ -125,6 +124,7 @@ details see the info pages."
If it doesn't exist yet, it is created and initialized with
matching entries of `tramp-connection-properties'.
If KEY is `tramp-cache-undefined', don't create anything, and return nil."
(declare (tramp-suppress-trace t))
(unless (eq key tramp-cache-undefined)
(or (gethash key tramp-cache-data)
(let ((hash
@ -506,6 +506,7 @@ PROPERTIES is a list of file properties (strings)."
;;;###tramp-autoload
(defun tramp-cache-print (table)
"Print hash table TABLE."
;; (declare (tramp-suppress-trace t))
(when (hash-table-p table)
(let (result)
(maphash
@ -538,6 +539,11 @@ PROPERTIES is a list of file properties (strings)."
table)
result)))
;; We cannot use the `declare' form for `tramp-suppress-trace' in
;; autoloaded functions, because the tramp-loaddefs.el generation
;; would fail.
(function-put #'tramp-cache-print 'tramp-suppress-trace t)
;;;###tramp-autoload
(defun tramp-list-connections ()
"Return all active `tramp-file-name' structs according to `tramp-cache-data'."
@ -553,6 +559,7 @@ PROPERTIES is a list of file properties (strings)."
(defun tramp-dump-connection-properties ()
"Write persistent connection properties into file \
`tramp-persistency-file-name'."
(declare (tramp-suppress-trace t))
;; We shouldn't fail, otherwise Emacs might not be able to be closed.
(ignore-errors
(when (and (hash-table-p tramp-cache-data)

View file

@ -221,6 +221,7 @@ functions are called with `current-buffer' set."
(defun tramp-cleanup-dired-buffer-p ()
"Return t if current buffer runs `dired-mode'."
(declare (tramp-suppress-trace t))
(derived-mode-p 'dired-mode))
(add-hook 'tramp-cleanup-some-buffers-hook
@ -231,14 +232,21 @@ functions are called with `current-buffer' set."
(defun tramp-delete-tainted-remote-process-buffer-function ()
"Delete current buffer from `tramp-tainted-remote-process-buffers'."
(declare (tramp-suppress-trace t))
(setq tramp-tainted-remote-process-buffers
(delete (current-buffer) tramp-tainted-remote-process-buffers)))
;;;###tramp-autoload
(defun tramp-taint-remote-process-buffer (buffer)
"Mark buffer as related to remote processes."
;; (declare (tramp-suppress-trace t))
(add-to-list 'tramp-tainted-remote-process-buffers buffer))
;; We cannot use the `declare' form for `tramp-suppress-trace' in
;; autoloaded functions, because the tramp-loaddefs.el generation
;; would fail.
(function-put #'tramp-taint-remote-process-buffer 'tramp-suppress-trace t)
(add-hook 'kill-buffer-hook
#'tramp-delete-tainted-remote-process-buffer-function)
(add-hook 'tramp-unload-hook

View file

@ -29,6 +29,7 @@
;;; Code:
(require 'tramp-loaddefs)
(require 'ansi-color)
(require 'auth-source)
(require 'format-spec)
@ -36,7 +37,7 @@
(require 'shell)
(require 'xdg)
(declare-function tramp-error "tramp")
(declare-function tramp-error "tramp-message")
(declare-function tramp-tramp-file-p "tramp")
(defvar tramp-temp-name-prefix)

View file

@ -281,7 +281,7 @@ arguments to pass to the OPERATION."
(assoc operation tramp-crypt-file-name-handler-alist))))
(prog1 (save-match-data (apply (cdr fn) args))
(setq tramp-debug-message-fnh-function (cdr fn)))
(prog1 (tramp-run-real-handler operation args)
(prog1 (tramp-crypt-run-real-handler operation args)
(setq tramp-debug-message-fnh-function operation))))
;;;###tramp-autoload

View file

@ -65,6 +65,7 @@
"Set up a minibuffer for `file-name-shadow-mode'.
Adds another overlay hiding filename parts according to Tramp's
special handling of `substitute-in-file-name'."
(declare (tramp-suppress-trace t))
(when minibuffer-completing-file-name
(setq tramp-rfn-eshadow-overlay
(make-overlay (minibuffer-prompt-end) (minibuffer-prompt-end)))
@ -86,6 +87,7 @@ special handling of `substitute-in-file-name'."
(defun tramp-rfn-eshadow-update-overlay-regexp ()
"An overlay covering the shadowed part of the filename."
(declare (tramp-suppress-trace t))
(rx-to-string
`(: (* (not (any ,tramp-postfix-host-format "/~"))) (| "/" "~"))))
@ -94,6 +96,7 @@ special handling of `substitute-in-file-name'."
This is intended to be used as a minibuffer `post-command-hook' for
`file-name-shadow-mode'; the minibuffer should have already
been set up by `rfn-eshadow-setup-minibuffer'."
(declare (tramp-suppress-trace t))
;; In remote files name, there is a shadowing just for the local part.
(ignore-errors
(let ((end (or (overlay-end rfn-eshadow-overlay)

View file

@ -47,25 +47,13 @@
;;; Code:
(require 'tramp-loaddefs)
(require 'tramp-compat)
(require 'help-mode)
(declare-function tramp-compat-string-replace "tramp-compat")
(declare-function tramp-file-name-equal-p "tramp")
(declare-function tramp-file-name-host-port "tramp")
(declare-function tramp-file-name-user-domain "tramp")
(declare-function tramp-get-default-directory "tramp")
(defvar tramp-compat-temporary-file-directory)
(eval-and-compile
(defalias 'tramp-byte-run--set-suppress-trace
#'(lambda (f _args val)
(list 'function-put (list 'quote f)
''tramp-suppress-trace val)))
(add-to-list
'defun-declarations-alist
(list 'tramp-suppress-trace #'tramp-byte-run--set-suppress-trace)))
;;;###tramp-autoload
(defcustom tramp-verbose 3
@ -132,6 +120,7 @@ When it is used for regexp matching, the regexp groups are
Point must be at the beginning of a header line.
The outline level is equal to the verbosity of the Tramp message."
(declare (tramp-suppress-trace t))
(1+ (string-to-number (match-string 3))))
;; This function takes action since Emacs 28.1, when
@ -140,6 +129,7 @@ The outline level is equal to the verbosity of the Tramp message."
(defun tramp-debug-buffer-command-completion-p (_symbol buffer)
"A predicate for Tramp interactive commands.
They are completed by \"M-x TAB\" only in Tramp debug buffers."
(declare (tramp-suppress-trace t))
(with-current-buffer buffer
(string-equal
(buffer-substring (point-min) (min (+ (point-min) 10) (point-max)))
@ -306,6 +296,7 @@ is greater than or equal 4.
Calls functions `message' and `tramp-debug-message' with FMT-STRING as
control string and the remaining ARGUMENTS to actually emit the message (if
applicable)."
;; (declare (tramp-suppress-trace t))
(ignore-errors
(when (<= level tramp-verbose)
;; Display only when there is a minimum level, and the progress
@ -346,8 +337,10 @@ applicable)."
(concat (format "(%d) # " level) fmt-string)
arguments))))))
;; We cannot declare our private symbols in loaddefs.
(function-put 'tramp-message 'tramp-suppress-trace t)
;; We cannot use the `declare' form for `tramp-suppress-trace' in
;; autoloaded functions, because the tramp-loaddefs.el generation
;; would fail.
(function-put #'tramp-message 'tramp-suppress-trace t)
(defsubst tramp-backtrace (&optional vec-or-proc force)
"Dump a backtrace into the debug buffer.
@ -473,6 +466,7 @@ the resulting error message."
(defun tramp-debug-button-action (button)
"Goto the linked message in debug buffer at place."
(declare (tramp-suppress-trace t))
(when (mouse-event-p last-input-event) (mouse-set-point last-input-event))
(when-let ((point (button-get button 'position)))
(goto-char point)))
@ -485,6 +479,7 @@ the resulting error message."
(defun tramp-debug-link-messages (pos1 pos2)
"Set links for two messages in current buffer.
The link buttons are in the verbositiy level substrings."
(declare (tramp-suppress-trace t))
(save-excursion
(let (beg1 end1 beg2 end2)
(goto-char pos1)
@ -518,6 +513,7 @@ Bound in `tramp-*-file-name-handler' functions.")
(defun tramp-debug-message-buttonize (position)
"Buttonize function in current buffer, at next line starting after POSTION."
(declare (tramp-suppress-trace t))
(save-excursion
(goto-char position)
(while (not (search-forward-regexp

View file

@ -87,15 +87,6 @@
;;;###autoload (when (featurep 'tramp-compat)
;;;###autoload (load "tramp-compat" 'noerror 'nomessage))
;;; User Customizable Internal Variables:
(defgroup tramp nil
"Edit remote files with a combination of ssh, scp, etc."
:group 'files
:group 'comm
:version "22.1"
:link '(custom-manual "(tramp)Top"))
;;;###tramp-autoload
(progn
(defvar tramp--startup-hook nil
@ -105,9 +96,26 @@
(defmacro tramp--with-startup (&rest body)
"Schedule BODY to be executed at the end of tramp.el."
`(add-hook 'tramp--startup-hook (lambda () ,@body))))
`(add-hook 'tramp--startup-hook (lambda () ,@body)))
(require 'tramp-loaddefs)
(eval-and-compile
(defalias 'tramp-byte-run--set-suppress-trace
#'(lambda (f _args val)
(list 'function-put (list 'quote f)
''tramp-suppress-trace val)))
(add-to-list
'defun-declarations-alist
(list 'tramp-suppress-trace #'tramp-byte-run--set-suppress-trace))))
;;; User Customizable Internal Variables:
(defgroup tramp nil
"Edit remote files with a combination of ssh, scp, etc."
:group 'files
:group 'comm
:version "22.1"
:link '(custom-manual "(tramp)Top"))
;; Maybe we need once a real Tramp mode, with key bindings etc.
;;;###autoload
@ -1480,6 +1488,7 @@ If LOCALNAME is an absolute file name, set it as localname. If
LOCALNAME is a relative file name, return `tramp-cache-undefined'.
Objects returned by this function compare `equal' if they refer to the
same connection. Make a copy in order to avoid side effects."
;; (declare (tramp-suppress-trace t))
(if (and (stringp localname)
(not (file-name-absolute-p localname)))
(setq vec tramp-cache-undefined)
@ -1491,13 +1500,16 @@ same connection. Make a copy in order to avoid side effects."
(tramp-file-name-hop vec) nil))
vec))
;; We cannot declare our private symbols in loaddefs.
(function-put 'tramp-file-name-unify 'tramp-suppress-trace t)
;; We cannot use the `declare' form for `tramp-suppress-trace' in
;; autoloaded functions, because the tramp-loaddefs.el generation
;; would fail.
(function-put #'tramp-file-name-unify 'tramp-suppress-trace t)
;; Comparison of file names is performed by `tramp-equal-remote'.
(defun tramp-file-name-equal-p (vec1 vec2)
"Check, whether VEC1 and VEC2 denote the same `tramp-file-name'.
LOCALNAME and HOP do not count."
(declare (tramp-suppress-trace t))
(and (tramp-file-name-p vec1) (tramp-file-name-p vec2)
(equal (tramp-file-name-unify vec1)
(tramp-file-name-unify vec2))))
@ -1526,6 +1538,7 @@ entry does not exist, return nil."
;;;###tramp-autoload
(defun tramp-tramp-file-p (name)
"Return t if NAME is a string with Tramp file name syntax."
;; (declare (tramp-suppress-trace t))
(and tramp-mode (stringp name)
;; No "/:" and "/c:". This is not covered by `tramp-file-name-regexp'.
(not (string-match-p (rx bos "/" (? alpha) ":") name))
@ -1535,6 +1548,11 @@ entry does not exist, return nil."
(string-match-p tramp-file-name-regexp name)
t))
;; We cannot use the `declare' form for `tramp-suppress-trace' in
;; autoloaded functions, because the tramp-loaddefs.el generation
;; would fail.
(function-put #'tramp-tramp-file-p 'tramp-suppress-trace t)
;; This function bypasses the file name handler approach. It is NOT
;; recommended to use it in any package if not absolutely necessary.
;; However, it is more performant than `file-local-name', and might be
@ -1563,6 +1581,7 @@ of `process-file', `start-file-process', or `shell-command'."
"Return the right method string to use depending on USER and HOST.
This is METHOD, if non-nil. Otherwise, do a lookup in
`tramp-default-method-alist' and `tramp-default-method'."
(declare (tramp-suppress-trace t))
(when (and method
(or (string-empty-p method)
(string-equal method tramp-default-method-marker)))
@ -1588,6 +1607,7 @@ This is METHOD, if non-nil. Otherwise, do a lookup in
"Return the right user string to use depending on METHOD and HOST.
This is USER, if non-nil. Otherwise, do a lookup in
`tramp-default-user-alist' and `tramp-default-user'."
(declare (tramp-suppress-trace t))
(let ((result
(or user
(let ((choices tramp-default-user-alist)
@ -1609,6 +1629,7 @@ This is USER, if non-nil. Otherwise, do a lookup in
"Return the right host string to use depending on METHOD and USER.
This is HOST, if non-nil. Otherwise, do a lookup in
`tramp-default-host-alist' and `tramp-default-host'."
(declare (tramp-suppress-trace t))
(let ((result
(or (and (tramp-compat-length> host 0) host)
(let ((choices tramp-default-host-alist)
@ -1635,6 +1656,7 @@ localname (file name on remote host), and hop.
Unless NODEFAULT is non-nil, method, user and host are expanded
to their default values. For the other file name parts, no
default values are used."
;; (declare (tramp-suppress-trace t))
(save-match-data
(unless (tramp-tramp-file-p name)
(tramp-user-error nil "Not a Tramp file name: \"%s\"" name))
@ -1691,8 +1713,10 @@ default values are used."
(tramp-user-error
v "Method `%s' is not supported for multi-hops" method)))))))
;; We cannot declare our private symbols in loaddefs.
(function-put 'tramp-dissect-file-name 'tramp-suppress-trace t)
;; We cannot use the `declare' form for `tramp-suppress-trace' in
;; autoloaded functions, because the tramp-loaddefs.el generation
;; would fail.
(function-put #'tramp-dissect-file-name 'tramp-suppress-trace t)
;;;###tramp-autoload
(defun tramp-ensure-dissected-file-name (vec-or-filename)
@ -1700,13 +1724,16 @@ default values are used."
VEC-OR-FILENAME may be either a string or a `tramp-file-name'.
If it's not a Tramp filename, return nil."
;; (declare (tramp-suppress-trace t))
(cond
((tramp-file-name-p vec-or-filename) vec-or-filename)
((tramp-tramp-file-p vec-or-filename)
(tramp-dissect-file-name vec-or-filename))))
;; We cannot declare our private symbols in loaddefs.
(function-put 'tramp-ensure-dissected-file-name 'tramp-suppress-trace t)
;; We cannot use the `declare' form for `tramp-suppress-trace' in
;; autoloaded functions, because the tramp-loaddefs.el generation
;; would fail.
(function-put #'tramp-ensure-dissected-file-name 'tramp-suppress-trace t)
(defun tramp-dissect-hop-name (name &optional nodefault)
"Return a `tramp-file-name' structure of `hop' part of NAME.
@ -1733,6 +1760,7 @@ See `tramp-dissect-file-name' for details."
(defun tramp-buffer-name (vec)
"A name for the connection buffer VEC."
(declare (tramp-suppress-trace t))
(let ((method (tramp-file-name-method vec))
(user-domain (tramp-file-name-user-domain vec))
(host-port (tramp-file-name-host-port vec)))
@ -6166,6 +6194,7 @@ Return the local name of the temporary file."
(defun tramp-delete-temp-file-function ()
"Remove temporary files related to current buffer."
(declare (tramp-suppress-trace t))
(when (stringp tramp-temp-buffer-file-name)
(ignore-errors (delete-file tramp-temp-buffer-file-name))))
@ -6458,6 +6487,7 @@ Consults the auth-source package."
(defun tramp-time-diff (t1 t2)
"Return the difference between the two times, in seconds.
T1 and T2 are time values (as returned by `current-time' for example)."
(declare (tramp-suppress-trace t))
(float-time (time-subtract t1 t2)))
(defun tramp-unquote-shell-quote-argument (s)