emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 9fd61a5: Avoid using `add-to-list' on a let-local v


From: Michael Albinus
Subject: [Emacs-diffs] master 9fd61a5: Avoid using `add-to-list' on a let-local var in tramp-smb.el
Date: Wed, 28 Oct 2015 14:31:50 +0000

branch: master
commit 9fd61a5aa2961d18ae00700bcbb527e5a643f3a2
Author: Michael Albinus <address@hidden>
Commit: Michael Albinus <address@hidden>

    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.
---
 lisp/net/tramp-compat.el |   10 ++++++++++
 lisp/net/tramp-smb.el    |    6 ++----
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/lisp/net/tramp-compat.el b/lisp/net/tramp-compat.el
index 7157ac2..c571028 100644
--- a/lisp/net/tramp-compat.el
+++ b/lisp/net/tramp-compat.el
@@ -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)
diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el
index 5910d1f..c956795 100644
--- a/lisp/net/tramp-smb.el
+++ b/lisp/net/tramp-smb.el
@@ -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."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]