From: "Roland Winkler" <winkler@gnu.org>
To: Stefan Monnier <monnier@IRO.UMontreal.CA>
Cc: 11983@debbugs.gnu.org
Subject: bug#11983: 24.1; Electric-command-loop broken?
Date: Thu, 19 Jul 2012 16:29:53 -0500 [thread overview]
Message-ID: <20488.31825.986146.195944@gargle.gargle.HOWL> (raw)
In-Reply-To: <jwv7gu0upar.fsf-monnier+emacs@gnu.org>
On Thu Jul 19 2012 Stefan Monnier wrote:
> The best I could understand of what it's trying to do is summarized in
> the commentary I added:
>
> ;; - electric modes and buffers: modes that typically pop-up in a
> ;; modal kind of way a transient buffer that automatically
> ;; disappears as soon as the user is done with it.
>
> > (this is used by BBDB 3):
>
> Could you maybe then describe the expected behavior, from the user's
> point of view? Adding docstrings, and/or improving comments would be
> very welcome.
My understanding of this is the following (better suggestions
welcome):
Imagine you have an unwind-protect form. It allows you to execute
whatever noninteractive code, and you can be sure that in the end
it executes cleanup-form. Now imagine you want to do the same
thing interactively: you want to run some commands interactively,
and in the end you want to be sure you execute cleanup-form, no
matter what happens. The code for this is
(unwind-protect
(catch 'return-tag
(Electric-command-loop 'return-tag))
(cleanup-form))
Electric-command-loop throws 'return-tag if you type
C-g (keyboard-quit). Or you can make commands electric by letting
them throw 'return-tag. But any other command is executed inside
the temporary command loop implemented by Electric-command-loop
without ever leaving this loop. In particular, this temporary
command loop catches all errors that do not throw 'return-tag.
So in short: Electric-command-loop allows one to execute commands
in an `unwind-protect'ed temporary command loop.
Maybe there is a simpler way to implement such a functionality.
A typical application is suggested by the function
Electric-pop-up-window which pops up a window fairly aggresively
(see bug#11985): You quickly execute some command in the electric
window. When you are done, this code guarantees that cleanup-form
gets executed.
> > - The doc string says
> > ;; Given third argument non-nil, it
> > ;; INHIBITS quitting unless the user types C-g at toplevel. This is
> > ;; so user can do things like C-u C-g and not get thrown out.
> > Yet it appears to me, that even for C-u C-g the user gets thrown out.
>
> I have no idea what this "C-u C-g" refers to, indeed.
If you type a plain C-g, Electric-command-loop throws
'return-tag. Now the idea is that if you type C-u, then you
change your mind and want to cancel it by typing C-g, then the
code should not leave the temporary command loop.
next prev parent reply other threads:[~2012-07-19 21:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-18 20:54 bug#11983: 24.1; Electric-command-loop broken? Roland Winkler
2012-07-19 8:40 ` Stefan Monnier
2012-07-19 21:29 ` Roland Winkler [this message]
2012-07-20 9:47 ` Stefan Monnier
2012-07-20 10:43 ` Roland Winkler
2012-07-20 12:09 ` Stefan Monnier
2012-07-20 12:38 ` Roland Winkler
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=20488.31825.986146.195944@gargle.gargle.HOWL \
--to=winkler@gnu.org \
--cc=11983@debbugs.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 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.