1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-02-02 13:41:30 -08:00

Tramp code cleanup

* lisp/net/tramp.el (tramp-use-absolute-autoload-file-names)
(tramp-skeleton-file-name-all-completions)
(tramp-parse-auth-sources, tramp-parse-file, tramp-parse-netrc):
* lisp/net/tramp-cache.el (tramp-parse-connection-properties):
* lisp/net/tramp-gvfs.el (tramp-gvfs-parse-device-names):
* lisp/net/tramp-sh.el (tramp-sh-handle-insert-directory):
Use `seq-uniq'.

* lisp/net/tramp.el (tramp-register-foreign-file-name-handler):
* lisp/net/tramp-fuse.el (tramp-fuse-handle-directory-files):
Use `seq-union'.

* test/lisp/net/tramp-archive-tests.el
(tramp-archive-test17-insert-directory):
* test/lisp/net/tramp-tests.el (tramp-test17-insert-directory):
Use `seq-union'.
(tramp-test42-utf8): Use `seq-uniq' and `tramp-compat-seq-keep'.
This commit is contained in:
Michael Albinus 2025-09-15 18:26:50 +02:00
parent 72c19d0f39
commit d6a7b0cd33
7 changed files with 24 additions and 27 deletions

View file

@ -647,7 +647,7 @@ your laptop to different networks frequently."
"Return a list of (user host) tuples allowed to access for METHOD.
This function is added always in `tramp-get-completion-function'
for all methods. Resulting data are derived from connection history."
(delete-dups
(seq-uniq
(tramp-compat-seq-keep
(lambda (key)
(let ((tramp-verbose 0))

View file

@ -59,11 +59,10 @@
(let ((result
(tramp-skeleton-directory-files directory full match nosort count
;; Some storage systems do not return "." and "..".
(delete-dups
(append
'("." "..")
(tramp-fuse-remove-hidden-files
(directory-files (tramp-fuse-local-file-name directory))))))))
(seq-union
'("." "..")
(tramp-fuse-remove-hidden-files
(directory-files (tramp-fuse-local-file-name directory)))))))
(if full
;; Massage the result.
(let ((local (rx

View file

@ -2556,7 +2556,7 @@ This uses \"avahi-browse\" in case D-Bus is not enabled in Avahi."
(split-string
(shell-command-to-string (format "avahi-browse -trkp %s" service))
(rx (+ (any "\r\n"))) 'omit (rx bol "+;" (* nonl) eol)))))
(delete-dups
(seq-uniq
(tramp-compat-seq-keep
(lambda (x)
(ignore-errors

View file

@ -2770,7 +2770,7 @@ The method used must be an out-of-band method."
#'file-name-directory (list localname))))
(unless (or full-directory-p (member "-d" switches))
(setq switches (append switches '("-d"))))
(setq switches (delete-dups switches)
(setq switches (seq-uniq switches)
switches (mapconcat #'tramp-shell-quote-argument switches " "))
(when wildcard
(setq switches (concat switches " " wildcard)))

View file

@ -2729,7 +2729,7 @@ This avoids problems during autoload, when `load-path' contains
remote file names."
;; We expect all other Tramp files in the same directory as tramp.el.
(let* ((dir (expand-file-name (file-name-directory (locate-library "tramp"))))
(files (delete-dups
(files (seq-uniq
(mapcar
#'file-name-sans-extension
(directory-files
@ -2803,12 +2803,11 @@ whether HANDLER is to be called. Add operations defined in
;; Mark `operations' the handler is responsible for.
(put #'tramp-file-name-handler
'operations
(delete-dups
(append
(get 'tramp-file-name-handler 'operations)
(mapcar
#'car
(symbol-value (intern (concat (symbol-name handler) "-alist"))))))))
(seq-union
(get 'tramp-file-name-handler 'operations)
(mapcar
#'car
(symbol-value (intern (concat (symbol-name handler) "-alist")))))))
(defun tramp-exists-file-name-handler (operation &rest args)
"Check, whether OPERATION runs a file name handler."
@ -2979,7 +2978,7 @@ not in completion mode."
BODY is the backend specific code."
(declare (indent 2) (debug t))
`(ignore-error file-missing
(delete-dups (delq nil (delete ""
(seq-uniq (delq nil (delete ""
(let* ((case-fold-search read-file-name-completion-ignore-case)
(result (progn ,@body)))
;; Some storage systems do not return "." and "..".
@ -3372,7 +3371,7 @@ as for \"~/.authinfo.gpg\"."
This function is added always in `tramp-get-completion-function'
for all methods. Resulting data are derived from default settings."
(and tramp-completion-use-auth-sources
(delete-dups
(seq-uniq
(tramp-compat-seq-keep
(lambda (x) `(,(plist-get x :user) ,(plist-get x :host)))
(auth-source-search
@ -3401,7 +3400,7 @@ User is always nil."
(with-temp-buffer
(insert-file-contents-literally filename)
(goto-char (point-min))
(delete-dups (delq nil
(seq-uniq (delq nil
(cl-loop while (not (eobp)) collect (funcall function))))))))
(defun tramp-parse-rhosts (filename)
@ -3538,7 +3537,7 @@ Host is always \"localhost\"."
(defun tramp-parse-netrc (filename)
"Return a list of (user host) tuples allowed to access.
User may be nil."
(delete-dups
(seq-uniq
(tramp-compat-seq-keep
(lambda (item)
(and (assoc "machine" item)
@ -5347,8 +5346,8 @@ should be set connection-local.")
(or (not (stringp buffer)) (not (tramp-tramp-file-p buffer)))
(or (not (stringp stderr)) (not (tramp-tramp-file-p stderr))))))
;; This function is used by tramp-*-handle-make-process and
;; tramp-sh-handle-process-file to filter local environment variables
;; This function is used by `tramp-*-handle-make-process' and
;; `tramp-sh-handle-process-file' to filter local environment variables
;; that should not be propagated remotely. Users can override this
;; function if necessary, for example, to ensure that a specific
;; environment variable is applied to remote processes, whether it

View file

@ -559,7 +559,7 @@ This checks also `file-name-as-directory', `file-name-directory',
(let (;; We test for the summary line. Keyword "total" could be localized.
(process-environment
(append '("LANG=C" "LANGUAGE=C" "LC_ALL=C") process-environment)))
(seq-union '("LANG=C" "LANGUAGE=C" "LC_ALL=C") process-environment)))
(unwind-protect
(progn
(with-temp-buffer

View file

@ -3515,7 +3515,7 @@ This tests also `file-directory-p' and `file-accessible-directory-p'."
(tmp-name2 (expand-file-name "foo" tmp-name1))
;; We test for the summary line. Keyword "total" could be localized.
(process-environment
(append '("LANG=C" "LANGUAGE=C" "LC_ALL=C") process-environment)))
(seq-union '("LANG=C" "LANGUAGE=C" "LC_ALL=C") process-environment)))
(unwind-protect
(progn
(make-directory tmp-name1)
@ -5656,8 +5656,7 @@ If UNSTABLE is non-nil, the test is tagged as `:unstable'."
(ert-deftest tramp-test30-make-process ()
"Check `make-process'."
:tags (append '(:expensive-test :tramp-asynchronous-processes)
(and (getenv "EMACS_EMBA_CI")
'(:unstable)))
(and (getenv "EMACS_EMBA_CI") '(:unstable)))
(skip-unless (tramp--test-enabled))
(skip-unless (tramp--test-supports-processes-p))
@ -7887,8 +7886,8 @@ This requires restrictions of file name syntax."
"🌈🍒👋")
(when (and (tramp--test-expensive-test-p) (not (tramp--test-windows-nt-p)))
(delete-dups
(mapcar
(seq-uniq
(tramp-compat-seq-keep
;; Use all available language specific snippets.
(lambda (x)
(and