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

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

[elpa] externals/orderless ae36760f61 015/204: Colorize matching portion


From: ELPA Syncer
Subject: [elpa] externals/orderless ae36760f61 015/204: Colorize matching portions of candidates
Date: Tue, 11 Jan 2022 12:58:13 -0500 (EST)

branch: externals/orderless
commit ae36760f610d25693f089dde31b51d4e9c5f9363
Author: Omar Antolín <omar.antolin@gmail.com>
Commit: Omar Antolín <omar.antolin@gmail.com>

    Colorize matching portions of candidates
---
 orderless.el | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/orderless.el b/orderless.el
index 22ac79927e..c5150560f3 100644
--- a/orderless.el
+++ b/orderless.el
@@ -45,6 +45,15 @@
 
 ;;; Code:
 
+(defun orderless-highlight-match (regexp string)
+  (when (string-match regexp string)
+    (font-lock-prepend-text-property
+     (match-beginning 0)
+     (match-end 0)
+     'face 'completions-common-part
+     string)
+    t))
+
 (defun orderless-all-completions (string table pred _point)
   (let* ((lim (car (completion-boundaries string table pred "")))
          (prefix (substring string 0 lim))
@@ -55,10 +64,12 @@
     (condition-case nil
         (progn
           (setq all
-                (cl-loop for candidate in all
-                         when (cl-loop for regexp in regexps
-                                       always (string-match-p regexp 
candidate))
-                         collect candidate))
+           (save-match-data
+             (cl-loop for candidate in all
+                      when (cl-loop for regexp in regexps
+                                    always (orderless-highlight-match
+                                            regexp candidate))
+                      collect candidate)))
           (when all (nconc all (length prefix))))
       (invalid-regexp nil))))
 



reply via email to

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