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

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

[elpa] externals/urgrep c0ccc33ae5: Combine change calls in `urgrep-filt


From: ELPA Syncer
Subject: [elpa] externals/urgrep c0ccc33ae5: Combine change calls in `urgrep-filter`
Date: Wed, 24 Jan 2024 18:59:10 -0500 (EST)

branch: externals/urgrep
commit c0ccc33ae5480a1bd3ea52a62d0818fe56926642
Author: Jim Porter <jporterbugs@gmail.com>
Commit: Jim Porter <jporterbugs@gmail.com>

    Combine change calls in `urgrep-filter`
    
    This prevents a hang when using `outline-minor-mode`.
---
 NEWS.md   |  7 +++++++
 urgrep.el | 41 +++++++++++++++++++++++------------------
 2 files changed, 30 insertions(+), 18 deletions(-)

diff --git a/NEWS.md b/NEWS.md
index be3e3d4846..90243c1a76 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,5 +1,12 @@
 # Urgrep News
 
+## v0.4.1 (in progress)
+
+### Bug fixes
+- Fix highlighting of matches when using Ugrep
+
+---
+
 ## v0.4.0 (2024-01-22)
 
 ### New features
diff --git a/urgrep.el b/urgrep.el
index 8bd2ae06ab..ca6436e2fe 100644
--- a/urgrep.el
+++ b/urgrep.el
@@ -993,19 +993,22 @@ This function is called from `compilation-filter-hook'."
                   (unless (re-search-forward (rx (ansi-sgr (? "0"))) end t)
                     ;; The filename is incomplete.  Try again next time.
                     (throw 'done nil))
-                  (unless (= file-name-begin (match-beginning 0))
-                    (setq file-name (buffer-substring-no-properties
-                                     file-name-begin (match-beginning 0))
-                          same-file (equal file-name urgrep--filter-last-file)
-                          urgrep--filter-last-file file-name)
-                    (add-text-properties
-                     file-name-begin (match-beginning 0)
-                     `( face nil
-                        font-lock-face urgrep-hit
-                        urgrep-file-name ,(if same-file 'repeat 'first))))
-                  ;; Remove the control sequences.
-                  (replace-match "" t t)
-                  (delete-region cseq-begin file-name-begin)))
+                  (combine-change-calls cseq-begin (match-end 0)
+                    ;; Ugrep produces empty "filename" ANSI sequences after the
+                    ;; real filename+sequence.
+                    (unless (= file-name-begin (match-beginning 0))
+                      (setq file-name (buffer-substring-no-properties
+                                       file-name-begin (match-beginning 0))
+                            same-file (equal file-name 
urgrep--filter-last-file)
+                            urgrep--filter-last-file file-name)
+                      (add-text-properties
+                       file-name-begin (match-beginning 0)
+                       `( face nil
+                          font-lock-face urgrep-hit
+                          urgrep-file-name ,(if same-file 'repeat 'first))))
+                    ;; Remove the control sequences.
+                    (replace-match "" t t)
+                    (delete-region cseq-begin file-name-begin))))
                ;; Highlight matches and delete ANSI SGR escapes.
                ((looking-at (rx (or ;; Find the escapes together...
                                  (ansi-sgr (or "01" "1") ";31")
@@ -1018,11 +1021,13 @@ This function is called from `compilation-filter-hook'."
                     ;; The match is incomplete.  Try again next time.
                     (throw 'done nil))
                   (cl-incf urgrep-num-matches-found)
-                  (add-text-properties match-begin (match-beginning 0)
-                                       '(face nil font-lock-face urgrep-match))
-                  ;; Remove the control sequences.
-                  (replace-match "" t t)
-                  (delete-region cseq-begin match-begin)))
+                  (combine-change-calls cseq-begin (match-end 0)
+                    (add-text-properties
+                     match-begin (match-beginning 0)
+                     '(face nil font-lock-face urgrep-match))
+                    ;; Remove the control sequences.
+                    (replace-match "" t t)
+                    (delete-region cseq-begin match-begin))))
                ;; If nothing matched, just proceed forward.
                (t (forward-char))))))
             (setq urgrep--filter-start (point))))))



reply via email to

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