* lisp/hi-lock.el (hi-lock--regexps-at-point): Fix bug (bug#60241).
Handle two cases: when a pattern is a regexp or a function.
This commit is contained in:
parent
60418e6f09
commit
0aea1cf819
1 changed files with 19 additions and 14 deletions
|
@ -569,24 +569,29 @@ the major mode specifies support for Font Lock."
|
|||
(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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue