unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Drew Adams <drew.adams@oracle.com>
Cc: 12867@debbugs.gnu.org
Subject: bug#12867: 24.3.50; easy-to-repro crash involving mode line
Date: Mon, 12 Nov 2012 17:40:35 +0200	[thread overview]
Message-ID: <83obj2x218.fsf@gnu.org> (raw)
In-Reply-To: <77CAAFE4D0CE4DD98476C996E3158648@us.oracle.com>

> 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	other threads:[~2012-11-12 15:40 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-12  3:52 bug#12867: 24.3.50; easy-to-repro crash involving mode line Drew Adams
2012-11-12 15:40 ` Eli Zaretskii [this message]
2012-11-12 17:09   ` Drew Adams
2012-11-12 17:52     ` Eli Zaretskii
2012-11-12 18:16       ` Drew Adams
2012-11-12 18:35         ` Eli Zaretskii
2012-11-12 19:07           ` bug#12872: " Drew Adams
2012-11-12 17:31   ` martin rudalics
2012-11-12 18:19     ` Eli Zaretskii
2012-11-12 20:55       ` Stefan Monnier
2012-11-13  8:22         ` martin rudalics
2012-11-13 12:52           ` Eli Zaretskii
2012-11-13 13:50             ` martin rudalics

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=83obj2x218.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=12867@debbugs.gnu.org \
    --cc=drew.adams@oracle.com \
    /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).