* bug#60241: 29.0.60; Fix regexp pattern case in hi-lock
@ 2022-12-21 17:29 Juri Linkov
2022-12-29 17:45 ` Juri Linkov
0 siblings, 1 reply; 2+ messages in thread
From: Juri Linkov @ 2022-12-21 17:29 UTC (permalink / raw)
To: 60241
[-- Attachment #1: Type: text/plain, Size: 255 bytes --]
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:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: hi-lock--regexps-at-point.patch --]
[-- Type: text/x-diff, Size: 2197 bytes --]
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* bug#60241: 29.0.60; Fix regexp pattern case in hi-lock
2022-12-21 17:29 bug#60241: 29.0.60; Fix regexp pattern case in hi-lock Juri Linkov
@ 2022-12-29 17:45 ` Juri Linkov
0 siblings, 0 replies; 2+ messages in thread
From: Juri Linkov @ 2022-12-29 17:45 UTC (permalink / raw)
To: 60241
close 60241 29.0.60
quit
> 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:
Pushed and closed.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-12-29 17:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-21 17:29 bug#60241: 29.0.60; Fix regexp pattern case in hi-lock Juri Linkov
2022-12-29 17:45 ` Juri Linkov
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).