diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2012-12-10 16:26:13 -0500 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2012-12-10 16:26:13 -0500 |
commit | ed6f2cd47f126b38f81ab0f45b7da42a8ae1985f (patch) | |
tree | 42061050b1651a4f4b6fb9bae67e8609ba4c258a /lisp/hi-lock.el | |
parent | 5b55e0b70f89dee84f6550e66267358a0a96d6b8 (diff) | |
download | emacs-ed6f2cd47f126b38f81ab0f45b7da42a8ae1985f.tar.gz |
* lisp/hi-lock.el (hi-lock--regexps-at-point): Fix boundary case for
font-lock as well as when there's no text-property.
Diffstat (limited to 'lisp/hi-lock.el')
-rw-r--r-- | lisp/hi-lock.el | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/lisp/hi-lock.el b/lisp/hi-lock.el index a6ad4dd26e0..2ae328a09e8 100644 --- a/lisp/hi-lock.el +++ b/lisp/hi-lock.el @@ -474,19 +474,33 @@ updated as you type." (let ((regexp (get-char-property (point) 'hi-lock-overlay-regexp))) (when regexp (push regexp regexps))) ;; With font-locking on, check if the cursor is on a highlighted text. - (and (memq (face-at-point) - (mapcar #'hi-lock-keyword->face hi-lock-interactive-patterns)) - (let* ((hi-text - (buffer-substring-no-properties - (previous-single-property-change (point) 'face) - (next-single-property-change (point) 'face)))) - ;; 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 (car hi-lock-pattern))) - (if (string-match regexp hi-text) - (push regexp regexps)))))) + (let ((face-after (get-text-property (point) 'face)) + (face-before + (unless (bobp) (get-text-property (1- (point)) 'face))) + (faces (mapcar #'hi-lock-keyword->face + hi-lock-interactive-patterns))) + (unless (memq face-before faces) (setq face-before nil)) + (unless (memq face-after faces) (setq face-after nil)) + (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))))) + ;; 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 (car hi-lock-pattern))) + (if (string-match regexp hi-text) + (push regexp regexps))))))) regexps)) (defvar-local hi-lock--unused-faces nil |