* Error with org-update-dblock
@ 2021-01-16 1:13 Michael Powe
2021-02-04 6:15 ` [PATCH] org.el: Don't clear dynamic block if write function is undefined Kyle Meyer
0 siblings, 1 reply; 2+ messages in thread
From: Michael Powe @ 2021-01-16 1:13 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1170 bytes --]
Hello,
After logging some clock time, I used the normal key combination, C-u C-c
C-x C-u to update my timesheet tables, and received this error message.
org-update-dblock: Symbol’s function definition is void:
org-dblock-write:CLOCKTABLE
This message is returned also from manually calling the function.
Org mode version 9.3 (release_9.3 @ /usr/share/emacs/27.1/lisp/org/)
GNU Emacs 27.1 (build 1, x86_64-suse-linux-gnu, GTK+ Version 3.24.22, cairo
version 1.16.0)
Well, after recovering from my horror at losing my timesheets for a day's
work, I was able to track down the problem: the function is case sensitive.
At some point, (apparently) I fat-fingered a key combo & upcased the mode
line for two tables. After returning them to l-case, all worked as it
should.
I dunno - should the function be case insensitive?
I love this tool. Now that my pulse has returned to normal. Once, it even
saved me from unpleasant interviews in my manager's office.
Thanks.
mp
"Do not neglect to do good, and to share what you have." - Hebrews 13:16a
Michael Powe
Naugatuck CT USA
powem@ctpowe.net
503.502.9582 mobile
203.490.6447 skype
[-- Attachment #2: Type: text/html, Size: 1699 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH] org.el: Don't clear dynamic block if write function is undefined
2021-01-16 1:13 Error with org-update-dblock Michael Powe
@ 2021-02-04 6:15 ` Kyle Meyer
0 siblings, 0 replies; 2+ messages in thread
From: Kyle Meyer @ 2021-02-04 6:15 UTC (permalink / raw)
To: Michael Powe; +Cc: emacs-orgmode
Michael Powe writes:
> Hello,
>
> After logging some clock time, I used the normal key combination, C-u C-c
> C-x C-u to update my timesheet tables, and received this error message.
>
> org-update-dblock: Symbol’s function definition is void:
> org-dblock-write:CLOCKTABLE
[...]
> Well, after recovering from my horror at losing my timesheets for a day's
> work, I was able to track down the problem: the function is case sensitive.
> At some point, (apparently) I fat-fingered a key combo & upcased the mode
> line for two tables. After returning them to l-case, all worked as it
> should.
>
> I dunno - should the function be case insensitive?
I don't think so. Other libraries and users can define their own
dynamic blocks, and I don't think anything documents that the
org-dblock-write:<name> function must be all lower case. However, I do
think we could improve the situation by signaling an error if the
function is unknown _before_ clearing the block.
With the below patch, you would have seen
user-error: Unknown dynamic block type: CLOCKTABLE
and the existing block would have been left as is. What do you think?
-- >8 --
Subject: [PATCH] org.el: Don't clear dynamic block if write function is
undefined
* lisp/org.el (org-prepare-dblock): Check whether the block's write
function is defined before clearing the existing contents.
(org-map-dblocks): Relay the message of the caught error to help the
caller figure out what went wrong.
The write function may be undefined because the user unintentionally
modified the dynamic block name or didn't load a library, and deleting
contents in this situation can be alarming. Instead signal an error
that's hopefully enough for the user to figure out what went wrong.
Reported-by: Michael Powe <powem@ctpowe.net>
Ref: CAF7nVLVRVrmCgMnMhga9+mtuE0nav-eH4C17Bf4EiEryowt27w@mail.gmail.com
---
lisp/org.el | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/lisp/org.el b/lisp/org.el
index 5b1443c4e..c9f58c9a5 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -9165,6 +9165,8 @@ (defun org-prepare-dblock ()
(name (org-no-properties (match-string 1)))
(params (append (list :name name)
(read (concat "(" (match-string 3) ")")))))
+ (unless (fboundp (intern (concat "org-dblock-write:" name)))
+ (user-error "Unknown dynamic block type: %s" name))
(save-excursion
(beginning-of-line 1)
(skip-chars-forward " \t")
@@ -9189,9 +9191,11 @@ (defun org-map-dblocks (&optional command)
(while (re-search-forward org-dblock-start-re nil t)
(goto-char (match-beginning 0))
(save-excursion
- (condition-case nil
+ (condition-case err
(funcall cmd)
- (error (message "Error during update of dynamic block"))))
+ (error
+ (message "Error during update of dynamic block: %s"
+ (error-message-string err)))))
(unless (re-search-forward org-dblock-end-re nil t)
(error "Dynamic block not terminated"))))))
base-commit: 369eb2739787b9b24399c803be31e4e793113dd1
--
2.30.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-02-04 6:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-16 1:13 Error with org-update-dblock Michael Powe
2021-02-04 6:15 ` [PATCH] org.el: Don't clear dynamic block if write function is undefined Kyle Meyer
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).