diff options
| author | Juri Linkov | 2022-12-29 19:45:12 +0200 |
|---|---|---|
| committer | Juri Linkov | 2022-12-29 19:45:12 +0200 |
| commit | 0aea1cf8190aa804a0d11a67b4a3cb4b715ae82d (patch) | |
| tree | c70601b2ba5ada45987c3c1f6f06ee96c88e531d | |
| parent | 60418e6f09c67924e3e05eb4948e109d8f7c4073 (diff) | |
| download | emacs-0aea1cf8190aa804a0d11a67b4a3cb4b715ae82d.tar.gz emacs-0aea1cf8190aa804a0d11a67b4a3cb4b715ae82d.zip | |
* 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.
| -rw-r--r-- | lisp/hi-lock.el | 33 |
1 files changed, 19 insertions, 14 deletions
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 @@ the major mode specifies support for Font Lock." | |||
| 569 | (when (and face-before face-after (not (eq face-before face-after))) | 569 | (when (and face-before face-after (not (eq face-before face-after))) |
| 570 | (setq face-before nil)) | 570 | (setq face-before nil)) |
| 571 | (when (or face-after face-before) | 571 | (when (or face-after face-before) |
| 572 | (let* ((hi-text | 572 | (let* ((beg (if face-before |
| 573 | (buffer-substring-no-properties | 573 | (or (previous-single-property-change (point) 'face) |
| 574 | (if face-before | 574 | (point-min)) |
| 575 | (or (previous-single-property-change (point) 'face) | 575 | (point))) |
| 576 | (point-min)) | 576 | (end (if face-after |
| 577 | (point)) | 577 | (or (next-single-property-change (point) 'face) |
| 578 | (if face-after | 578 | (point-max)) |
| 579 | (or (next-single-property-change (point) 'face) | 579 | (point)))) |
| 580 | (point-max)) | ||
| 581 | (point))))) | ||
| 582 | ;; Compute hi-lock patterns that match the | 580 | ;; Compute hi-lock patterns that match the |
| 583 | ;; highlighted text at point. Use this later in | 581 | ;; highlighted text at point. Use this later in |
| 584 | ;; during completing-read. | 582 | ;; during completing-read. |
| 585 | (dolist (hi-lock-pattern hi-lock-interactive-patterns) | 583 | (dolist (hi-lock-pattern hi-lock-interactive-patterns) |
| 586 | (let ((regexp (or (car (rassq hi-lock-pattern hi-lock-interactive-lighters)) | 584 | (let ((pattern (or (rassq hi-lock-pattern hi-lock-interactive-lighters) |
| 587 | (car hi-lock-pattern)))) | 585 | (car hi-lock-pattern)))) |
| 588 | (if (string-match regexp hi-text) | 586 | (cond |
| 589 | (push regexp regexps))))))) | 587 | ((stringp pattern) |
| 588 | (when (string-match pattern (buffer-substring-no-properties beg end)) | ||
| 589 | (push pattern regexps))) | ||
| 590 | ((functionp (cadr pattern)) | ||
| 591 | (save-excursion | ||
| 592 | (goto-char beg) | ||
| 593 | (when (funcall (cadr pattern) end) | ||
| 594 | (push (car pattern) regexps)))))))))) | ||
| 590 | regexps)) | 595 | regexps)) |
| 591 | 596 | ||
| 592 | (defvar-local hi-lock--unused-faces nil | 597 | (defvar-local hi-lock--unused-faces nil |