unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Tassilo Horn <tassilo@member.fsf.org>
To: emacs-devel@gnu.org
Subject: Conflicting overlays and the 'priority property
Date: Sun, 17 Jan 2010 19:04:49 +0100	[thread overview]
Message-ID: <87hbqk620u.fsf@thinkpad.tsdh.de> (raw)

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	other threads:[~2010-01-17 18:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-17 18:04 Tassilo Horn [this message]
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

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87hbqk620u.fsf@thinkpad.tsdh.de \
    --to=tassilo@member.fsf.org \
    --cc=emacs-devel@gnu.org \
    /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 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).