emacs-devel
[Top][All Lists]
Advanced

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

Re: linum.el: problem (bug ?) fix and improvement


From: Stefan Monnier
Subject: Re: linum.el: problem (bug ?) fix and improvement
Date: Thu, 12 May 2011 10:58:58 -0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

> It is displaying a wrong line number when there is an invisible line.
> (I don't know the problem is a bug clearly, but it is trouble to me.)

>     Example:
>     ====================================================================
>       In buffer (linum-mode is enabled).

>         1 abc
>         2 def
>         3 ghi
>         4 jkl

>       Make the 2nd line ("def\n") invisible (by `facemenu-set-invisible').

>         1 abc
>         2 ghi                   <= wrong
>         4 jkl
>     ====================================================================

Actually, it's even more interesting:

the line number displayed in front of `ghi' is sometimes 2 and sometimes
3, changing "at random" while editing that line or when mouse-1 clicking
in that window.

IIUC the problem is that Emacs "displays" both margin properties: the
one from the `def' line and the one from the `ghi' line, and since
in reality both can't be displayed it ends up choosing one of the two
and depending on how the redisplay happens it picks one or the other.

What we'd like here is for the redisplay to ignore the margin property
placed on invisible text.  This boils down to making Emacs ignore
`before-string' properties placed at the beginning of invisible text.
I don't think it's always right to ignore them, tho.  Maybe a good way
to make it work is to rely on the stickiness of the `before-string'
property: by making it rear-sticky (i.e. making the overlay's
front-advance non-nil) we'd be stating explicitly that the property
belongs to the hidden text and should hence be hidden as well.

> I fixed the problem.

Alternatively we can let linum do the hard work, like your patch
does, of course.

> Additionally, I improved about invisible buffer string.

>     the attached file: "linum-mode.el.2.diff"
>                        (including the above bug fix.)

>   (1) Indicating invisible line(s) by an underlined line number
>       when the following line(s) is/are invisible.

>     ====================================================================
>         _1_ abc                 <= underline
>          3  ghi
>          4  jkl
>     ====================================================================

>   (2) Indicating partial invisible string by a `strike-through' line
>       number when the line has partial invisible string.

>     ====================================================================
>         _1_ abc
>          3  ghi
>          4  jkl

>       Make the 3rd line ("hi") invisible partially.

>         _1_ abc
>         -3- g                   <= strike-through
>          4  jkl

>       Make the 1st line ("ab") invisible partially.

>         -_1_- c                 <= underline and strike-through
>          -3-  g
>           4   jkl
>     ====================================================================

Could you describe the context in which you've needed such a thing?
The strike-through info seems to be redundant with the fact that the
next line number is not the immediate successor, and I wonder when you'd
be so interested in knowing if there's some hidden text on
a particular line.


        Stefan



reply via email to

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