From: Lennart Borgman <lennart.borgman@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Chong Yidong <cyd@stupidchicken.com>,
Eli Zaretskii <eliz@gnu.org>,
Tassilo Horn <tassilo@member.fsf.org>,
emacs-devel@gnu.org
Subject: Re: Hl-line and visual-line
Date: Sat, 22 May 2010 19:04:09 +0200 [thread overview]
Message-ID: <AANLkTikx_ynbMytD3-dHf2Giswh9gZVZ30AS8PfNdl5c@mail.gmail.com> (raw)
In-Reply-To: <AANLkTimxCqmZk8-FIg_6-2petlOPyWvEhUaZZcxKYaXX@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1055 bytes --]
On Sat, May 22, 2010 at 4:35 AM, Lennart Borgman
<lennart.borgman@gmail.com> wrote:
> On Sat, May 22, 2010 at 2:18 AM, Stefan Monnier
> <monnier@iro.umontreal.ca> wrote:
>>> Didn't I send something for that long ago? I am not sure anymore.
>>
>> No idea.
>>
>>> I am not even sure I understand the code. Is it just a simple change
>>> in face_at_buffer_position in xfaces.c that is needed?
>>
>> No. This is a change to overlays and hence affects all properties, not
>> just `face'. Maybe it'll also require changes in xfaces.c as well, but the
>> core change should be somewhat around the code that implements
>> functionality like get-char-property.
>
> Thanks, forgot. I looked up all places calling sort_overlays and
> changed the relevant ones (I skipped mouse overlays).
I have attached the patch. Could someone please check and install it
to the trunk (unless there are no objections).
PS: If someone could tell me how I could do this from my checkout from
Launchpad I would be glad to do it myself the next time.
[-- Attachment #2: overlay-neg-priority-1.diff --]
[-- Type: text/x-patch, Size: 7415 bytes --]
=== modified file 'src/textprop.c'
--- trunk/src/textprop.c 2010-01-19 13:16:01 +0000
+++ patched/src/textprop.c 2010-05-22 01:39:11 +0000
@@ -629,6 +629,11 @@
Lisp_Object *overlay;
{
struct window *w = 0;
+ Lisp_Object tem = Qnil;
+ Lisp_Object tem_text = Qnil;
+ int priority;
+ int noverlays;
+ Lisp_Object *overlay_vec;
CHECK_NUMBER_COERCE_MARKER (position);
@@ -642,8 +647,6 @@
}
if (BUFFERP (object))
{
- int noverlays;
- Lisp_Object *overlay_vec;
struct buffer *obuf = current_buffer;
if (XINT (position) < BUF_BEGV (XBUFFER (object))
@@ -658,26 +661,37 @@
set_buffer_temp (obuf);
/* Now check the overlays in order of decreasing priority. */
- while (--noverlays >= 0)
+ while ( NILP (tem) && (--noverlays >= 0) )
{
- Lisp_Object tem = Foverlay_get (overlay_vec[noverlays], prop);
+ tem = Foverlay_get (overlay_vec[noverlays], prop);
if (!NILP (tem))
{
- if (overlay)
- /* Return the overlay we got the property from. */
- *overlay = overlay_vec[noverlays];
- return tem;
+ Lisp_Object tem_pri = Foverlay_get (overlay_vec[noverlays], Qpriority);
+ priority = (INTEGERP (tem_pri)) ? XINT (tem_pri) : 0;
}
}
}
- if (overlay)
- /* Indicate that the return value is not from an overlay. */
- *overlay = Qnil;
+ /* Check what to return. */
+ tem_text = Fget_text_property (position, prop, object);
+ if ( (!NILP (tem)) && ( (priority >= 0)
+ || NILP (tem_text) ))
+ {
+ if (overlay)
+ /* Return the overlay we got the property from. */
+ *overlay = overlay_vec[noverlays];
+ return tem;
+ }
+ else
+ {
+ if (overlay)
+ /* Indicate that the return value is not from an overlay. */
+ *overlay = Qnil;
- /* Not a buffer, or no appropriate overlay, so fall through to the
- simpler case. */
- return Fget_text_property (position, prop, object);
+ /* Not a buffer, or no appropriate overlay, so fall through to the
+ simpler case. */
+ return tem_text;
+ }
}
DEFUN ("get-char-property", Fget_char_property, Sget_char_property, 2, 3, 0,
=== modified file 'src/editfns.c'
--- trunk/src/editfns.c 2010-03-24 18:02:56 +0000
+++ patched/src/editfns.c 2010-05-22 01:48:44 +0000
@@ -444,7 +444,9 @@
{
int posn = XINT (position);
int noverlays;
- Lisp_Object *overlay_vec, tem;
+ Lisp_Object *overlay_vec;
+ Lisp_Object tem = Qnil;
+ Lisp_Object tem_pri;
struct buffer *obuf = current_buffer;
set_buffer_temp (XBUFFER (object));
@@ -466,7 +468,7 @@
set_buffer_temp (obuf);
/* Now check the overlays in order of decreasing priority. */
- while (--noverlays >= 0)
+ while ( NILP (tem) && (--noverlays >= 0) )
{
Lisp_Object ol = overlay_vec[noverlays];
tem = Foverlay_get (ol, prop);
@@ -478,24 +480,28 @@
&& XMARKER (start)->insertion_type == 1)
|| (OVERLAY_POSITION (finish) == posn
&& XMARKER (finish)->insertion_type == 0))
- ; /* The overlay will not cover a char inserted at point. */
+ tem = Qnil; /* The overlay will not cover a char inserted at point. */
else
{
- return tem;
+ tem_pri = Foverlay_get (ol, Qpriority);
+ if (tem_pri >= 0) return tem;
}
}
}
{ /* Now check the text properties. */
int stickiness = text_property_stickiness (prop, position, object);
+ Lisp_Object tem_text = Qnil;
if (stickiness > 0)
- return Fget_text_property (position, prop, object);
+ tem_text = Fget_text_property (position, prop, object);
else if (stickiness < 0
&& XINT (position) > BUF_BEGV (XBUFFER (object)))
- return Fget_text_property (make_number (XINT (position) - 1),
+ tem_text = Fget_text_property (make_number (XINT (position) - 1),
prop, object);
+ if (tem_text && (tem_pri < 0))
+ return tem_text;
else
- return Qnil;
+ return tem;
}
}
}
=== modified file 'src/xfaces.c'
--- trunk/src/xfaces.c 2010-01-13 08:35:10 +0000
+++ patched/src/xfaces.c 2010-05-22 02:42:08 +0000
@@ -6278,7 +6278,7 @@
{
struct frame *f = XFRAME (w->frame);
Lisp_Object attrs[LFACE_VECTOR_SIZE];
- Lisp_Object prop, position;
+ Lisp_Object text_prop, prop, position;
int i, noverlays;
Lisp_Object *overlay_vec;
Lisp_Object frame;
@@ -6286,6 +6286,7 @@
Lisp_Object propname = mouse ? Qmouse_face : Qface;
Lisp_Object limit1, end;
struct face *default_face;
+ int text_merged = 0;
/* W must display the current buffer. We could write this function
to use the frame and buffer of W, but right now it doesn't. */
@@ -6300,7 +6301,7 @@
/* Get the `face' or `mouse_face' text property at POS, and
determine the next position at which the property changes. */
- prop = Fget_text_property (position, propname, w->buffer);
+ text_prop = Fget_text_property (position, propname, w->buffer);
XSETFASTINT (limit1, (limit < endpos ? limit : endpos));
end = Fnext_single_property_change (position, propname, w->buffer, limit1);
if (INTEGERP (end))
@@ -6323,7 +6324,7 @@
/* Optimize common cases where we can use the default face. */
if (noverlays == 0
- && NILP (prop)
+ && NILP (text_prop)
&& !(pos >= region_beg && pos < region_end))
return default_face->id;
@@ -6331,16 +6332,26 @@
bcopy (default_face->lface, attrs, sizeof attrs);
/* Merge in attributes specified via text properties. */
- if (!NILP (prop))
- merge_face_ref (f, prop, attrs, 1, 0);
+ /* if (!NILP (prop)) */
+ /* merge_face_ref (f, prop, attrs, 1, 0); */
- /* Now merge the overlay data. */
+ /* Now merge the overlay data and the text properties. */
+ if (NILP (text_prop)) text_merged = 1;
noverlays = sort_overlays (overlay_vec, noverlays, w);
for (i = 0; i < noverlays; i++)
{
Lisp_Object oend;
int oendpos;
+ if (!text_merged)
+ {
+ int priority = Foverlay_get (overlay_vec[i], Qpriority);
+ if (priority >= 0)
+ {
+ merge_face_ref (f, text_prop, attrs, 1, 0);
+ text_merged = 1;
+ }
+ }
prop = Foverlay_get (overlay_vec[i], propname);
if (!NILP (prop))
merge_face_ref (f, prop, attrs, 1, 0);
@@ -6350,6 +6361,9 @@
if (oendpos < endpos)
endpos = oendpos;
}
+ /* If there were no overlays or all had negative prioriteis we have
+ not handled text properties yet. */
+ if (!text_merged) merge_face_ref (f, text_prop, attrs, 1, 0);
/* If in the region, merge in the region face. */
if (pos >= region_beg && pos < region_end)
=== modified file 'src/lisp.h'
--- trunk/src/lisp.h 2010-05-15 21:19:05 +0000
+++ patched/src/lisp.h 2010-05-22 13:50:56 +0000
@@ -2973,1 +2973,1 @@
extern void set_time_zone_rule P_ ((char *));
/* defined in buffer.c */
+extern Lisp_Object Qpriority;
extern int mouse_face_overlay_overlaps P_ ((Lisp_Object));
extern void nsberror P_ ((Lisp_Object)) NO_RETURN;
EXFUN (Fset_buffer_multibyte, 1);
next prev parent reply other threads:[~2010-05-22 17:04 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-20 20:30 Hl-line and visual-line David Reitter
2010-05-20 21:02 ` Eli Zaretskii
2010-05-21 2:35 ` David Reitter
2010-05-21 6:34 ` Tassilo Horn
2010-05-21 8:17 ` Eli Zaretskii
2010-05-21 10:16 ` Tassilo Horn
2010-05-21 14:22 ` David Reitter
2010-05-21 14:57 ` Eli Zaretskii
2010-05-23 17:26 ` Eli Zaretskii
2010-05-23 19:13 ` David Reitter
2010-05-23 20:33 ` Eli Zaretskii
2010-05-23 23:04 ` David Reitter
2010-05-24 18:16 ` Eli Zaretskii
2010-05-24 18:46 ` Stefan Monnier
2010-05-24 19:06 ` Lennart Borgman
2010-05-24 22:24 ` Eli Zaretskii
2010-05-24 22:37 ` Lennart Borgman
2010-05-24 22:47 ` David Reitter
2010-05-24 23:03 ` Lennart Borgman
2010-05-21 16:54 ` Lennart Borgman
2010-05-21 17:39 ` Eli Zaretskii
2010-05-21 20:24 ` Stefan Monnier
2010-05-21 22:31 ` Lennart Borgman
2010-05-22 0:18 ` Stefan Monnier
2010-05-22 2:35 ` Lennart Borgman
2010-05-22 13:10 ` Lennart Borgman
2010-05-22 17:04 ` Lennart Borgman [this message]
2010-05-21 6:36 ` Eli Zaretskii
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=AANLkTikx_ynbMytD3-dHf2Giswh9gZVZ30AS8PfNdl5c@mail.gmail.com \
--to=lennart.borgman@gmail.com \
--cc=cyd@stupidchicken.com \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
--cc=tassilo@member.fsf.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).