GNU bug report logs -
#60241
29.0.60; Fix regexp pattern case in hi-lock
Previous Next
Reported by: Juri Linkov <juri <at> linkov.net>
Date: Wed, 21 Dec 2022 17:30:03 UTC
Severity: normal
Tags: patch
Fixed in version 29.0.60
Done: Juri Linkov <juri <at> linkov.net>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Version: 29.0.60
Tags: patch
0. emacs -Q
1. Type [ M-< C-s [ M-s h r RET M-s h u
Debugger entered--Lisp error: (invalid-regexp "Unmatched [ or [^")
hi-lock--regexps-at-point()
command-execute(unhighlight-regexp)
Here is a patch to fix this error:
[hi-lock--regexps-at-point.patch (text/x-diff, inline)]
diff --git a/lisp/hi-lock.el b/lisp/hi-lock.el
index a45e74eca26..bc631747e6d 100644
--- a/lisp/hi-lock.el
+++ b/lisp/hi-lock.el
@@ -569,24 +569,29 @@ hi-lock--regexps-at-point
(when (and face-before face-after (not (eq face-before face-after)))
(setq face-before nil))
(when (or face-after face-before)
- (let* ((hi-text
- (buffer-substring-no-properties
- (if face-before
- (or (previous-single-property-change (point) 'face)
- (point-min))
- (point))
- (if face-after
- (or (next-single-property-change (point) 'face)
- (point-max))
- (point)))))
+ (let* ((beg (if face-before
+ (or (previous-single-property-change (point) 'face)
+ (point-min))
+ (point)))
+ (end (if face-after
+ (or (next-single-property-change (point) 'face)
+ (point-max))
+ (point))))
;; Compute hi-lock patterns that match the
;; highlighted text at point. Use this later in
;; during completing-read.
(dolist (hi-lock-pattern hi-lock-interactive-patterns)
- (let ((regexp (or (car (rassq hi-lock-pattern hi-lock-interactive-lighters))
- (car hi-lock-pattern))))
- (if (string-match regexp hi-text)
- (push regexp regexps)))))))
+ (let ((pattern (or (rassq hi-lock-pattern hi-lock-interactive-lighters)
+ (car hi-lock-pattern))))
+ (cond
+ ((stringp pattern)
+ (when (string-match pattern (buffer-substring-no-properties beg end))
+ (push pattern regexps)))
+ ((functionp (cadr pattern))
+ (save-excursion
+ (goto-char beg)
+ (when (funcall (cadr pattern) end)
+ (push (car pattern) regexps))))))))))
regexps))
(defvar-local hi-lock--unused-faces nil
This bug report was last modified 2 years and 172 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.