emacs-devel
[Top][All Lists]
Advanced

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

Conflicting overlays and the 'priority property


From: Tassilo Horn
Subject: Conflicting overlays and the 'priority property
Date: Sun, 17 Jan 2010 19:04:49 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.91 (gnu/linux)

Hi all,

I use Nicolaj Schumacher's highlight-symbol.el, which highlights the
symbol at point or some selected symbol by using hi-lock to add a
colorized background.  Now the problem is that this background change is
not visible on the current line, iff hl-line-mode is enabled.

Both use overlays, the former via hi-lock, the latter manually.  So
there is an overlay for the whole line, and in that line there's another
overlay for one symbol.  Both specify a face property with some
background color.  Ok, so there is a conflict.  It seems, that hl-line
always wins.

Reading the elisp manual, there is:

,----[ (info "(elisp)Overlay Properties") ]
| `priority'
|      This property's value (which should be a nonnegative integer
|      number) determines the priority of the overlay.  No priority, or
|      `nil', means zero.
| 
|      The priority matters when two or more overlays cover the same
|      character and both specify the same property; the one whose
|      `priority' value is larger overrides the other.  For the `face'
|      property, the higher priority overlay's value does not completely
|      override the other value; instead, its face attributes override
|      the face attributes of the lower priority `face' property.
`----

So I tried use that.  I changed hi-lock like this:

--8<---------------cut here---------------start------------->8---
diff -u -L /usr/share/emacs/23.1.91/lisp/hi-lock.el.gz -L 
/tmp/buffer-content-5991ty0 /tmp/jka-com5991f8D /tmp/buffer-content-5991ty0
--- /usr/share/emacs/23.1.91/lisp/hi-lock.el.gz
+++ /tmp/buffer-content-5991ty0
@@ -568,7 +568,7 @@
   "Inhibit the action of `hi-lock-font-lock-hook'.
 This is used by `hi-lock-set-pattern'.")
 
-(defun hi-lock-set-pattern (regexp face)
+(defun hi-lock-set-pattern (regexp face &optional priority)
   "Highlight REGEXP with face FACE."
   (let ((pattern (list regexp (list 0 (list 'quote face) t)))
        ;; The call to `font-lock-add-keywords' below might disable
@@ -596,7 +596,8 @@
               (let ((overlay (make-overlay (match-beginning 0) (match-end 0))))
                 (overlay-put overlay 'hi-lock-overlay t)
                 (overlay-put overlay 'hi-lock-overlay-regexp serial)
-                (overlay-put overlay 'face face))
+                (overlay-put overlay 'face face)
+                        (overlay-put overlay 'priority priority))
               (goto-char (match-end 0)))))))))
 
 (defun hi-lock-set-file-patterns (patterns)

Diff finished.  Sun Jan 17 18:55:02 2010
--8<---------------cut here---------------end--------------->8---

Then I changed highlight-symbol.el to call that function with a priority
value of 9999.

Unfortunately, that doesn't change anything.  Still hl-line-mode's
overlay takes precedence over the symbol overlay from highlight-symbol /
hi-lock.  But hl-line mode does not use the priority property, so I'm
pretty sure that the background face property applied by
highlight-symbol should take precedence over that of hl-line, at least
that would comply with the docs.

Am I doing something wrong, or is that a bug?  

Bye,
Tassilo




reply via email to

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