|
From: | gerard . vermeulen |
Subject: | Re: [PATCH] org-babel-demarcate-block: split using element API |
Date: | Thu, 29 Feb 2024 09:50:42 +0000 |
On 28.02.2024 12:54, Ihor Radchenko wrote:
gerard.vermeulen@posteo.net writes:You may wrap `org-indent-block' into `condition-case' to catch user-errors.The caveat is not a real constraint, since Org has limited support for source block editing in an Org mode buffer when an `org-babel-edit-prep:<LANG>' function signals an user-error. I show that in the attached no-user-errors-in-edit-prep.org.I studied the existing Org handling of various errors related to src edit buffers and it seems that we tend to ignore them in a number of scenarios. In particular, when major mode fails to load for any reason, Org mode does not even throw an error, but simply displays a warning. So, I think that we can similarly ignore errors in edit-prep function, demoting them to messages. (In addition, it does not look like electric-indent-mode triggered in your example file by pressing <RET> handles errors gracefully either - yet another reason not to throw errors in `org-indent-*' functions) Does it make sense?
Your reply helped me to read the Org Babel code from a different view point. I re-discovered that `org-babel-edit-prep:sql' handles all issues gracefully while trying the block below: #+begin_src sql :engine wrong a b #+end_src That includes `org-babel-demarcate-block' splitting with the patch. I do not understand why it works and why I never see the user-error re-signalled by `org-babel-edit-prep:sql' (even as demoted message). After writing `org-babel-edit-prep:python' like: #+begin_src emacs-lisp -n :results silent (defun harm-full-edit-prep (_info) (user-error "Harm-FULL edit-prep")) (defun org-babel-edit-prep:python (info) "Imitate `org-babel-edit-prep:sql'." (condition-case nil (harm-full-edit-prep info) (user-error "Why is this harm-LESS in `org-babel-edit-prep:sql'?"))) #+end_src and trying it on the block below: #+begin_src python -i -n :results silent 11 22 #+end_src I see that this `org-babel-edit-prep:python' handles all issues like `org-babel-edit-prep:sql' (and it does not matter whether `electric-indent-mode' is disabled or enabled). I conclude (contrary to the previous commit message in the patch): In case functions called by an `org-babel-edit-prep:<LANG>' function raise an user-error, this `org-babel-edit-prep:<LANG>' function should re-signal the user-error like `org-babel-edit-prep:sql' does. Attached you'll find the patch with an updated commit message. Regards -- Gerard
0001-org-babel-demarcate-block-split-using-element-API.patch
Description: Binary data
[Prev in Thread] | Current Thread | [Next in Thread] |