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

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

[elpa] externals/xeft ad2d7b259d 23/55: Don't highlight short keywords.


From: ELPA Syncer
Subject: [elpa] externals/xeft ad2d7b259d 23/55: Don't highlight short keywords.
Date: Fri, 13 Jan 2023 23:58:37 -0500 (EST)

branch: externals/xeft
commit ad2d7b259d6e296b49b004a1510ccf821ba3db16
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>

    Don't highlight short keywords.
    
    * xeft.el (xeft--highlight-search-phrase, xeft--highlight-matched):
    Add condition (> (length keyword) 1).
---
 xeft.el | 34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/xeft.el b/xeft.el
index 574ac51ced..b0401f9a14 100644
--- a/xeft.el
+++ b/xeft.el
@@ -330,16 +330,17 @@ If SELECT is non-nil, select the buffer after displaying 
it."
                        (split-string (xeft--get-search-phrase))))
         (inhibit-read-only t))
     (dolist (keyword keyword-list)
-      (goto-char (point-min))
-      (forward-line 2)
-      ;; We use overlay because overlay allows face composition.
-      ;; So we can have bold + underline.
-      (while (search-forward keyword nil t)
-        (let ((ov (make-overlay (match-beginning 0)
-                                (match-end 0))))
-          (overlay-put ov 'face 'xeft-inline-highlight)
-          (overlay-put ov 'xeft-highlight t)
-          (overlay-put ov 'evaporate t))))))
+      (when (> (length keyword) 1)
+        (goto-char (point-min))
+        (forward-line 2)
+        ;; We use overlay because overlay allows face composition.
+        ;; So we can have bold + underline.
+        (while (search-forward keyword nil t)
+          (let ((ov (make-overlay (match-beginning 0)
+                                  (match-end 0))))
+            (overlay-put ov 'face 'xeft-inline-highlight)
+            (overlay-put ov 'xeft-highlight t)
+            (overlay-put ov 'evaporate t)))))))
 
 (defvar xeft--ecache nil
   "Cache for finding excerpt for a file.")
@@ -546,12 +547,13 @@ non-nil, display all results."
   (save-excursion
     ;; Add highlight overlays.
     (dolist (keyword keyword-list)
-      (goto-char (point-min))
-      (while (search-forward keyword nil t)
-        (let ((ov (make-overlay (match-beginning 0)
-                                (match-end 0))))
-          (overlay-put ov 'face 'xeft-preview-highlight)
-          (overlay-put ov 'xeft-highlight t))))
+      (when (> (length keyword) 1)
+        (goto-char (point-min))
+        (while (search-forward keyword nil t)
+          (let ((ov (make-overlay (match-beginning 0)
+                                  (match-end 0))))
+            (overlay-put ov 'face 'xeft-preview-highlight)
+            (overlay-put ov 'xeft-highlight t)))))
     ;; Add cleanup hook.
     (add-hook 'window-selection-change-functions
               #'xeft--cleanup-highlight



reply via email to

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