all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jambunathan K <kjambunathan@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 11095@debbugs.gnu.org
Subject: bug#11095: [PATCH] Re: bug#11095: 24.0.94; hi-lock-face-buffer/unhighlight-regexp': Augment?
Date: Sat, 08 Dec 2012 18:20:03 +0530	[thread overview]
Message-ID: <87pq2k6744.fsf@gmail.com> (raw)
In-Reply-To: <jwv7gothkoi.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Fri, 07 Dec 2012 11:55:54 -0500")

[-- Attachment #1: Type: text/plain, Size: 49 bytes --]


Attaching a patch.  See ChangeLog for details.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: bug11095-rev111152-1.diff --]
[-- Type: text/x-diff, Size: 3131 bytes --]

=== modified file 'lisp/ChangeLog'
--- lisp/ChangeLog	2012-12-07 16:48:42 +0000
+++ lisp/ChangeLog	2012-12-08 12:43:29 +0000
@@ -1,3 +1,11 @@
+2012-12-08  Jambunathan K  <kjambunathan@gmail.com>
+
+	* hi-lock.el (hi-lock--regexps-at-point): Use a better heuristic
+	that depends on actual faces rather than their common prefix.
+	(hi-lock-unface-buffer): Fix unhighlight all, when using overlays.
+	(hi-lock-set-pattern): Refuse to highlight an already highlighted
+	regexp.
+
 2012-12-07  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	* hi-lock.el (hi-lock-unface-buffer): If there's no matching regexp at

=== modified file 'lisp/hi-lock.el'
--- lisp/hi-lock.el	2012-12-07 16:48:42 +0000
+++ lisp/hi-lock.el	2012-12-08 10:38:25 +0000
@@ -471,19 +471,19 @@
     (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 an highlighted text.
-    ;; Checking for hi-lock face is a good heuristic.  FIXME: use "hi-lock-".
-    (and (string-match "\\`hi-" (face-name (face-at-point)))
-         (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))))))
+    (and (member (list 'quote (face-at-point))
+		 (mapcar #'cadadr 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))))))
     regexps))
 
 (defvar-local hi-lock--last-face nil)
@@ -541,6 +541,7 @@
   (dolist (keyword (if (eq regexp t) hi-lock-interactive-patterns
                      (list (assoc regexp hi-lock-interactive-patterns))))
     (when keyword
+      (setq regexp (car keyword))
       (let ((face (cadr (cadr (cadr keyword)))))
         ;; Make `face' the next one to use by default.
         (setq hi-lock--last-face
@@ -628,7 +629,8 @@
   ;; Hashcons the regexp, so it can be passed to remove-overlays later.
   (setq regexp (hi-lock--hashcons regexp))
   (let ((pattern (list regexp (list 0 (list 'quote face) t))))
-    (unless (member pattern hi-lock-interactive-patterns)
+    ;; Refuse to highlight a text that is already highlighted.
+    (unless (assoc regexp hi-lock-interactive-patterns)
       (push pattern hi-lock-interactive-patterns)
       (if font-lock-mode
 	  (progn


  reply	other threads:[~2012-12-08 12:50 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-26  6:46 bug#11095: 24.0.94; hi-lock-face-buffer/unhighlight-regexp': Augment? Jambunathan K
2012-10-10 20:21 ` bug#11095: [PATCH] " Jambunathan K
2012-12-04 21:14   ` Stefan Monnier
2012-12-04 21:39     ` Drew Adams
2012-12-04 21:57       ` Stefan Monnier
2012-12-04 22:43         ` Drew Adams
2012-12-05  3:46           ` Stefan Monnier
2012-12-05 22:15             ` Jambunathan K
2012-12-06  1:14               ` Stefan Monnier
2012-12-06  5:06     ` Jambunathan K
2012-12-06 14:50       ` Jambunathan K
2012-12-06 19:16       ` Stefan Monnier
2012-12-06 19:36         ` Drew Adams
2012-12-06 21:26         ` Jambunathan K
2012-12-06 21:36           ` Stefan Monnier
2012-12-06 22:23             ` Jambunathan K
2012-12-07  4:07               ` Stefan Monnier
2012-12-07  4:46                 ` Jambunathan K
2012-12-07 16:55                   ` Stefan Monnier
2012-12-08 12:50                     ` Jambunathan K [this message]
2012-12-10  4:26                       ` Jambunathan K
2012-12-10 18:34                         ` Stefan Monnier
2012-12-10 20:37                           ` Jambunathan K
2012-12-10 21:27                             ` Stefan Monnier
2012-10-10 22:08 ` Jambunathan K
2012-10-11 20:24 ` Jambunathan K
2012-10-11 20:33   ` Jambunathan K
2012-10-11 22:41   ` Juri Linkov
2012-10-12  4:30     ` Jambunathan K
2012-10-13 16:10       ` Juri Linkov
2012-10-13 17:28         ` Jambunathan K
2012-10-12 16:17 ` Jambunathan K
2012-10-12 18:18 ` Jambunathan K
2012-10-12 19:32 ` bug#11095: [FINAL] " Jambunathan K

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87pq2k6744.fsf@gmail.com \
    --to=kjambunathan@gmail.com \
    --cc=11095@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.