From: Takaaki Ishikawa <takaxp@ieee.org>
To: Kyle Meyer <kyle@kyleam.com>
Cc: orgmode list <emacs-orgmode@gnu.org>
Subject: Re: Quit and Error in org-export--dispatch-action
Date: Mon, 9 Dec 2019 13:58:21 +0900 [thread overview]
Message-ID: <917C186E-DF0F-4198-967B-E382DC37A9BC@ieee.org> (raw)
In-Reply-To: <874kyeglm7.fsf@kyleam.com>
[-- Attachment #1: Type: text/plain, Size: 3238 bytes --]
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’ and
it is difficult for me to catch `C-g' signal in the original advice function.
So I’ve tried again and produced the following code to support calling any
additional functions before and after `org-export-dispatch’ 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:
>
> * 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).
>
> * '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 “[q] Exit”. This is actually different from “[q] Aborting”.
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 “aborting” and update the code appropriately.
Anyway, replacing with `user-error` is OK.
Best,
Takaaki
[-- Attachment #2: 0001-ox.el-Replace-error-with-user-error-to-exit-org-expo.patch --]
[-- Type: application/octet-stream, Size: 1220 bytes --]
From b22ed4854e7776effa62f01af47691800a76a9ff Mon Sep 17 00:00:00 2001
From: Takaaki ISHIKAWA <takaxp@ieee.org>
Date: Mon, 9 Dec 2019 13:08:56 +0900
Subject: [PATCH] ox.el: Replace error with user-error to exit
org-export-dispatch
* lisp/ox.el (org-export--dispatch-action): Replace error with user-error
(org-export--dispatch-action): Replace an error function with a user-error so that user can quit `org-export-dispatch' without entering debugging mode.
Modified from a patch proposal by Takaaki Ishikawa.
---
lisp/ox.el | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lisp/ox.el b/lisp/ox.el
index 5b4134ecc..10286e18f 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -6929,7 +6929,7 @@ options as CDR."
(org-export--dispatch-ui options first-key expertp))
;; q key at first level aborts export. At second level, cancel
;; first key instead.
- ((eq key ?q) (if (not first-key) (error "Export aborted")
+ ((eq key ?q) (if (not first-key) (user-error "Export aborted")
(org-export--dispatch-ui options nil expertp)))
;; Help key: Switch back to standard interface if expert UI was
;; active.
--
2.21.0 (Apple Git-122.2)
[-- Attachment #3: Type: text/plain, Size: 4 bytes --]
next prev parent reply other threads:[~2019-12-09 4:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-05 7:42 Quit and Error in org-export--dispatch-action Takaaki Ishikawa
2019-12-05 10:27 ` Kyle Meyer
2019-12-05 13:59 ` Takaaki Ishikawa
2019-12-06 3:48 ` Kyle Meyer
2019-12-09 4:58 ` Takaaki Ishikawa [this message]
2019-12-09 10:39 ` Kyle Meyer
2019-12-09 15:02 ` Takaaki Ishikawa
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.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=917C186E-DF0F-4198-967B-E382DC37A9BC@ieee.org \
--to=takaxp@ieee.org \
--cc=emacs-orgmode@gnu.org \
--cc=kyle@kyleam.com \
/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/org-mode.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).