all messages for Emacs-related lists mirrored at yhetil.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 19:52:34 +0200	[thread overview]
Message-ID: <83ehjywvx9.fsf@gnu.org> (raw)
In-Reply-To: <B6D22ACCDB494018B5ABC060D771AB92@us.oracle.com>

> 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	other threads:[~2012-11-12 17:52 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
2012-11-12 17:09   ` Drew Adams
2012-11-12 17:52     ` Eli Zaretskii [this message]
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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83ehjywvx9.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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.