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: Drew Adams
Subject: bug#12867: 24.3.50; easy-to-repro crash involving mode line
Date: Mon, 12 Nov 2012 10:16:55 -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?

The latter.

> If the latter, then what is so special about changing the
> current line that you want mode line redisplayed only at that time?

See the code I pointed you to (but I explain below).

I show users info that pertains to the line they are on.  IOW, that info changes
as the line changes.  It is not the line number itself that they want to see in
this context.  It is info about what is in the current line compared to info in
other lines.

The info relates to numbers of particular kinds of marks used in a bookmarks
listing, and in particular the number of the current-line's mark of each kind
relative to the total number of that kind.

The doc string of the function I pointed you to says:

 Show, in mode line, information about the current bookmark-list display.
 The information includes the sort order and the number of marked,
 flagged (for deletion), tagged, temporary, annotated, and modified
 bookmarks currently shown.

 For each number indication:
  If the current line has the indicator (e.g. mark, flag) and there are
  others with the same indicator listed after it, then show `N/M',
  where N is the number indicated through the current line and M is the
  total number indicated.

> > 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 see - good to know.  I don't expect it will be a problem here, but I'll keep
an eye out.  Any idea what size buffers lead to such behavior?  I don't expect
users to have gigantic bookmark-list displays, but you never know, and it's a
good idea to know what the (approximate) threshold is.

> > 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.

Do you mean at the level of my code, or are you thinking about an enhancement
for Emacs?  The rest of your text leads me to think the latter.  If not, I'm not
sure what kind of option you have in mind here.

> But we should first formulate the conditions under which this
> redisplay will be performed.

If we're talking about my use case then it is each time the current line
changes.

> 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?

I don't follow you.  Probably that's because I don't know what the option that
you envision is for.

Perhaps (dunno whether this is related to what you're thinking or off the map)
we could have a user function get called on every redisplay cycle.  It would (a)
determine whether to redisplay the mode line and (b) perhaps also say how.
Dunno.

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

OK.  Do you want to formulate the bug subject?  You have a better idea than I
what you are envisioning as a possible solution.  Or I can file a bug
(enhancement request) with subject "trigger mode-line redisplay on line change"
or some such.

> 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.

I tried that.

> > 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.

OK.






reply via email to

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