From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takaaki Ishikawa Subject: Re: Quit and Error in org-export--dispatch-action Date: Mon, 9 Dec 2019 13:58:21 +0900 Message-ID: <917C186E-DF0F-4198-967B-E382DC37A9BC@ieee.org> References: <87a787gj9h.fsf@kyleam.com> <874kyeglm7.fsf@kyleam.com> Mime-Version: 1.0 (Mac OS X Mail 13.0 \(3601.0.10\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_AFFFA17C-0C07-452C-9C00-962265C0331C" Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:42310) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieB7v-0002rs-3B for emacs-orgmode@gnu.org; Sun, 08 Dec 2019 23:58:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ieB7t-0000uY-75 for emacs-orgmode@gnu.org; Sun, 08 Dec 2019 23:58:30 -0500 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]:41279) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ieB7s-0000ZR-NI for emacs-orgmode@gnu.org; Sun, 08 Dec 2019 23:58:29 -0500 Received: by mail-pg1-x52a.google.com with SMTP id x8so6481079pgk.8 for ; Sun, 08 Dec 2019 20:58:27 -0800 (PST) In-Reply-To: <874kyeglm7.fsf@kyleam.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Kyle Meyer Cc: orgmode list --Apple-Mail=_AFFFA17C-0C07-452C-9C00-962265C0331C Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Dear Kyle and all, Thank you for your kind feedback. > Thanks for providing more context. So if I'm understanding correctly, > the point here is that for your use case/setup you'd like to call > delete-window even when you select 'q' within the org-export-dispatch > call. Signaling a user-error doesn't make this much more difficult: = you > can wrap the `(apply f ...)' call within a condition-case. Yes. But I found out `C-g' also exits `org-export-dispatch=E2=80=99 and it is difficult for me to catch `C-g' signal in the original advice = function. So I=E2=80=99ve tried again and produced the following code to support = calling any=20 additional functions before and after `org-export-dispatch=E2=80=99 even = if user types `q` or `C-g`. In this case, using user-error is OK for me :) #+begin_src emacs-lisp (with-eval-after-load "ox" (defvar my-org-export-before-hook nil) (add-hook 'my-org-export-before-hook #'split-window-horizontally) (defvar my-org-export-after-hook nil) (add-hook 'my-org-export-after-hook #'delete-window) (defun my-org-export--post-processing () (when (eq this-command 'org-export-dispatch) (run-hooks 'my-org-export-after-hook)) (remove-hook 'post-command-hook #'my-org-export--post-processing)) (defun my-org-export-dispatch (f ARG) (cond (org-export-dispatch-use-expert-ui (apply f ARG)) ((> (frame-width) 160) (when my-org-export-after-hook (add-hook 'post-command-hook = #'my-org-export--post-processing)) (run-hooks 'my-org-export-before-hook) (apply f ARG)) (t (apply f ARG)))) (advice-add 'org-export-dispatch :around #'my-org-export-dispatch)) #+end_src I created a patch for this issue. Please find an attached patch. It is a really tiny patch. But I have already signed the copyright assignment with FSF. > I see two related advantages of sticking to signaling an error here: >=20 > * It stays close to what the current code does. Continuing to signal > an error but replacing `error' with `user-error' reduces the risk of > bugs or unintended changes in behavior while avoiding showing a > backtrace when the caller aborts and debug-on-error is true (the > initial issue reported in this thread). >=20 > * 'q' is described as aborting, so I think it's confusing to make 'q' > instead execute a no-op function and continue with the remaining = code > in the outer functions, which at the moment boils down to code in > org-export-dispatch. For example, with your suggested change, > issuing 'q' will result in `ignore' being saved as the last export > action, and it's hard to imagine that's an action the user would > expect or want to repeat when calling org-export-dispatch with a > prefix argument. I partially agree with you because the dispatcher shows it as =E2=80=9C[q] Exit=E2=80=9D. This is actually different from =E2=80=9C[q= ] Aborting=E2=80=9D. Typing `q` is completely intended by user to exit the procedure. If something is happened accidentally in the procedure, then, IMO, we should say it as =E2=80=9Caborting=E2=80=9D and update the = code appropriately. Anyway, replacing with `user-error` is OK. Best, Takaaki --Apple-Mail=_AFFFA17C-0C07-452C-9C00-962265C0331C Content-Disposition: attachment; filename=0001-ox.el-Replace-error-with-user-error-to-exit-org-expo.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-ox.el-Replace-error-with-user-error-to-exit-org-expo.patch" Content-Transfer-Encoding: quoted-printable =46rom=20b22ed4854e7776effa62f01af47691800a76a9ff=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20Takaaki=20ISHIKAWA=20=0ADate:=20= Mon,=209=20Dec=202019=2013:08:56=20+0900=0ASubject:=20[PATCH]=20ox.el:=20= Replace=20error=20with=20user-error=20to=20exit=0A=20org-export-dispatch=0A= =0A*=20lisp/ox.el=20(org-export--dispatch-action):=20Replace=20error=20= with=20user-error=0A(org-export--dispatch-action):=20Replace=20an=20= error=20function=20with=20a=20user-error=20so=20that=20user=20can=20quit=20= `org-export-dispatch'=20without=20entering=20debugging=20mode.=0A=0A= Modified=20from=20a=20patch=20proposal=20by=20Takaaki=20Ishikawa.=0A---=0A= =20lisp/ox.el=20|=202=20+-=0A=201=20file=20changed,=201=20insertion(+),=20= 1=20deletion(-)=0A=0Adiff=20--git=20a/lisp/ox.el=20b/lisp/ox.el=0Aindex=20= 5b4134ecc..10286e18f=20100644=0A---=20a/lisp/ox.el=0A+++=20b/lisp/ox.el=0A= @@=20-6929,7=20+6929,7=20@@=20options=20as=20CDR."=0A=20=20=20=20=20=20=20= (org-export--dispatch-ui=20options=20first-key=20expertp))=0A=20=20=20=20= =20=20;;=20q=20key=20at=20first=20level=20aborts=20export.=20=20At=20= second=20level,=20cancel=0A=20=20=20=20=20=20;;=20first=20key=20instead.=0A= -=20=20=20=20=20((eq=20key=20?q)=20(if=20(not=20first-key)=20(error=20= "Export=20aborted")=0A+=20=20=20=20=20((eq=20key=20?q)=20(if=20(not=20= first-key)=20(user-error=20"Export=20aborted")=0A=20=09=09=20=20=20=20= (org-export--dispatch-ui=20options=20nil=20expertp)))=0A=20=20=20=20=20=20= ;;=20Help=20key:=20Switch=20back=20to=20standard=20interface=20if=20= expert=20UI=20was=0A=20=20=20=20=20=20;;=20active.=0A--=20=0A2.21.0=20= (Apple=20Git-122.2)=0A=0A= --Apple-Mail=_AFFFA17C-0C07-452C-9C00-962265C0331C Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii --Apple-Mail=_AFFFA17C-0C07-452C-9C00-962265C0331C--