Merge branch 'maint'
This commit is contained in:
commit
d71e708fe3
|
@ -223,21 +223,32 @@ See `org-columns-summary-types' for details.")
|
||||||
|
|
||||||
(defun org-columns--displayed-value (spec value)
|
(defun org-columns--displayed-value (spec value)
|
||||||
"Return displayed value for specification SPEC in current entry.
|
"Return displayed value for specification SPEC in current entry.
|
||||||
|
|
||||||
SPEC is a column format specification as stored in
|
SPEC is a column format specification as stored in
|
||||||
`org-columns-current-fmt-compiled'. VALUE is the real value to
|
`org-columns-current-fmt-compiled'. VALUE is the real value to
|
||||||
display, as a string."
|
display, as a string."
|
||||||
(cond
|
(or (and (functionp org-columns-modify-value-for-display-function)
|
||||||
((and (functionp org-columns-modify-value-for-display-function)
|
(funcall org-columns-modify-value-for-display-function
|
||||||
(funcall org-columns-modify-value-for-display-function
|
(nth 1 spec) ;column name
|
||||||
(nth 1 spec)
|
value))
|
||||||
value)))
|
(pcase spec
|
||||||
((equal (car spec) "ITEM")
|
(`("ITEM" . ,_)
|
||||||
(concat (make-string (1- (org-current-level))
|
(concat (make-string (1- (org-current-level))
|
||||||
(if org-hide-leading-stars ?\s ?*))
|
(if org-hide-leading-stars ?\s ?*))
|
||||||
"* "
|
"* "
|
||||||
(org-columns-compact-links value)))
|
(org-columns-compact-links value)))
|
||||||
(value)))
|
(`(,_ ,_ ,_ ,_ nil) value)
|
||||||
|
;; If PRINTF is set, and we are displaying a number, obey to
|
||||||
|
;; it. Otherwise, raise an error.
|
||||||
|
(`(,_ ,name ,_ ,_ ,printf)
|
||||||
|
(when (or (not (string-match-p "[0-9]" value))
|
||||||
|
(and (string-match-p "[1-9]" value)
|
||||||
|
(= 0 (string-to-number value))))
|
||||||
|
(user-error "Invalid value: %S. \
|
||||||
|
Format string in operator implies column %S only contains numbers"
|
||||||
|
value
|
||||||
|
name))
|
||||||
|
(format printf (string-to-number value)))
|
||||||
|
(_ (error "Invalid column specification format: %S" spec)))))
|
||||||
|
|
||||||
(defun org-columns--collect-values (&optional compiled-fmt)
|
(defun org-columns--collect-values (&optional compiled-fmt)
|
||||||
"Collect values for columns on the current line.
|
"Collect values for columns on the current line.
|
||||||
|
|
|
@ -212,6 +212,27 @@
|
||||||
:END:"
|
:END:"
|
||||||
(let ((org-columns-default-format "%A{$}")) (org-columns))
|
(let ((org-columns-default-format "%A{$}")) (org-columns))
|
||||||
(get-char-property (point) 'org-columns-value-modified))))
|
(get-char-property (point) 'org-columns-value-modified))))
|
||||||
|
;; Obey to format string even in leaf values.
|
||||||
|
(should
|
||||||
|
(equal
|
||||||
|
"1.0"
|
||||||
|
(org-test-with-temp-text
|
||||||
|
"* H
|
||||||
|
:PROPERTIES:
|
||||||
|
:A: 1
|
||||||
|
:END:"
|
||||||
|
(let ((org-columns-default-format "%A{+;%.1f}")) (org-columns))
|
||||||
|
(get-char-property (point) 'org-columns-value-modified))))
|
||||||
|
;; Raise an error when format strings are applied to non-numbers.
|
||||||
|
(should-error
|
||||||
|
(org-test-with-temp-text
|
||||||
|
"* H
|
||||||
|
** S1
|
||||||
|
:PROPERTIES:
|
||||||
|
:A: foo
|
||||||
|
:END:"
|
||||||
|
(let ((org-columns-default-format "%A{+;%.2f}")) (org-columns))
|
||||||
|
(get-char-property (point) 'org-columns-value-modified)))
|
||||||
;; {:} sums times. Plain numbers are hours.
|
;; {:} sums times. Plain numbers are hours.
|
||||||
(should
|
(should
|
||||||
(equal
|
(equal
|
||||||
|
|
Loading…
Reference in New Issue