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 19:52:34 +0200

> From: "Drew Adams" <drew.adams@oracle.com>
> Cc: <12867@debbugs.gnu.org>
> Date: Mon, 12 Nov 2012 09:09:43 -0800
> 
> That is, %l triggers redisplay when the current line changes.  It is that
> triggering that I miss otherwise; it is not evaluating to produce the right
> display (e.g. using :eval), once redisplay is triggered.

So you want to be able to trigger redisplay of the mode line at will,
without being forced to have a line number display on the mode line,
is that it?

Or do you only want to trigger redisplay of mode line when the current
line changes?  If the latter, then what is so special about changing
the current line that you want mode line redisplayed only at that
time?

> Yes, I could instead use, say, `post-command-hook' and 
> `force-mode-line-update'
> if the line changes.  But %l triggers mode-line redisplay on line changes, and
> it seems to me better to let it do the triggering than to call `count-lines' 
> in
> a Lisp function on `post-command-hook'.

Yes, post-command-hook is ugly and expensive.  But you should know
that %l is not ideal either: e.g., if display of the line numbers is
disabled because the file is too large or the lines are too long, and
Emacs displays "???" instead of the number, I think mode line is not
redisplayed when the current line changes.  Again, because Emacs tries
very hard to avoid this costly redisplay.

> I will be glad to find a way to simplify the code and remove this ugly little
> hack.  Suggestions welcome.

A user option sounds like the right approach.  But we should first
formulate the conditions under which this redisplay will be
performed.  Doing that only when the line number changes sounds too
ad-hoc to me.  Can we come up with something more general?  E.g.,
would redisplaying the mode line on _every_ redisplay cycle (under the
new option) be acceptable?

Anyway, it looks like this discussion should continue in another bug
report, as the crash is solved.

> (defun foo ()
>   (set (make-local-variable 'mode-line-position)
>        '(:propertize "%l (line)" invisible t))
>   (set (make-local-variable 'mode-line-format)
>        '(("" mode-name mode-line-position))))
> 
> I thought that something I tried earlier using text property `invisible' made
> all of the text invisible, including the line #, but also broke the dynamic
> update wrt current line.  Perhaps I was mistaken about that - perhaps the 
> code I
> was testing just led to an error that somehow prevented the %l formatted text
> from being used at all.  Dunno.
> 
> (The symptom was that the line number did not appear in the mode line, and the
> mode line was not updated wrt current-line changes.  And I did not get the
> *invalid* mode-line-format display that typically indicates a mode-line
> display/formatting error.)
> 
> But at any rate, trying the code above you can see that it does not make the
> line number itself disappear.  Shouldn't it?  Or perhaps I am missing 
> something
> and there is a simple way to make that text invisible?

Did you try the syntax used in bindings.el?  It's ",(propertize ...", 
perhaps that's what you should do as well to make the text invisible.

> What is not so obvious is that you can automatically update anything at all in
> the mode line when the cursor changes line, as long as you include %l 
> somewhere
> in the `mode-line-format'.  IOW, %l triggers mode-line redisplay when you 
> change
> lines, and your mode-line code can take advantage of that.  (But you must show
> the line number as well.)

Yes, and there are other complications (see above about "???"), all of
them artifacts of the implementation details.  I don't think this
should be documented, because it can change without notice.





reply via email to

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