emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r111178: * lisp/hi-lock.el (hi-lock--


From: Stefan Monnier
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r111178: * lisp/hi-lock.el (hi-lock--regexps-at-point): Fix boundary case for
Date: Mon, 10 Dec 2012 16:26:13 -0500
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 111178
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Mon 2012-12-10 16:26:13 -0500
message:
  * lisp/hi-lock.el (hi-lock--regexps-at-point): Fix boundary case for
  font-lock as well as when there's no text-property.
modified:
  lisp/ChangeLog
  lisp/hi-lock.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-12-10 18:33:59 +0000
+++ b/lisp/ChangeLog    2012-12-10 21:26:13 +0000
@@ -1,3 +1,8 @@
+2012-12-10  Stefan Monnier  <address@hidden>
+
+       * hi-lock.el (hi-lock--regexps-at-point): Fix boundary case for
+       font-lock as well as when there's no text-property.
+
 2012-12-10  Jambunathan K  <address@hidden>
 
        * hi-lock.el: Refine the choice of default face.

=== modified file 'lisp/hi-lock.el'
--- a/lisp/hi-lock.el   2012-12-10 18:33:59 +0000
+++ b/lisp/hi-lock.el   2012-12-10 21:26:13 +0000
@@ -474,19 +474,33 @@
     (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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]