[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org 07dd3bcae6: org-columns-compile-format: Fix regexp
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org 07dd3bcae6: org-columns-compile-format: Fix regexp |
Date: |
Sat, 31 Aug 2024 09:58:37 -0400 (EDT) |
branch: externals/org
commit 07dd3bcae6b7b5e0692fc40dd307a7e841179b52
Author: Slawomir Grochowski <slawomir.grochowski@gmail.com>
Commit: Ihor Radchenko <yantar92@posteo.net>
org-columns-compile-format: Fix regexp
* lisp/org-colview.el (org-columns-compile-format): Refactor
string-based regexp to `rx' form. Fix regexp: When an empty
parentheses () is in the column format string then the regexp
can't capture the operator which is in curly brackets {}.
(org-columns-new): prevent adding empty parantheses '()' to 'column
format string' when 'column title' is empty.
* testing/lisp.test-org-colview.el (test-org-colview/compile-format):
New test case: check if operator will be captured when there is
empty parantheses '()' in 'column format string'.
Reported-by: SÅ‚awomir Grochowski <slawomir.grochowski@gmail.com>
Link: https://list.orgmode.org/orgmode/877ccczt83.fsf@gmail.com/
---
lisp/org-colview.el | 20 +++++++++++++-------
testing/lisp/test-org-colview.el | 7 ++++++-
2 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/lisp/org-colview.el b/lisp/org-colview.el
index bc93941e47..a9eb2e0b63 100644
--- a/lisp/org-colview.el
+++ b/lisp/org-colview.el
@@ -935,8 +935,10 @@ details."
(mapcar #'list (org-buffer-property-keys t nil t))
nil nil (nth 0 spec))))
(list prop
- (read-string (format "Column title [%s]: " prop)
- (nth 1 spec))
+ ;; Discard useless whitespace-only titles.
+ (org-string-nw-p
+ (read-string (format "Column title [%s]: " prop)
+ (nth 1 spec)))
;; Use `read-string' instead of `read-number'
;; to allow empty width.
(let ((w (read-string
@@ -1183,14 +1185,18 @@ This function updates
`org-columns-current-fmt-compiled'."
(setq org-columns-current-fmt-compiled nil)
(let ((start 0))
(while (string-match
- "%\\([0-9]+\\)?\\([[:alnum:]_-]+\\)\\(?:(\\([^)]+\\))\\)?\
-\\(?:{\\([^}]+\\)}\\)?\\s-*"
- fmt start)
+ (rx "%"
+ (optional (group (+ digit)))
+ (group (one-or-more (in alnum "_-")))
+ (optional "(" (group (zero-or-more (not (any ")")))) ")")
+ (optional "{" (group (zero-or-more (not (any "}")))) "}")
+ (zero-or-more space))
+ fmt start)
(setq start (match-end 0))
(let* ((width (and (match-end 1) (string-to-number (match-string 1
fmt))))
(prop (match-string-no-properties 2 fmt))
- (title (or (match-string-no-properties 3 fmt) prop))
- (operator (match-string-no-properties 4 fmt)))
+ (title (or (org-string-nw-p (match-string-no-properties 3 fmt))
prop))
+ (operator (org-string-nw-p (match-string-no-properties 4 fmt))))
(push (if (not operator) (list (upcase prop) title width nil nil)
(let (printf)
(when (string-match ";" operator)
diff --git a/testing/lisp/test-org-colview.el b/testing/lisp/test-org-colview.el
index 6b603c31b7..623ee62838 100644
--- a/testing/lisp/test-org-colview.el
+++ b/testing/lisp/test-org-colview.el
@@ -90,7 +90,12 @@
(should
(equal `(("ITEM" "ITEM" nil "+" "%.1f"))
(org-columns-compile-format
- "%ITEM{+;%.1f}"))))
+ "%ITEM{+;%.1f}")))
+ (should
+ ;; Bug https://list.orgmode.org/orgmode/877ccczt83.fsf@gmail.com/
+ (equal '(("ITEM" "ITEM" nil "X" nil))
+ (org-columns-compile-format
+ "%ITEM(){X}"))))
(ert-deftest test-org-colview/substring-below-width ()
"Test `org-columns--truncate-below-width'."
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/org 07dd3bcae6: org-columns-compile-format: Fix regexp,
ELPA Syncer <=