]> code.delx.au - gnu-emacs/commitdiff
Avoid using `add-to-list' on a let-local var in tramp-smb.el
authorMichael Albinus <michael.albinus@gmx.de>
Wed, 28 Oct 2015 14:31:40 +0000 (15:31 +0100)
committerMichael Albinus <michael.albinus@gmx.de>
Wed, 28 Oct 2015 14:31:40 +0000 (15:31 +0100)
* lisp/net/tramp-compat.el (tramp-compat-delete-dups): New defun.
* lisp/net/tramp-smb.el (tramp-smb-handle-directory-files): Use it.

lisp/net/tramp-compat.el
lisp/net/tramp-smb.el

index 7157ac25fa20310fd9dcf1f4617fc7f3e0fc2cc0..c57102881bf1eda8a5f9881689bb42316c5e40c4 100644 (file)
@@ -592,6 +592,16 @@ and replace a sub-expression, e.g.
 (unless (fboundp 'format-message)
   (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
          (lambda ()
            (unload-feature 'tramp-loaddefs 'force)
index 5910d1fd3a46968882e3b671cdf63771eaf78f65..c95679584dc2f3a01615cb323cbff84f70077986 100644 (file)
@@ -649,8 +649,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
   (directory &optional full match nosort)
   "Like `directory-files' for Tramp files."
   (let ((result (mapcar 'directory-file-name
-                       (file-name-all-completions "" directory)))
-       res)
+                       (file-name-all-completions "" directory))))
     ;; Discriminate with regexp.
     (when match
       (setq result
@@ -666,8 +665,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
     ;; Sort them if necessary.
     (unless nosort (setq result (sort result 'string-lessp)))
     ;; Remove double entries.
-    (dolist (elt result res)
-      (add-to-list 'res elt 'append))))
+    (tramp-compat-delete-dups result)))
 
 (defun tramp-smb-handle-expand-file-name (name &optional dir)
   "Like `expand-file-name' for Tramp files."