Commit 9fd61a5a authored by Michael Albinus's avatar Michael Albinus
Browse files

Avoid using `add-to-list' on a let-local var in tramp-smb.el

* lisp/net/tramp-compat.el (tramp-compat-delete-dups): New defun.
* lisp/net/tramp-smb.el (tramp-smb-handle-directory-files): Use it.
parent 1e2ed268
...@@ -592,6 +592,16 @@ and replace a sub-expression, e.g. ...@@ -592,6 +592,16 @@ and replace a sub-expression, e.g.
(unless (fboundp 'format-message) (unless (fboundp 'format-message)
(defalias 'format-message 'format)) (defalias 'format-message 'format))
;; `delete-dups' does not exist in XEmacs 21.4.
(if (fboundp 'delete-dups)
(defalias 'tramp-compat-delete-dups 'delete-dups)
(defun tramp-compat-delete-dups (list)
"Destructively remove `equal' duplicates from LIST.
Store the result in LIST and return it. LIST must be a proper list.
Of several `equal' occurrences of an element in LIST, the first
one is kept."
(cl-delete-duplicates list '(:test equal :from-end) nil)))
(add-hook 'tramp-unload-hook (add-hook 'tramp-unload-hook
(lambda () (lambda ()
(unload-feature 'tramp-loaddefs 'force) (unload-feature 'tramp-loaddefs 'force)
......
...@@ -649,8 +649,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored." ...@@ -649,8 +649,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
(directory &optional full match nosort) (directory &optional full match nosort)
"Like `directory-files' for Tramp files." "Like `directory-files' for Tramp files."
(let ((result (mapcar 'directory-file-name (let ((result (mapcar 'directory-file-name
(file-name-all-completions "" directory))) (file-name-all-completions "" directory))))
res)
;; Discriminate with regexp. ;; Discriminate with regexp.
(when match (when match
(setq result (setq result
...@@ -666,8 +665,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored." ...@@ -666,8 +665,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
;; Sort them if necessary. ;; Sort them if necessary.
(unless nosort (setq result (sort result 'string-lessp))) (unless nosort (setq result (sort result 'string-lessp)))
;; Remove double entries. ;; Remove double entries.
(dolist (elt result res) (tramp-compat-delete-dups result)))
(add-to-list 'res elt 'append))))
(defun tramp-smb-handle-expand-file-name (name &optional dir) (defun tramp-smb-handle-expand-file-name (name &optional dir)
"Like `expand-file-name' for Tramp files." "Like `expand-file-name' for Tramp files."
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment