bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#12867: 24.3.50; easy-to-repro crash involving mode line


From: Eli Zaretskii
Subject: bug#12867: 24.3.50; easy-to-repro crash involving mode line
Date: Mon, 12 Nov 2012 17:40:35 +0200

> From: "Drew Adams" <drew.adams@oracle.com>
> Date: Sun, 11 Nov 2012 19:52:09 -0800
> 
> emacs -Q
>  
> (defun foo ()
>   (set (make-local-variable 'mode-line-position)
>        '("%99l (line)"))
>   (set (make-local-variable 'mode-line-format)
>        '(("" mode-name mode-line-position))))
>  
> M-: (foo)
>  
> No problem.  The line number is shown at the far right, padded on the
> left (see bug #12866).  You might need to widen the window/frame to see
> it.  But no problem.
>  
> Now change 99 to 999 and repeat M-: (foo).  Still no problem.  Now, no
> matter how big you make the window or how small you make the font, the
> line number has probably moved off the screen at the right, so you no
> longer see it.  Good (what I wanted).
>  
> Now change the value to 9999.  Crash.

Fixed in revision 110850 on the emacs-24 branch.  (The value 999 was
already too large, btw, it just didn't cause an immediate crash by
sheer luck.  The maximum width is 4 times the width of the frame, and
with the above revision, you are limited to that maximum.)

> I want to use the fact that a %l construct in the mode line enables you
> to do something dynamic when the cursor moves to another line.

May I inquire why you don't use the (:eval FORM) construct?  IIUC,
this does exactly what you want and is supported since Emacs 21.1.

> 1. The %l construct must be present in the `mode-line-format'.
> 2. Its resulting line-number text must not have property `invisible'.

The need to redisplay the mode line on every move of point is a killer
of many redisplay optimizations.  It is also potentially expensive by
itself, because it requires Emacs to count lines, something that is
not an easy operation in Emacs, which sees the buffer text as a linear
array of characters, not a series of lines.  So the display engine
tries very hard to avoid redisplaying the mode line if it decides that
the line number does not need to appear.

This is probably the explanation for what you see.  Still, it is not
entirely clear to me what "must" means in this context, so please show
the mode-line spec you tried and tell what didn't work when 1 or 2
above was not true.  Maybe there's something else involved.

> Besides fixing the crash, it would be great if I did not have to resort
> to such an ugly hack in the first place.
>  
> Presumably, this feature of dynamic line-sensitive updating is buried in
> the bowels of Emacs C code, so not available to Lisp users to tweak.
> Must this feature really be tied to an actual display of the line
> number?  If so, can't we at least make that text invisible?

If :eval doesn't fit the bill, please tell why.  If there's need to
make changes in the display engine to support the feature you want to
implement, I'd prefer to invest the energy in providing a clean
solution, rather than making mode-line-position serve as a back door
for such ugly hacks.

> Regardless, it would also be good if this feature (line-sensitive
> updating) were documented.  I could find nothing that even hinted at it.

Sorry, I don't understand: what is undocumented?  If you are talking
about refreshing mode-line-position, then shouldn't it be obvious that
it's refreshed on every move of point?





reply via email to

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