[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#60241: 29.0.60; Fix regexp pattern case in hi-lock
From: |
Juri Linkov |
Subject: |
bug#60241: 29.0.60; Fix regexp pattern case in hi-lock |
Date: |
Wed, 21 Dec 2022 19:29:11 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) |
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:
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
- bug#60241: 29.0.60; Fix regexp pattern case in hi-lock,
Juri Linkov <=