unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#13297: hi-lock-unface-buffer fails on face lists
@ 2012-12-28 20:21 Jonas Bernoulli
  2013-01-12  3:24 ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Jonas Bernoulli @ 2012-12-28 20:21 UTC (permalink / raw)
  To: 13297

Before commit 111129 hi-lock-unface-buffer could handle face symbols as
well as face lists.  After this commit it fails on lists.

Third-party library highlight-symbol uses hi-lock-set-pattern passing it
a face list.  The above change breaks this usage which isn't disallowed
in hi-lock-set-pattern's doc-string.  As a result this library cannot
remove the highlights it added with the help of hi-lock.

  Jonas





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#13297: hi-lock-unface-buffer fails on face lists
  2012-12-28 20:21 bug#13297: hi-lock-unface-buffer fails on face lists Jonas Bernoulli
@ 2013-01-12  3:24 ` Stefan Monnier
  2013-01-17  7:50   ` Jambunathan K
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2013-01-12  3:24 UTC (permalink / raw)
  To: Jonas Bernoulli; +Cc: 13297

> Before commit 111129 hi-lock-unface-buffer could handle face symbols as
> well as face lists.  After this commit it fails on lists.
> Third-party library highlight-symbol uses hi-lock-set-pattern passing it
> a face list.  The above change breaks this usage which isn't disallowed
> in hi-lock-set-pattern's doc-string.  As a result this library cannot
> remove the highlights it added with the help of hi-lock.

I don't understand exactly what you're referring to.  In which way does
it break it?  Do you get an error?  Or is the regexp's highlight just
sticks around without signaling any error?
Can you show some specific recipe to reproduce the problem?


        Stefan





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#13297: hi-lock-unface-buffer fails on face lists
  2013-01-12  3:24 ` Stefan Monnier
@ 2013-01-17  7:50   ` Jambunathan K
  2013-01-28 20:03     ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Jambunathan K @ 2013-01-17  7:50 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Jonas Bernoulli, 13297

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> Before commit 111129 hi-lock-unface-buffer could handle face symbols as
>> well as face lists.  After this commit it fails on lists.
>> Third-party library highlight-symbol uses hi-lock-set-pattern passing it
>> a face list.  The above change breaks this usage which isn't disallowed
>> in hi-lock-set-pattern's doc-string.  As a result this library cannot
>> remove the highlights it added with the help of hi-lock.
>
> I don't understand exactly what you're referring to.  In which way does
> it break it?  Do you get an error?  Or is the regexp's highlight just
> sticks around without signaling any error?
> Can you show some specific recipe to reproduce the problem?

highlight-symbol is at 

        http://nschum.de/src/emacs/highlight-symbol/highlight-symbol.el

To higlight use 
        M-x highlight-symbol-at-point RET 

To un-highlight use
        M-x highlight-symbol-at-point RET

That library uses anonymous faces (as opposed to a pre-defined face) for
highlighting.

    ,---- hi-lock-interactive-patterns
    |
    | (("\\_<completing-read\\_>"
    |   (0
    |    '((background-color . "cyan")            <====== anonymous face
    |      . #1=((foreground-color . "black")))
    |    t))
    |  ("\\_<keyword\\_>"
    |   (0
    |    '((background-color . "DeepPink")
    |      . #1#)
    |    t)))
    |
    `----

The problem is due to the mistaken assumption about the nature of face,
as captured by the comment line below.

    ,----
    | (defun hi-lock-keyword->face (keyword)
    |   (cadr (cadr (cadr keyword))))    ; Keyword looks like (REGEXP (0 'FACE) ...).
    `----


A simple check in `hi-lock-unface-buffer' will make the problem
disappear.  However, I have a gut feeling that management of
`hi-lock--unused-faces' could be improved.

    ,----
    | (when keyword
    |   (let ((face (hi-lock-keyword->face keyword)))
    |     (when (member face hi-lock-face-defaults) <==  Use facep instead
    |       ;; Make `face' the next one to use by default.
    |  	  (add-to-list 'hi-lock--unused-faces (face-name face))))
    `----


--8<---------------cut here---------------start------------->8---

Debugger entered--Lisp error: (error "Not a face: ((background-color . DeepPink) (foreground-color . black))")
  signal(error ("Not a face: ((background-color . DeepPink) (foreground-color . black))"))
  error("Not a face: %s" ((background-color . "DeepPink") (foreground-color . "black")))
  check-face(((background-color . "DeepPink") (foreground-color . "black")))
  face-name(((background-color . "DeepPink") (foreground-color . "black")))
  (add-to-list (quote hi-lock--unused-faces) (face-name face))
  (let ((face (hi-lock-keyword->face keyword))) (add-to-list (quote hi-lock--unused-faces) (face-name face)))
  (progn (let ((face (hi-lock-keyword->face keyword))) (add-to-list (quote hi-lock--unused-faces) (face-name face))) (font-lock-remove-keywords nil (list keyword)) (setq hi-lock-interactive-patterns (delq keyword hi-lock-interactive-patterns)) (remove-overlays nil nil (quote hi-lock-overlay-regexp) (hi-lock--hashcons (car keyword))) (if font-lock-fontified (progn (font-lock-fontify-buffer))))
  (if keyword (progn (let ((face (hi-lock-keyword->face keyword))) (add-to-list (quote hi-lock--unused-faces) (face-name face))) (font-lock-remove-keywords nil (list keyword)) (setq hi-lock-interactive-patterns (delq keyword hi-lock-interactive-patterns)) (remove-overlays nil nil (quote hi-lock-overlay-regexp) (hi-lock--hashcons (car keyword))) (if font-lock-fontified (progn (font-lock-fontify-buffer)))))
  (let ((keyword (car --dolist-tail--))) (if keyword (progn (let ((face (hi-lock-keyword->face keyword))) (add-to-list (quote hi-lock--unused-faces) (face-name face))) (font-lock-remove-keywords nil (list keyword)) (setq hi-lock-interactive-patterns (delq keyword hi-lock-interactive-patterns)) (remove-overlays nil nil (quote hi-lock-overlay-regexp) (hi-lock--hashcons (car keyword))) (if font-lock-fontified (progn (font-lock-fontify-buffer))))) (setq --dolist-tail-- (cdr --dolist-tail--)))
  (while --dolist-tail-- (let ((keyword (car --dolist-tail--))) (if keyword (progn (let ((face (hi-lock-keyword->face keyword))) (add-to-list (quote hi-lock--unused-faces) (face-name face))) (font-lock-remove-keywords nil (list keyword)) (setq hi-lock-interactive-patterns (delq keyword hi-lock-interactive-patterns)) (remove-overlays nil nil (quote hi-lock-overlay-regexp) (hi-lock--hashcons (car keyword))) (if font-lock-fontified (progn (font-lock-fontify-buffer))))) (setq --dolist-tail-- (cdr --dolist-tail--))))
  (let ((--dolist-tail-- (if (eq regexp t) hi-lock-interactive-patterns (list (assoc regexp hi-lock-interactive-patterns))))) (while --dolist-tail-- (let ((keyword (car --dolist-tail--))) (if keyword (progn (let ((face ...)) (add-to-list (quote hi-lock--unused-faces) (face-name face))) (font-lock-remove-keywords nil (list keyword)) (setq hi-lock-interactive-patterns (delq keyword hi-lock-interactive-patterns)) (remove-overlays nil nil (quote hi-lock-overlay-regexp) (hi-lock--hashcons (car keyword))) (if font-lock-fontified (progn (font-lock-fontify-buffer))))) (setq --dolist-tail-- (cdr --dolist-tail--)))))
  (progn (let ((--dolist-tail-- (if (eq regexp t) hi-lock-interactive-patterns (list (assoc regexp hi-lock-interactive-patterns))))) (while --dolist-tail-- (let ((keyword (car --dolist-tail--))) (if keyword (progn (let (...) (add-to-list ... ...)) (font-lock-remove-keywords nil (list keyword)) (setq hi-lock-interactive-patterns (delq keyword hi-lock-interactive-patterns)) (remove-overlays nil nil (quote hi-lock-overlay-regexp) (hi-lock--hashcons ...)) (if font-lock-fontified (progn ...)))) (setq --dolist-tail-- (cdr --dolist-tail--))))))
  hi-lock-unface-buffer("\\_<keyword\\_>")
  (progn (setq highlight-symbol-list (delete symbol highlight-symbol-list)) (hi-lock-unface-buffer symbol))
  (if (member symbol highlight-symbol-list) (progn (setq highlight-symbol-list (delete symbol highlight-symbol-list)) (hi-lock-unface-buffer symbol)) (if (equal symbol highlight-symbol) (progn (highlight-symbol-mode-remove-temp))) (let ((color (nth highlight-symbol-color-index highlight-symbol-colors))) (if color (setq highlight-symbol-color-index (1+ highlight-symbol-color-index)) (setq highlight-symbol-color-index 1 color (car highlight-symbol-colors))) (setq color (cons (cons (quote background-color) color) (quote ((foreground-color . "black"))))) (with-no-warnings (if (< emacs-major-version 22) (hi-lock-set-pattern (list symbol (cons 0 (cons ... ...)))) (hi-lock-set-pattern symbol color))) (setq highlight-symbol-list (cons symbol highlight-symbol-list))))
  (let ((symbol (highlight-symbol-get-symbol))) (if symbol nil (error "No symbol at point")) (if hi-lock-mode nil (hi-lock-mode 1)) (if (member symbol highlight-symbol-list) (progn (setq highlight-symbol-list (delete symbol highlight-symbol-list)) (hi-lock-unface-buffer symbol)) (if (equal symbol highlight-symbol) (progn (highlight-symbol-mode-remove-temp))) (let ((color (nth highlight-symbol-color-index highlight-symbol-colors))) (if color (setq highlight-symbol-color-index (1+ highlight-symbol-color-index)) (setq highlight-symbol-color-index 1 color (car highlight-symbol-colors))) (setq color (cons (cons (quote background-color) color) (quote ((foreground-color . "black"))))) (with-no-warnings (if (< emacs-major-version 22) (hi-lock-set-pattern (list symbol (cons 0 ...))) (hi-lock-set-pa
 ttern symbol color))) (setq highlight-symbol-list (cons symbol highlight-symbol-list)))))
  highlight-symbol-at-point()
  call-interactively(highlight-symbol-at-point record nil)
  command-execute(highlight-symbol-at-point record)
  execute-extended-command(nil "highlight-symbol-at-point")
  call-interactively(execute-extended-command nil nil)

--8<---------------cut here---------------end--------------->8---

-- 





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#13297: hi-lock-unface-buffer fails on face lists
  2013-01-17  7:50   ` Jambunathan K
@ 2013-01-28 20:03     ` Stefan Monnier
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2013-01-28 20:03 UTC (permalink / raw)
  To: Jambunathan K; +Cc: Jonas Bernoulli, 13297-done

> The problem is due to the mistaken assumption about the nature of face,
> as captured by the comment line below.

Oh, indeed, thank you.  I installed the patch below which should fix it,


        Stefan


=== modified file 'lisp/hi-lock.el'
--- lisp/hi-lock.el	2013-01-02 16:13:04 +0000
+++ lisp/hi-lock.el	2013-01-28 19:59:39 +0000
@@ -562,7 +562,8 @@
     (when keyword
       (let ((face (hi-lock-keyword->face keyword)))
         ;; Make `face' the next one to use by default.
-	(add-to-list 'hi-lock--unused-faces (face-name face)))
+        (when (symbolp face)          ;Don't add it if it's a list (bug#13297).
+          (add-to-list 'hi-lock--unused-faces (face-name face))))
       (font-lock-remove-keywords nil (list keyword))
       (setq hi-lock-interactive-patterns
             (delq keyword hi-lock-interactive-patterns))






^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-01-28 20:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-28 20:21 bug#13297: hi-lock-unface-buffer fails on face lists Jonas Bernoulli
2013-01-12  3:24 ` Stefan Monnier
2013-01-17  7:50   ` Jambunathan K
2013-01-28 20:03     ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).