aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2012-12-10 16:26:13 -0500
committerStefan Monnier2012-12-10 16:26:13 -0500
commited6f2cd47f126b38f81ab0f45b7da42a8ae1985f (patch)
tree42061050b1651a4f4b6fb9bae67e8609ba4c258a
parent5b55e0b70f89dee84f6550e66267358a0a96d6b8 (diff)
downloademacs-ed6f2cd47f126b38f81ab0f45b7da42a8ae1985f.tar.gz
emacs-ed6f2cd47f126b38f81ab0f45b7da42a8ae1985f.zip
* lisp/hi-lock.el (hi-lock--regexps-at-point): Fix boundary case for
font-lock as well as when there's no text-property.
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/hi-lock.el40
2 files changed, 32 insertions, 13 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index c75a6a9719f..aa870591e23 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12012-12-10 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * hi-lock.el (hi-lock--regexps-at-point): Fix boundary case for
4 font-lock as well as when there's no text-property.
5
12012-12-10 Jambunathan K <kjambunathan@gmail.com> 62012-12-10 Jambunathan K <kjambunathan@gmail.com>
2 7
3 * hi-lock.el: Refine the choice of default face. 8 * hi-lock.el: Refine the choice of default face.
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."
474 (let ((regexp (get-char-property (point) 'hi-lock-overlay-regexp))) 474 (let ((regexp (get-char-property (point) 'hi-lock-overlay-regexp)))
475 (when regexp (push regexp regexps))) 475 (when regexp (push regexp regexps)))
476 ;; With font-locking on, check if the cursor is on a highlighted text. 476 ;; With font-locking on, check if the cursor is on a highlighted text.
477 (and (memq (face-at-point) 477 (let ((face-after (get-text-property (point) 'face))
478 (mapcar #'hi-lock-keyword->face hi-lock-interactive-patterns)) 478 (face-before
479 (let* ((hi-text 479 (unless (bobp) (get-text-property (1- (point)) 'face)))
480 (buffer-substring-no-properties 480 (faces (mapcar #'hi-lock-keyword->face
481 (previous-single-property-change (point) 'face) 481 hi-lock-interactive-patterns)))
482 (next-single-property-change (point) 'face)))) 482 (unless (memq face-before faces) (setq face-before nil))
483 ;; Compute hi-lock patterns that match the 483 (unless (memq face-after faces) (setq face-after nil))
484 ;; highlighted text at point. Use this later in 484 (when (and face-before face-after (not (eq face-before face-after)))
485 ;; during completing-read. 485 (setq face-before nil))
486 (dolist (hi-lock-pattern hi-lock-interactive-patterns) 486 (when (or face-after face-before)
487 (let ((regexp (car hi-lock-pattern))) 487 (let* ((hi-text
488 (if (string-match regexp hi-text) 488 (buffer-substring-no-properties
489 (push regexp regexps)))))) 489 (if face-before
490 (or (previous-single-property-change (point) 'face)
491 (point-min))
492 (point))
493 (if face-after
494 (or (next-single-property-change (point) 'face)
495 (point-max))
496 (point)))))
497 ;; Compute hi-lock patterns that match the
498 ;; highlighted text at point. Use this later in
499 ;; during completing-read.
500 (dolist (hi-lock-pattern hi-lock-interactive-patterns)
501 (let ((regexp (car hi-lock-pattern)))
502 (if (string-match regexp hi-text)
503 (push regexp regexps)))))))
490 regexps)) 504 regexps))
491 505
492(defvar-local hi-lock--unused-faces nil 506(defvar-local hi-lock--unused-faces nil