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

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

[nongnu] elpa/flx 64b8e0f934 027/182: work around ido bug 10994


From: ELPA Syncer
Subject: [nongnu] elpa/flx 64b8e0f934 027/182: work around ido bug 10994
Date: Tue, 13 Dec 2022 03:59:21 -0500 (EST)

branch: elpa/flx
commit 64b8e0f9340891f3e655d57cc50e06475ecb85cc
Author: Le Wang <le.wang@agworld.com.au>
Commit: Le Wang <le.wang@agworld.com.au>

    work around ido bug 10994
    
    - delete runs of same string in completion
---
 flx-ido.el | 30 +++++++++++++++++++++++++-----
 1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/flx-ido.el b/flx-ido.el
index e25d25acb6..a8bea9df0d 100644
--- a/flx-ido.el
+++ b/flx-ido.el
@@ -13,7 +13,7 @@
 ;; Version: 0.1
 ;; Last-Updated:
 ;;           By:
-;;     Update #: 12
+;;     Update #: 15
 ;; URL:
 ;; Keywords:
 ;; Compatibility:
@@ -64,6 +64,25 @@
 (require 'ido)
 (require 'flx)
 
+(unless (fboundp 'ido-delete-runs)
+  (defun ido-delete-runs (list)
+    "Delete consecutive runs of same item in list.
+Comparison done with `equal'.  Runs may loop back on to the first
+item, in which case, the ending items are deleted."
+    (let ((tail list)
+          before-last-run)
+      (while tail
+        (if (consp (cdr tail))
+            (if (equal (car tail) (cadr tail))
+                (setcdr tail (cddr tail))
+              (setq before-last-run tail)
+              (setq tail (cdr tail)))
+          (setq tail (cdr tail))))
+      (when (and before-last-run
+                 (equal (car list) (cadr before-last-run)))
+        (setcdr before-last-run nil)))
+    list))
+
 (defvar flx-ido-narrowed-matches-hash (make-hash-table :test 'equal))
 
 (defun flx-ido-narrowed (query items)
@@ -118,19 +137,20 @@
                         collect (cons item score)
                         into matches
                         finally return matches)))
-    (flx-ido-decorate (sort matches
-                            (lambda (x y) (> (cadr x) (cadr y)))))))
+    (flx-ido-decorate (ido-delete-runs
+                       (sort matches
+                             (lambda (x y) (> (cadr x) (cadr y))))))))
 
 (defun flx-ido-match (query items)
   "Better sorting for flx ido matching."
   (if (memq ido-cur-item '(file dir))
       (if (equal "" query)
-          (nreverse items)
+          (nreverse (ido-delete-runs items))
         (flx-ido-match-internal query items))
     (when (and (equal "" query)
                (not (gethash query flx-ido-narrowed-matches-hash)))
       ;; original function reverses list.
-      (setq items (nreverse items))
+      (setq items (nreverse (ido-delete-runs items)))
       (puthash query items flx-ido-narrowed-matches-hash))
     (destructuring-bind (exact items)
         (flx-ido-narrowed query items)



reply via email to

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