From: Akira Kyle <ak@akirakyle.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org
Subject: Re: non-local exits in redisplay
Date: Mon, 12 Oct 2020 13:19:25 -0600 [thread overview]
Message-ID: <868scbuu9u.fsf@akirakyle.com> (raw)
In-Reply-To: <83h7qz2xa4.fsf@gnu.org>
On Mon, Oct 12, 2020 at 11:01 AM, Eli Zaretskii <eliz@gnu.org>
wrote:
> As Stefan mentions, you are well advised not to signal errors
> inside
> redisplay. The reason is simple: signaling an error always
> reenters
> redisplay immediately, because we need to display the error
> message.
> While that is a special kind of redisplay, it usually redraws at
> least
> one window, and can redraw more, depending on what exactly is on
> display. It is virtually impossible to predict when displaying
> the
> error signal message will hit the same error again; even if you
> seem
> to be able to get away with that in some situation, another user
> of
> your code might not be so lucky, if they use some specialized
> feature,
> like post-command-hooks that affect the display (it could be as
> simple
> as hl-line-mode or similar), or functions that run off timers
> that
> display something, or any number of other optional features, of
> which
> Emacs has a gazillion.
Yes as I'm learning more about the interplay between the lisp
interpreter and the complicated machinery of redisplay, I'm
realizing there are many ways to shoot yoursef in the foot.
> So you really shouldn't signal errors from redisplay. the most
> you
> can do is silently deposit an error message in the *Messages*
> buffer
> (that's what the safe_call and friends do, btw) and hope that
> the user
> will look there at some point, e.g. because the display doesn't
> look
> "right".
Which isn't very satisfactory from a UI perspective. I suppose
setting some flag in redisplay which could then be checked later
in lisp to signal the error would be the obvious work around.
> Can you explain why you'd need to signal an error from the
> display
> code? Maybe we can find some way of dealing with your problem
> that is
> better than just inserting a message in *Messages*.
>
> And one more thing: please don't over-use the safe_call facility
> as
> well, i.e. try not to call too much Lisp from the display
> engine. As
> convenient as that may sound, calling Lisp from display has its
> downsides. For starters, it produces more garbage, which
> triggers
> more frequent GCs, which slows down Emacs.
>
> So if you are tempted to call Lisp, try first to find an
> equivalent
> way of doing that in C (don't hesitate to ask questions if you
> cannot
> find it or are unsure how to do that), and only use Lisp if the
> alternative is not reasonable.
Perhaps I'm really getting ahead of myself here...
I'll describe what my goal is for the xwidgets code, which is what
ultimately prompted this question, in a new thread in case others
might be interested in commenting on it.
Thanks!
Akira
prev parent reply other threads:[~2020-10-12 19:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-11 21:28 non-local exits in redisplay Akira Kyle
2020-10-11 22:31 ` Stefan Monnier
2020-10-12 0:27 ` Akira Kyle
2020-10-12 3:44 ` Stefan Monnier
2020-10-12 17:01 ` Eli Zaretskii
2020-10-12 19:19 ` Akira Kyle [this message]
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=868scbuu9u.fsf@akirakyle.com \
--to=ak@akirakyle.com \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
/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).