emacs-devel
[Top][All Lists]
Advanced

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

Re: Insight into the mystery hangs


From: Kévin Le Gouguec
Subject: Re: Insight into the mystery hangs
Date: Wed, 14 Feb 2024 00:05:04 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Kévin Le Gouguec <kevin.legouguec@gmail.com>
>> Cc: "Eric S. Raymond" <esr@thyrsus.com>,  emacs-devel@gnu.org
>> Date: Tue, 13 Feb 2024 08:52:06 +0100
>> 
>> Eli Zaretskii <eliz@gnu.org> writes:
>> 
>> > Isn't that call issued from the mode-line display?  If so, that is
>> > done from redisplay, and redisplay cannot enter debugger, so it
>> > catches all errors.  If you want to produce Lisp backtraces from Lisp
>> > code called by redisplay, you need to use the facilities documented in
>> > the node "Debugging Redisplay" in the ELisp Reference manual.
>> 
>> Tangential, not so much about debugging errors during redisplay, than
>> merely noticing them: I do periodically forget that these errors are
>> caught, so every couple of months I find myself frowning at code
>> (font-locking, usually) that misbehaves yet fails to throw an error for
>> about five minutes, before remembering to check *Messages* for any
>> "Error during redisplay".
>
> Yes, something to keep in mind.
>
>> 1. "For Science", I just did…
>> 
>>     (setq mode-line-format '(:eval (error "argh")))
>> 
>>    … and I am surprised that this *Messages* diagnostic…
>> 
>>     > Error during redisplay: (eval (error "argh") t) signaled (error "argh")
>> 
>>    … never seems to make its way to the echo area?  It's a small thing
>>    (I'll probably have *Messages* open when debugging so I'll notice
>>    eventually) but it is somewhat surprising that these warnings can
>>    pile up in *Messages* yet the echo area remains blank.
>
> Question: what happens when a message is shown in the echo-area?
> Answer: Emacs triggers redisplay.

Ah, yes; it would, wouldn't it 🥲

> Question: what happens in redisplay which was triggered by error
> message shown in the echo-area because of error during redisplay?
> Answer: the same error during redisplay will happen again, as part of
> the new redisplay cycle.
> Question: what will this do to Emacs?
> Answer: a never-ending sequence of error, displaying an error message,
> which causes another error, which displays the same error message,
> which causes the same error, etc. etc., ad nauseam.
> Question: what will the user see?
> Answer: a never-ending sequence of rapidly blinking windows, and an
> Emacs session that is unusable.

>> 2. It's neat that…
>> 
>>     (setq mode-line-format '("foo " (:eval (error "argh")) " bar"))
>> 
>>    … will be "robust" enough to display "foo bar" in the mode-line;
>>    combined with the lack of echo-area reporting it does make it hard to
>>    ever know something went wrong though.
>
> Where ignoring the problematic result can help us recover (at a price
> of botching the trouble-making Lisp), we do that.
>
>>    Might it make sense to (have an option to) substitute a signaling
>>    :eval form with some "[redisplay error]" placeholder?
>
> You mean, display the error on the mode line or something?  We
> actually do that in some simple cases, but the problem is that the
> mode line has too little real-estate to show enough information
> without catastrophically wiping everything else.  But if you want to
> work on a feature whereby a redisplay error adds some button on the
> mode line which, if pressed, will show the *Messages* buffer with the
> details, feel free.

Right, I think this is where my mind was going with this (taking
observations 1 and 2 into account).

>                      Just be aware of the following gotcha: changing
> how the mode line looks will also trigger a kind of redisplay.

Thanks for taking the time to spell all of this out.  I guess at the
moment I can't think of anything smarter than e.g.

* a boolean set by redisplay when it catches an error,

* a mode-line construct that shows a button when the boolean is set,

* the button offering a mouse binding to clear the boolean, and another
  to visit *Messages*.

Of course (a) the construct might be "late" by one redisplay cycle, if
it is processed before the error is raised in the same cycle (b)
redisplay might reset the boolean immediately after the user clears it,
if the cause of the original error persists (c) the boolean would remain
set indefinitely after the cause has been fixed, until the user manually
clears it.

FWIW I wouldn't see this as much worse than the current situation, but
then again, as my tangent's introduction implies, I don't experience
redisplay errors that often (… or at least I don't notice them 😉).

Again, thanks for your reply; appreciate the food for thought.



reply via email to

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