branch: externals/org
commit bd5665e017eef03107afe73a8fa05c3748f639ee
Author: Ihor Radchenko <[email protected]>
Commit: Ihor Radchenko <[email protected]>
org-table-make-reference: Address compiler warning
* lisp/org-table.el (org-table-make-reference): Drop branch of `if'
unused during runtime. This preserves _interactive_ behavior.
* testing/lisp/test-org-table.el
(test-org-table/org-table-make-reference/mode-string-none):
(test-org-table/org-table-make-reference/mode-string-N): Fix tests to
check for the existing _interactive_ behavior. When running make
test (eq "" "") happens to return t and tests were passing previously
by accident despite actual behavior during user session being
different. Fix the tests to avoid breaking changes in the user
experience.
Link:
https://list.orgmode.org/orgmode/[email protected]/
---
lisp/org-table.el | 18 +++++++++---------
testing/lisp/test-org-table.el | 4 ++--
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/lisp/org-table.el b/lisp/org-table.el
index 0c2dc27ed6..a1bd140fb0 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -2887,15 +2887,15 @@ list, `literal' is for the format specifier L."
(if lispp
(if (eq lispp 'literal)
elements
- (if (and (eq elements "") (not keep-empty))
- ;; FIXME: This branch of `if' is never used because
- ;; strings are never `eq' here. But changing to
- ;; `equal' breaks tests.
- ;; See
- ;;
https://list.orgmode.org/orgmode/[email protected]/
- ""
- (prin1-to-string
- (if numbers (string-to-number elements) elements))))
+ ;; Ignore KEEP-EMPTY here.
+ ;; When ELEMENTS="" and NUMBERS=t, (string-to-number "")
+ ;; returns 0 - consistent with (0) for Calc branch.
+ ;; When ELEMENTS="" and NUMBERS=nil, `prin1-to-string' will
+ ;; return "\"\"" - historical behavior that also does not
+ ;; leave missing arguments in formulas like (string< $1 $2)
+ ;; when $2 cell is empty.
+ (prin1-to-string
+ (if numbers (string-to-number elements) elements)))
(if (string-match "\\S-" elements)
(progn
(when numbers (setq elements (number-to-string
diff --git a/testing/lisp/test-org-table.el b/testing/lisp/test-org-table.el
index bfe5c32849..df63a65fc8 100644
--- a/testing/lisp/test-org-table.el
+++ b/testing/lisp/test-org-table.el
@@ -938,7 +938,7 @@ See also URL
`https://orgmode.org/worg/org-tutorials/org-lookups.html'."
;; For Lisp formula
(should (equal "\"0\"" (org-table-make-reference "0" nil nil t)))
(should (equal "\"z\"" (org-table-make-reference "z" nil nil t)))
- (should (equal "" (org-table-make-reference "" nil nil t)))
+ (should (equal "\"\"" (org-table-make-reference "" nil nil t)))
(should (equal "\"0\" \"1\"" (org-table-make-reference '("0" "1") nil nil
t)))
(should (equal "\"z\" \"1\"" (org-table-make-reference '("z" "1") nil nil
t)))
(should (equal "\"1\"" (org-table-make-reference '("" "1") nil nil t)))
@@ -965,7 +965,7 @@ See also URL
`https://orgmode.org/worg/org-tutorials/org-lookups.html'."
;; For Lisp formula
(should (equal "0" (org-table-make-reference "0" nil t t)))
(should (equal "0" (org-table-make-reference "z" nil t t)))
- (should (equal "" (org-table-make-reference "" nil t t)))
+ (should (equal "0" (org-table-make-reference "" nil t t)))
(should (equal "0 1" (org-table-make-reference '("0" "1") nil t t)))
(should (equal "0 1" (org-table-make-reference '("z" "1") nil t t)))
(should (equal "1" (org-table-make-reference '("" "1") nil t t)))