unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Conflicting overlays and the 'priority property
@ 2010-01-17 18:04 Tassilo Horn
  2010-01-18 21:33 ` hi-lock and overlays (was: Conflicting overlays and the 'priority property) Tassilo Horn
  0 siblings, 1 reply; 6+ messages in thread
From: Tassilo Horn @ 2010-01-17 18:04 UTC (permalink / raw)
  To: emacs-devel

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




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

end of thread, other threads:[~2010-01-20 17:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-17 18:04 Conflicting overlays and the 'priority property Tassilo Horn
2010-01-18 21:33 ` hi-lock and overlays (was: Conflicting overlays and the 'priority property) Tassilo Horn
2010-01-18 21:51   ` Lennart Borgman
2010-01-19  7:41     ` hi-lock and overlays Tassilo Horn
2010-01-20 15:54   ` Stefan Monnier
2010-01-20 17:19     ` Tassilo Horn

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).