From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Robert Weiner Newsgroups: gmane.emacs.devel Subject: Re: Problem quitting properly from transient keymap with one keystroke Date: Fri, 20 Oct 2017 12:04:51 -0400 Message-ID: References: Reply-To: rswgnu@gmail.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="001a11473a84d65869055bfca33b" X-Trace: blaine.gmane.org 1508515583 11697 195.159.176.226 (20 Oct 2017 16:06:23 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 20 Oct 2017 16:06:23 +0000 (UTC) Cc: emacs-devel To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Oct 20 18:06:13 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e5Zo8-0000Um-GF for ged-emacs-devel@m.gmane.org; Fri, 20 Oct 2017 18:06:00 +0200 Original-Received: from localhost ([::1]:54730 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5ZoF-0002yW-U7 for ged-emacs-devel@m.gmane.org; Fri, 20 Oct 2017 12:06:07 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45875) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5Znb-0002yQ-6l for emacs-devel@gnu.org; Fri, 20 Oct 2017 12:05:28 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e5ZnX-0006qU-3N for emacs-devel@gnu.org; Fri, 20 Oct 2017 12:05:27 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:37805) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5ZnW-0006qI-V5 for emacs-devel@gnu.org; Fri, 20 Oct 2017 12:05:22 -0400 Original-Received: from mail-qk0-f176.google.com ([209.85.220.176]:44550) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1e5ZnW-00016k-NZ for emacs-devel@gnu.org; Fri, 20 Oct 2017 12:05:22 -0400 Original-Received: by mail-qk0-f176.google.com with SMTP id r64so14908119qkc.1 for ; Fri, 20 Oct 2017 09:05:22 -0700 (PDT) X-Gm-Message-State: AMCzsaVInqFRjNKq7NeqY3t3GxFJns9aCbdXxQFsiQDa66vgihumZdfo a5i9eVcFUyWLKqdZF4ZyM5rCMCyAkWqcJ+3zaJs= X-Google-Smtp-Source: ABhQp+S6GWcf6H57G+IR8WS9C9o4jZOWF54GkpdaXHVwHsxd9eeBPogN1ie+GgMEe5uHTjZprColLsSD9447OCnNYc4= X-Received: by 10.55.25.85 with SMTP id k82mr7271255qkh.223.1508515522171; Fri, 20 Oct 2017 09:05:22 -0700 (PDT) Original-Received: by 10.200.12.74 with HTTP; Fri, 20 Oct 2017 09:04:51 -0700 (PDT) In-Reply-To: X-Gmail-Original-Message-ID: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:219652 Archived-At: --001a11473a84d65869055bfca33b Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Oct 20, 2017 at 11:13 AM, Stefan Monnier wrote: > >> > I can't just add a post-command-hook that calls the transient map > >> > disable function because calling (keyboard-quit) from the > >> > post-command-hook triggers an error and I imagine that is not a prop= er > >> > usage scenario. > >> Why do you need a post-command-hook? > > HyControl uses post-command-hook to persist a prefix-argument value > across > > commands and to continually display a help message in the minibuffer > until > > exit. > > But neither of those activities seem related to calling the exit > function or calling keyboard-quit. > =E2=80=8BI thought you were just asking about how this library used post-command-hook with set-transient-map. When {C-g} is pressed, we want to execute some actions and then terminate the transient map. We could do this in the {C-g} key binding itself rather than in post-command-hook. I just tested and that does indeed solve the problem. Thanks much. =E2=80=8B=E2=80=8B > > =E2=80=8B=E2=80=8B > > =E2=80=8B=E2=80=8BJust curious, why does set-transient-map use pre-comm= and-hook instead > of > =E2=80=8B=E2=80=8B > > post-command-hook=E2=80=8B to test whether or not to keep the transient= -map > =E2=80=8B=E2=80=8B > > enabled? > =E2=80=8B=E2=80=8B > > =E2=80=8B=E2=80=8B > Because we need to know which is the next command before we know whether > =E2=80=8B=E2=80=8B > to exit or not: E.g. after hitting C-u we don't know yet whether to > =E2=80=8B=E2=80=8B > exit, it's only once the user hits the next key that we know whether to > =E2=80=8B=E2=80=8B > exit (e.g. she pressed `a`) or stay (e.g. she pressed `5`). > =E2=80=8B=E2=80=8B > > =E2=80=8B=E2=80=8B > And when she presses `a`, we need to exit *before* running the command > =E2=80=8B=E2=80=8B > bound to `a`: sometimes it could be OK to linger on until the end of > =E2=80=8B=E2=80=8B > the command bound to `a`, but not in general. > =E2=80=8BI understand. Would it be possible to make the exit function run = on both pre- and post-command hook so that it could use the results of the command= =E2=80=8B when needed and eliminate the need in many cases to call the quit function manually? Or would that cause problems? Bob --001a11473a84d65869055bfca33b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Fri, Oct 20, 2= 017 at 11:13 AM, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>= ;> > I can't just add a post-command-hook that calls the transien= t map
>> > disable function because calling (keyboard-quit) from the
>> > post-command-hook triggers an error and I imagine that is not= a proper
>> > usage scenario.
>> Why do you need a post-command-hook?
> HyControl uses post-command-hook to persist a prefix-argument value ac= ross
> commands and to continually display a help message in the minibuffer u= ntil
> exit.

But neither of those activities seem related to calling the exit
function or calling keyboard-quit.

=E2=80=8BI th= ought you were just asking about how this library used post-command-hook wi= th set-transient-map.

When {C-g} is pressed, we want to execute some= actions and then terminate the transient map.=C2=A0 We could
do this in t= he {C-g} key binding itself rather than in post-command-hook.=C2=A0 I just = tested and that does
indeed solve the problem.=C2=A0 Thanks much.

=E2=80=8B=E2=80=8B

=E2=80=8B=E2=80=8B
> =E2=80=8B=E2=80=8BJust curious, why= does set-transient-map use pre-command-hook instead of
=E2=80=8B=E2=80=8B
> post-command-hook=E2=80=8B to test = whether or not to keep the transient-map
=E2=80=8B=E2=80=8B
> enabled?
=E2=80=8B=E2=80=8B

=E2=80=8B=E2=80=8B
Because we need to know which is = the next command before we know whether
=E2=80=8B=E2=80=8B
to exit or not: E.g. after hitting C-u w= e don't know yet whether to
=E2=80=8B=E2=80=8B
exit, it's only once the user hits t= he next key that we know whether to
=E2=80=8B=E2=80=8B
exit (e.g. she pressed `a`) or stay (e.g= . she pressed `5`).
=E2=80=8B=E2=80=8B

=E2=80=8B=E2=80=8B
And when she presses `a`, we need to exi= t *before* running the command
=E2=80=8B=E2=80=8B
bound to `a`: sometimes it could be OK t= o linger on until the end of
=E2=80=8B=E2=80=8B
the command bound to `a`, but not in gen= eral.

=E2=80=8BI understand.=C2=A0 Would it be p= ossible to make the exit function run on both pre- and post-command hook so= that it could use the results of the command=E2=80=8B when needed and elim= inate the need in many cases to call the quit function manually?=C2=A0 Or w= ould that cause problems?

Bob

--001a11473a84d65869055bfca33b--