From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Roland Winkler" Newsgroups: gmane.emacs.bugs Subject: bug#11983: 24.1; Electric-command-loop broken? Date: Thu, 19 Jul 2012 16:29:53 -0500 Message-ID: <20488.31825.986146.195944@gargle.gargle.HOWL> References: <87pq7s6b8q.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1342733456 26150 80.91.229.3 (19 Jul 2012 21:30:56 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 19 Jul 2012 21:30:56 +0000 (UTC) Cc: 11983@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jul 19 23:30:55 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SryJB-00064q-QD for geb-bug-gnu-emacs@m.gmane.org; Thu, 19 Jul 2012 23:30:54 +0200 Original-Received: from localhost ([::1]:45053 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SryJB-0002Jf-4u for geb-bug-gnu-emacs@m.gmane.org; Thu, 19 Jul 2012 17:30:53 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:49368) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SryJ8-0002JP-4A for bug-gnu-emacs@gnu.org; Thu, 19 Jul 2012 17:30:50 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SryJ6-0003DQ-PF for bug-gnu-emacs@gnu.org; Thu, 19 Jul 2012 17:30:49 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:41791) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SryJ6-0003DK-LL for bug-gnu-emacs@gnu.org; Thu, 19 Jul 2012 17:30:48 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1SryP7-0000PI-No for bug-gnu-emacs@gnu.org; Thu, 19 Jul 2012 17:37:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Roland Winkler" Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 19 Jul 2012 21:37:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 11983 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 11983-submit@debbugs.gnu.org id=B11983.13427337731504 (code B ref 11983); Thu, 19 Jul 2012 21:37:01 +0000 Original-Received: (at 11983) by debbugs.gnu.org; 19 Jul 2012 21:36:13 +0000 Original-Received: from localhost ([127.0.0.1]:51337 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SryOK-0000OD-Uo for submit@debbugs.gnu.org; Thu, 19 Jul 2012 17:36:13 -0400 Original-Received: from fencepost.gnu.org ([208.118.235.10]:57925) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SryOI-0000O5-DJ for 11983@debbugs.gnu.org; Thu, 19 Jul 2012 17:36:11 -0400 Original-Received: from pchdb00005.uni-regensburg.de ([132.199.129.10]:40285 helo=regnitz) by fencepost.gnu.org with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1SryIG-0002GK-DR; Thu, 19 Jul 2012 17:29:56 -0400 In-Reply-To: X-Mailer: VM 8.2 trial under 24.1.1 (x86_64-unknown-linux-gnu) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:62173 Archived-At: 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.