From c274128997881513256d57b4de2505603f9be018 Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Fri, 12 Apr 2024 15:07:02 +0300 Subject: [PATCH] org-table-eval-formula: Keep empty result in duration (;TtU) mode * lisp/org-table.el (org-table-eval-formula): When using T, t, or U (duration) mode, do not convert empty results into duration. This is to keep things consistent with default mode. Reported-by: Jeff Trull Link: https://list.orgmode.org/orgmode/CAF_DUeEFpNU5UXjE80yB1MB9xj5oVLqG=XadnkqCdzWtakWdPg@mail.gmail.com/ --- lisp/org-table.el | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lisp/org-table.el b/lisp/org-table.el index 535d1b44c..b1c6ef86d 100644 --- a/lisp/org-table.el +++ b/lisp/org-table.el @@ -2657,11 +2657,16 @@ location of point." form (calc-eval (cons form calc-modes) (when (and (not keep-empty) numbers) 'num))) - ev (if duration (org-table-time-seconds-to-string - (if (string-match "^[0-9]+:[0-9]+\\(?::[0-9]+\\)?$" ev) - (string-to-number (org-table-time-string-to-seconds ev)) - (string-to-number ev)) - duration-output-format) + ev (if (and duration + ;; When the result is an empty string, + ;; keep it empty. + ;; See https://list.orgmode.org/orgmode/CAF_DUeEFpNU5UXjE80yB1MB9xj5oVLqG=XadnkqCdzWtakWdPg@mail.gmail.com/ + (not (string-empty-p ev))) + (org-table-time-seconds-to-string + (if (string-match "^[0-9]+:[0-9]+\\(?::[0-9]+\\)?$" ev) + (string-to-number (org-table-time-string-to-seconds ev)) + (string-to-number ev)) + duration-output-format) ev))) (when org-table-formula-debug