branch: externals/urgrep
commit 99e1de4eb1d2f37e6ca852968f2f28de4a708201
Author: Jim Porter <jporterb...@gmail.com>
Commit: Jim Porter <jporterb...@gmail.com>

    Fix an edge case when unable to get the grouped filename for highlighting
    
    Sometimes, this code can run before `urgrep-filter` has propertized the
    filenames, resulting in it being unable to find the file name. On Emacs 27 
and
    lower, this breaks compilation-mode.
---
 urgrep.el | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/urgrep.el b/urgrep.el
index 831baa2ae3..c0c3947dd4 100644
--- a/urgrep.el
+++ b/urgrep.el
@@ -764,8 +764,10 @@ versions, it's half-open.  Use this to adjust the value as 
needed in
   "Look backwards for the filename when a match is found in grouped output."
   (save-excursion
     (if-let ((match (text-property-search-backward 'urgrep-file-name)))
-        (buffer-substring (prop-match-beginning match)
-                          (prop-match-end match)))))
+        (buffer-substring-no-properties (prop-match-beginning match)
+                                        (prop-match-end match))
+      ;; Emacs 27 and lower will break if we return nil from this function.
+      (when (< emacs-major-version 28) "*unknown*"))))
 
 (defconst urgrep-regexp-alist
   ;; XXX: Try to rely on ANSI escapes as with the match highlight?

Reply via email to