emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/vertico 9b81d8d 08/48: remove ./ and ../ from file comp


From: Stefan Monnier
Subject: [elpa] externals/vertico 9b81d8d 08/48: remove ./ and ../ from file completion candidates
Date: Mon, 5 Apr 2021 10:54:40 -0400 (EDT)

branch: externals/vertico
commit 9b81d8dbba44cc27ef7260becd320f8b7d60a89b
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    remove ./ and ../ from file completion candidates
---
 minicomp.el | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/minicomp.el b/minicomp.el
index 6ca97dc..0497931 100644
--- a/minicomp.el
+++ b/minicomp.el
@@ -174,21 +174,24 @@
                    (prog1 (cdr last)
                      (setcdr last nil))
                  0))
-         (total (length all))
-         (candidates (if (> total minicomp-sort-threshold)
-                         all
-                       (funcall
-                        (or (completion-metadata-get metadata 
'display-sort-function)
-                            #'minicomp--sort)
-                        all))))
+         (total))
+    (when (eq (completion-metadata-get metadata 'category) 'file)
+      (setq all (delete "../" (delete "./" all))))
+    (setq total (length all)
+          all (if (> total minicomp-sort-threshold)
+                  all
+                (funcall
+                 (or (completion-metadata-get metadata 'display-sort-function)
+                     #'minicomp--sort)
+                 all)))
     (when-let* ((def (cond
                       ((stringp (car-safe minibuffer-default)) (car 
minibuffer-default))
                       ((stringp minibuffer-default) minibuffer-default)))
-                (rest (member def candidates)))
-      (setq candidates (nconc (list (car rest)) (delete def candidates))))
+                (rest (member def all)))
+      (setq all (nconc (list (car rest)) (delete def all))))
     (when-let (group (completion-metadata-get metadata 'x-group-function))
-      (setq candidates (mapcan #'cdr (funcall group candidates))))
-    (list base total candidates)))
+      (setq all (mapcan #'cdr (funcall group all))))
+    (list base total all)))
 
 (defun minicomp--recompute (input metadata)
   "Preprocess candidates with INPUT string and METADATA."



reply via email to

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