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

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

[nongnu] elpa/flx 01818a56ae 039/182: handle of cons cells in completion


From: ELPA Syncer
Subject: [nongnu] elpa/flx 01818a56ae 039/182: handle of cons cells in completion list
Date: Tue, 13 Dec 2022 03:59:23 -0500 (EST)

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

    handle of cons cells in completion list
    
    #11
---
 flx-ido.el | 27 ++++++++++++---------------
 flx.el     | 39 ++++++++++++++++++++++++---------------
 2 files changed, 36 insertions(+), 30 deletions(-)

diff --git a/flx-ido.el b/flx-ido.el
index bca362aca4..e8596e6490 100644
--- a/flx-ido.el
+++ b/flx-ido.el
@@ -13,7 +13,7 @@
 ;; Version: 0.1
 ;; Last-Updated:
 ;;           By:
-;;     Update #: 23
+;;     Update #: 30
 ;; URL:
 ;; Keywords:
 ;; Compatibility:
@@ -118,20 +118,17 @@ item, in which case, the ending items are deleted."
 
 
 (defun flx-ido-decorate (things &optional clear)
-  (if (consp (car-safe (car things)))
-      (mapcar 'car things)
-    (let ((decorate-count (min ido-max-prospects
-                               (length things))))
-      (nconc
-       (loop for thing in things
-             for i from 0 below decorate-count
-             collect (if clear
-                         (substring-no-properties thing)
-                       ;; copy the string in case it's "pure"
-                       (flx-propertize (copy-sequence (car thing)) (cdr 
thing))))
-       (if clear
-           (nthcdr decorate-count things)
-         (mapcar 'car (nthcdr decorate-count things)))))))
+  (let ((decorate-count (min ido-max-prospects
+                             (length things))))
+    (nconc
+     (loop for thing in things
+           for i from 0 below decorate-count
+           collect (if clear
+                       (flx-propertize thing nil)
+                     (flx-propertize (car thing) (cdr thing))))
+     (if clear
+         (nthcdr decorate-count things)
+       (mapcar 'car (nthcdr decorate-count things))))))
 
 (defun flx-ido-match-internal (query items)
   (let* ((matches (loop for item in items
diff --git a/flx.el b/flx.el
index 0588f2d072..5f2e64ede8 100644
--- a/flx.el
+++ b/flx.el
@@ -13,7 +13,7 @@
 ;; Version: 0.1
 ;; Last-Updated:
 ;;           By:
-;;     Update #: 15
+;;     Update #: 17
 ;; URL:
 ;; Keywords:
 ;; Compatibility:
@@ -321,21 +321,30 @@ e.g. (\"aab\" \"ab\") returns
       best-score)))
 
 
-(defun flx-propertize (str score &optional add-score)
-  "Return propertized string according to score."
+(defun flx-propertize (obj score &optional add-score)
+  "Return propertized copy of obj according to score.
+
+SCORE of nil means to clear the properties."
   (let ((block-started (cadr score))
-        (last-char nil))
-    (loop for char in (cdr score)
-          do (progn
-               (when (and last-char
-                          (not (= (1+ last-char) char)))
-                 (put-text-property block-started  (1+ last-char) 'face 
'flx-highlight-face str)
-                 (setq block-started char))
-               (setq last-char char)))
-    (put-text-property block-started  (1+ last-char) 'face 'flx-highlight-face 
str)
-    (when add-score
-      (setq str (format "%s [%s]" str (car score))))
-    str))
+        (last-char nil)
+        (str (if (consp obj)
+                 (substring-no-properties (car obj))
+               (substring-no-properties obj))))
+
+    (unless (null score)
+      (loop for char in (cdr score)
+            do (progn
+                 (when (and last-char
+                            (not (= (1+ last-char) char)))
+                   (put-text-property block-started  (1+ last-char) 'face 
'flx-highlight-face str)
+                   (setq block-started char))
+                 (setq last-char char)))
+      (put-text-property block-started  (1+ last-char) 'face 
'flx-highlight-face str)
+      (when add-score
+        (setq str (format "%s [%s]" str (car score)))))
+    (if (consp obj)
+        (cons str (cdr obj))
+      str)))
 
 
 



reply via email to

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