[-- Attachment #1: Type: text/plain, Size: 260 bytes --] user-error in sql-set-product interrupts normal execution flow in org-indent-line for sql blocks without :engine. Provided patch is not the best solution, but I do not have the time or inclination to mess around with anything outside of the org-mode itself. [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-ob-sql-do-not-stuck-on-user-error-in-sql-set-product.patch --] [-- Type: text/x-patch, Size: 891 bytes --] From 8768e1c245ab0c0d2d8f8ac830f39ac89d23a839 Mon Sep 17 00:00:00 2001 From: Ivan Sokolov <ivan-p-sokolov@ya.ru> Date: Tue, 20 Apr 2021 18:22:21 +0300 Subject: [PATCH] ob-sql: do not stuck on user-error in sql-set-product --- lisp/ob-sql.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el index 7c359b988..4e61253bf 100644 --- a/lisp/ob-sql.el +++ b/lisp/ob-sql.el @@ -98,7 +98,9 @@ Set `sql-product' in Org edit buffer according to the corresponding :engine source block header argument." (let ((product (cdr (assq :engine (nth 2 info))))) - (sql-set-product product))) + (condition-case _error + (sql-set-product product) + (user-error)))) (defun org-babel-sql-dbstring-mysql (host port user password database) "Make MySQL cmd line args for database connection. Pass nil to omit that arg." -- 2.31.1
Hi Ivan,
thanks for the bug report.
Ivan Sokolov <ivan-p-sokolov@ya.ru> writes:
> user-error in sql-set-product interrupts normal execution flow in
> org-indent-line for sql blocks without :engine.
Sorry, I don't really understand what is the exact problem here.
Can you restate it by explaining what you want to do, what happens
instead, and how the patch fixes the problem?
Thanks,
--
Bastien
> what you want to do? I want to indent some sql in the src block in an org file. > what happens instead Buffer becomes unusable -- text is entered in the opposite direction until the Org-Src buffer is closed. NOTE: I am not opening this buffer myself, it is opened by org-indent-line, but is not closed because sql-set-product throws a user-error. > how the patch fixes the problem? It ignores user-error thrown by sql-set-product. --- Debugger entered--entering a function: * signal(user-error ("SQL product nil is not supported; treated as ANSI")) * user-error("SQL product %s is not supported; treated as ANSI" nil) * #f(compiled-function (product) "Set `sql-product' to PRODUCT and enable appropriate highlighting." (interactive #f(compiled-function () #<bytecode 0x2eb2ee0e10bfe1>)) #<bytecode -0x63b7e4c1361d2b2>)(nil) * apply(#f(compiled-function (product) "Set `sql-product' to PRODUCT and enable appropriate highlighting." (interactive #f(compiled-function () #<bytecode 0x2eb2ee0e10bfe1>)) #<bytecode -0x63b7e4c1361d2b2>) nil) * sql-set-product(nil) org-babel-edit-prep:sql(("sql" "select foo\n" ((:results . "replace") (:exports . "code") (:tangle . "no") (:hlines . "no") (:noweb . "no") (:cache . "no") (:session . "none")) "" nil 1 "(ref:%s)")) org-edit-src-code() org-babel-do-key-sequence-in-edit-buffer("\11") org-indent-line() indent-according-to-mode() electric-indent-post-self-insert-function() self-insert-command(1) newline(nil 1) org--newline(nil nil 1) org-return(nil nil 1) funcall-interactively(org-return nil nil 1) call-interactively(org-return nil nil) command-execute(org-return)
Hi Ivan, thanks for the explanations. I applied your patch in maint with commit 45ca597f9, adding a commit message to it. See https://orgmode.org/worg/org-contribute.html#commit-messages Thanks, -- Bastien