* lisp/net/tramp-compat.el (tramp-compat-seq-keep): New defalias.
* lisp/net/tramp.el (tramp-enable-method):
* lisp/net/tramp-adb.el (tramp-adb-parse-device-names):
* lisp/net/tramp-cache.el (tramp-list-connections):
* lisp/net/tramp-cmds.el (tramp-bug, tramp-append-tramp-buffers):
* lisp/net/tramp-container.el (tramp-container--completion-function)
(tramp-toolbox--completion-function)
(tramp-flatpak--completion-function)
(tramp-apptainer--completion-function):
* lisp/net/tramp-rclone.el (tramp-rclone-parse-device-names): Use it.
(cherry picked from commit
04363f9924c0f63d28f789ccdadd81a87e6f7417)
;;;###tramp-autoload
(defun tramp-adb-parse-device-names (_ignore)
"Return a list of (nil host) tuples allowed to access."
- (delq nil
- (mapcar
- (lambda (line)
- (when (string-match
- (rx bol (group (+ (not blank))) (+ blank) "device" eol) line)
- ;; Replace ":" by "#".
- `(nil ,(tramp-compat-string-replace
- ":" tramp-prefix-port-format (match-string 1 line)))))
- (tramp-process-lines nil tramp-adb-program "devices"))))
+ (tramp-compat-seq-keep
+ (lambda (line)
+ (when (string-match
+ (rx bol (group (+ (not blank))) (+ blank) "device" eol) line)
+ ;; Replace ":" by "#".
+ `(nil ,(tramp-compat-string-replace
+ ":" tramp-prefix-port-format (match-string 1 line)))))
+ (tramp-process-lines nil tramp-adb-program "devices")))
(defun tramp-adb-handle-file-system-info (filename)
"Like `file-system-info' for Tramp files."
(defun tramp-list-connections ()
"Return all active `tramp-file-name' structs according to `tramp-cache-data'."
(let ((tramp-verbose 0))
- (delq nil (mapcar
- (lambda (key)
- (and (tramp-file-name-p key)
- (null (tramp-file-name-localname key))
- (tramp-connection-property-p key "process-buffer")
- key))
- (hash-table-keys tramp-cache-data)))))
+ (tramp-compat-seq-keep
+ (lambda (key)
+ (and (tramp-file-name-p key)
+ (null (tramp-file-name-localname key))
+ (tramp-connection-property-p key "process-buffer")
+ key))
+ (hash-table-keys tramp-cache-data))))
(defun tramp-dump-connection-properties ()
"Write persistent connection properties into file \
(format "tramp (%s %s/%s)" ; package name and version
tramp-version tramp-repository-branch tramp-repository-version)
(sort
- (delq nil (mapcar
- (lambda (x)
- (and x (boundp x) (not (get x 'tramp-suppress-trace))
- (cons x 'tramp-reporter-dump-variable)))
- (append
- (mapcar #'intern (all-completions "tramp-" obarray #'boundp))
- ;; Non-Tramp variables of interest.
- '(shell-prompt-pattern
- backup-by-copying
- backup-by-copying-when-linked
- backup-by-copying-when-mismatch
- backup-by-copying-when-privileged-mismatch
- backup-directory-alist
- password-cache
- password-cache-expiry
- remote-file-name-inhibit-cache
- connection-local-profile-alist
- connection-local-criteria-alist
- file-name-handler-alist))))
+ (tramp-compat-seq-keep
+ (lambda (x)
+ (and x (boundp x) (not (get x 'tramp-suppress-trace))
+ (cons x 'tramp-reporter-dump-variable)))
+ (append
+ (mapcar #'intern (all-completions "tramp-" obarray #'boundp))
+ ;; Non-Tramp variables of interest.
+ '(shell-prompt-pattern
+ backup-by-copying
+ backup-by-copying-when-linked
+ backup-by-copying-when-mismatch
+ backup-by-copying-when-privileged-mismatch
+ backup-directory-alist
+ password-cache
+ password-cache-expiry
+ remote-file-name-inhibit-cache
+ connection-local-profile-alist
+ connection-local-criteria-alist
+ file-name-handler-alist)))
(lambda (x y) (string< (symbol-name (car x)) (symbol-name (car y)))))
'tramp-load-report-modules ; pre-hook
;; Dump buffer local variables.
(insert "\nlocal variables:\n================")
- (dolist (buffer
- (delq nil
- (mapcar
- (lambda (b)
- (when (string-match-p "\\*tramp/" (buffer-name b)) b))
- (buffer-list))))
+ (dolist (buffer (tramp-compat-seq-keep
+ (lambda (b)
+ (when (string-match-p "\\*tramp/" (buffer-name b)) b))
+ (buffer-list)))
(let ((reporter-eval-buffer buffer)
(elbuf (get-buffer-create " *tmp-reporter-buffer*")))
(with-current-buffer elbuf
(autoload 'netrc-parse "netrc")
(netrc-parse file))))
+;; Function `seq-keep' is new in Emacs 29.1.
+(defalias 'tramp-compat-seq-keep
+ (if (fboundp 'seq-keep)
+ #'seq-keep
+ (lambda (function sequence)
+ (delq nil (seq-map function sequence)))))
+
;; User option `password-colon-equivalents' is new in Emacs 30.1.
(if (boundp 'password-colon-equivalents)
(defvaralias
(concat program " ps --format '{{.ID}}\t{{.Names}}'")))
(lines (split-string raw-list "\n" 'omit))
(names
- (mapcar
+ (tramp-compat-seq-keep
(lambda (line)
(when (string-match
(rx bol (group (1+ nonl))
line)
(or (match-string 2 line) (match-string 1 line))))
lines)))
- (mapcar (lambda (name) (list nil name)) (delq nil names)))))
+ (mapcar (lambda (name) (list nil name)) names))))
;;;###tramp-autoload
(defun tramp-kubernetes--completion-function (method)
(when-let ((raw-list (shell-command-to-string (concat program " list -c")))
;; Ignore header line.
(lines (cdr (split-string raw-list "\n" 'omit)))
- (names (mapcar
+ (names (tramp-compat-seq-keep
(lambda (line)
(when (string-match
(rx bol (1+ (not space))
line)
(match-string 1 line)))
lines)))
- (mapcar (lambda (name) (list nil name)) (delq nil names)))))
+ (mapcar (lambda (name) (list nil name)) names))))
;;;###tramp-autoload
(defun tramp-flatpak--completion-function (method)
;; Ignore header line.
(concat program " ps --columns=instance,application | cat -")))
(lines (split-string raw-list "\n" 'omit))
- (names (mapcar
+ (names (tramp-compat-seq-keep
(lambda (line)
(when (string-match
(rx bol (* space) (group (+ (not space)))
line)
(or (match-string 2 line) (match-string 1 line))))
lines)))
- (mapcar (lambda (name) (list nil name)) (delq nil names)))))
+ (mapcar (lambda (name) (list nil name)) names))))
;;;###tramp-autoload
(defun tramp-apptainer--completion-function (method)
(shell-command-to-string (concat program " instance list")))
;; Ignore header line.
(lines (cdr (split-string raw-list "\n" 'omit)))
- (names (mapcar
+ (names (tramp-compat-seq-keep
(lambda (line)
(when (string-match
(rx bol (group (1+ (not space)))
line)
(match-string 1 line)))
lines)))
- (mapcar (lambda (name) (list nil name)) (delq nil names)))))
+ (mapcar (lambda (name) (list nil name)) names))))
;;;###tramp-autoload
(defvar tramp-default-remote-shell) ;; Silence byte compiler.
(defun tramp-rclone-parse-device-names (_ignore)
"Return a list of (nil host) tuples allowed to access."
(with-tramp-connection-property nil "rclone-device-names"
- (delq nil
- (mapcar
- (lambda (line)
- (when (string-match (rx bol (group (+ (not blank))) ":" eol) line)
- `(nil ,(match-string 1 line))))
- (tramp-process-lines nil tramp-rclone-program "listremotes")))))
+ (tramp-compat-seq-keep
+ (lambda (line)
+ (when (string-match (rx bol (group (+ (not blank))) ":" eol) line)
+ `(nil ,(match-string 1 line))))
+ (tramp-process-lines nil tramp-rclone-program "listremotes"))))
\f
;; File name primitives.