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 <edaskel@att.net>
Link: https://list.orgmode.org/orgmode/CAF_DUeEFpNU5UXjE80yB1MB9xj5oVLqG=XadnkqCdzWtakWdPg@mail.gmail.com/
This commit is contained in:
Ihor Radchenko 2024-04-12 15:07:02 +03:00
parent 66e307b411
commit c274128997
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 10 additions and 5 deletions

View File

@ -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