From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 8N6QOzqRG2CkRgAA0tVLHw (envelope-from ) for ; Thu, 04 Feb 2021 06:16:26 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id EI/yNjqRG2AfNgAAbx9fmQ (envelope-from ) for ; Thu, 04 Feb 2021 06:16:26 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id AFDD594021E for ; Thu, 4 Feb 2021 06:16:25 +0000 (UTC) Received: from localhost ([::1]:52124 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7XwG-0001Z1-18 for larch@yhetil.org; Thu, 04 Feb 2021 01:16:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35166) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7Xvm-0001Yu-Bx for emacs-orgmode@gnu.org; Thu, 04 Feb 2021 01:15:54 -0500 Received: from out1.migadu.com ([2001:41d0:2:863f::]:28033) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7Xvi-0002Y6-B2 for emacs-orgmode@gnu.org; Thu, 04 Feb 2021 01:15:53 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kyleam.com; s=key1; t=1612419343; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/nZlucbjadTqBByjzYY8elk9zALTRKpl1N+8qBtKSYg=; b=pZJM1yuDSjixCGYe7CiLIGQ1Mt9LnjqU7hCdolEbrt0nr/jevWu2yUEG7dr+id0H/FYH/7 3hyU8TQm3ol/+6wcG0EtjjNDUXk0ZWtIu3a+w2ewOVGpJrxW/oOucGPwq2k8JKc6U4n2Ag fVplRIzP5ZtqAak+ghcA1ElZVQ9FRqgp77JP39osRLJNhngq2gqj0I8lneuYaPdxskgXdN 3qMlwAXDDN2kkFd2bC3SakVSBxHI+waXaLM5m4UtlWHcT5BPolunnJNNKt04Ij6AdBrLIW 9dLbiJ4b47Ns4PATU6SF7MxDv6tE6N1uGh3KJ2KTVgfA+brRRLihiqoJ8ZoaZg== From: Kyle Meyer To: Michael Powe Subject: [PATCH] org.el: Don't clear dynamic block if write function is undefined In-Reply-To: References: Date: Thu, 04 Feb 2021 01:15:42 -0500 Message-ID: <87wnvofje9.fsf@kyleam.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Migadu-Auth-User: kyle@kyleam.com Received-SPF: pass client-ip=2001:41d0:2:863f::; envelope-from=kyle@kyleam.com; helo=out1.migadu.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -2.56 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=kyleam.com header.s=key1 header.b=pZJM1yuD; dmarc=none; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: AFDD594021E X-Spam-Score: -2.56 X-Migadu-Scanner: scn1.migadu.com X-TUID: fLsQhq4fX+nA 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=E2=80=99s 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 sensitiv= e. > 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: 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 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")))))) =20 base-commit: 369eb2739787b9b24399c803be31e4e793113dd1 --=20 2.30.0