org-colview: Remove now useless functions

* lisp/org-colview.el (org-columns-number-to-string):
(org-columns-string-to-number): Remove functions.

(org-columns--displayed-value): Apply removal.

* lisp/org.el (org-entry-properties): Ditto.

* testing/lisp/test-org-colview.el (test-org-colview/columns-summary):
  Ditto.
This commit is contained in:
Nicolas Goaziou 2016-02-20 23:24:54 +01:00
parent 58d387661a
commit 15101fe7a6
3 changed files with 21 additions and 108 deletions

View File

@ -202,22 +202,18 @@ VALUE is the real value of the property, as a string.
This function assumes `org-columns-current-fmt-compiled' is This function assumes `org-columns-current-fmt-compiled' is
initialized." initialized."
(pcase (assoc-string property org-columns-current-fmt-compiled t) (cond
(`(,_ ,_ ,_ ,operator ,printf ,_) ((and (functionp org-columns-modify-value-for-display-function)
(cond (funcall
((and (functionp org-columns-modify-value-for-display-function) org-columns-modify-value-for-display-function
(funcall (nth 1 (assoc-string property org-columns-current-fmt-compiled t))
org-columns-modify-value-for-display-function value)))
(nth 1 (assoc-string property org-columns-current-fmt-compiled t)) ((equal (upcase property) "ITEM")
value))) (concat (make-string (1- (org-current-level))
((equal (upcase property) "ITEM") (if org-hide-leading-stars ?\s ?*))
(concat (make-string (1- (org-current-level)) "* "
(if org-hide-leading-stars ?\s ?*)) (org-columns-compact-links value)))
"* " (value)))
(org-columns-compact-links value)))
(printf (org-columns-number-to-string
(org-columns-string-to-number value operator) operator printf))
(value)))))
(defun org-columns--collect-values (&optional agenda) (defun org-columns--collect-values (&optional agenda)
"Collect values for columns on the current line. "Collect values for columns on the current line.
@ -1250,70 +1246,6 @@ and variances (respectively) of the individual estimates."
(format (or printf "%.0f") (- mean sd)) (format (or printf "%.0f") (- mean sd))
(format (or printf "%.0f") (+ mean sd)))))) (format (or printf "%.0f") (+ mean sd))))))
;;;###autoload
(defun org-columns-number-to-string (n operator &optional printf)
"Convert a computed column number N to a string value.
operator is a string describing the summary type. Optional argument
PRINTF, when non-nil, is a format string used to print N."
(cond
((equal operator "est+")
(let ((fmt (or printf "%.0f")))
(mapconcat (lambda (n) (format fmt n)) (if (consp n) n (list n n)) "-")))
((not (numberp n)) "")
((member operator '(":" ":max" ":min" ":mean"))
(org-hours-to-clocksum-string n))
((equal operator "X")
(cond ((= n (floor n)) "[X]")
((> n 1.) "[-]")
(t "[ ]")))
((member operator '("X/" "X%"))
(let* ((n1 (floor n))
(n2 (+ (floor (+ .5 (* 1000000 (- n n1)))) n1)))
(cond ((not (equal operator "X%")) (format "[%d/%d]" n1 n2))
((or (= n1 0) (= n2 0)) "[0%]")
(t (format "[%d%%]" (round (* 100.0 n1) n2))))))
(printf (format printf n))
((equal operator "$") (format "%.2f" n))
((member operator '("@min" "@max" "@mean"))
(format-seconds "%dd %.2hh %mm %ss" n))
(t (number-to-string n))))
(defun org-columns-string-to-number (s operator)
"Convert a column value S to a number.
OPERATOR is a string describing the summary type."
(cond
((not s) nil)
((member operator '("@min" "@max" "@mean"))
(cond
((string= s "") org-columns--time)
((string-match "\\`\\(?: *\\([0-9]+\\)d\\)?\\(?: *\\([0-9]+\\)h\\)?\
\\(?: *\\([0-9]+\\)m\\)?\\(?: *\\([0-9]+\\)s\\)?\\'" s)
(let ((d (if (match-end 1) (string-to-number (match-string 1 s)) 0))
(h (if (match-end 2) (string-to-number (match-string 2 s)) 0))
(m (if (match-end 3) (string-to-number (match-string 3 s)) 0))
(s (if (match-end 4) (string-to-number (match-string 4 s)) 0)))
(+ (* 60 (+ (* 60 (+ (* 24 d) h)) m)) s)))
(t
(- org-columns--time
(float-time (apply #'encode-time (org-parse-time-string s)))))))
((string-match-p ":" s) ;Interpret HH:MM:SS.
(let ((sum 0.0))
(dolist (n (nreverse (split-string s ":")) sum)
(setq sum (+ (string-to-number n) (/ sum 60))))))
((member operator '("X" "X/" "X%"))
(if (equal s "[X]") 1. 0.000001))
((equal operator "est+")
(if (not (string-match "\\(.*\\)-\\(.*\\)" s))
(string-to-number s)
(list (string-to-number (match-string 1 s))
(string-to-number (match-string 2 s)))))
((string-match-p org-columns--duration-re s)
(let ((s (concat "0:" (org-duration-string-to-minutes s t)))
(sum 0.0))
(dolist (n (nreverse (split-string s ":")) sum)
(setq sum (+ (string-to-number n) (/ sum 60))))))
(t (string-to-number s))))
;;; Dynamic block for Column view ;;; Dynamic block for Column view

View File

@ -4726,7 +4726,6 @@ Otherwise, these types are allowed:
;; Declare Column View Code ;; Declare Column View Code
(declare-function org-columns-number-to-string "org-colview" (n operator &optional printf))
(declare-function org-columns-get-format-and-top-level "org-colview" ()) (declare-function org-columns-get-format-and-top-level "org-colview" ())
(declare-function org-columns-compute "org-colview" (property)) (declare-function org-columns-compute "org-colview" (property))
@ -15600,8 +15599,7 @@ strings."
(let ((clocksum (get-text-property (point) :org-clock-minutes))) (let ((clocksum (get-text-property (point) :org-clock-minutes)))
(when clocksum (when clocksum
(push (cons "CLOCKSUM" (push (cons "CLOCKSUM"
(org-columns-number-to-string (org-minutes-to-clocksum-string clocksum))
(/ clocksum 60.0) ":"))
props))) props)))
(when specific (throw 'exit props))) (when specific (throw 'exit props)))
(when (or (not specific) (string= specific "CLOCKSUM_T")) (when (or (not specific) (string= specific "CLOCKSUM_T"))
@ -15609,8 +15607,7 @@ strings."
:org-clock-minutes-today))) :org-clock-minutes-today)))
(when clocksumt (when clocksumt
(push (cons "CLOCKSUM_T" (push (cons "CLOCKSUM_T"
(org-columns-number-to-string (org-minutes-to-clocksum-string clocksumt))
(/ clocksumt 60.0) ":"))
props))) props)))
(when specific (throw 'exit props))) (when specific (throw 'exit props)))
(when (or (not specific) (string= specific "ITEM")) (when (or (not specific) (string= specific "ITEM"))

View File

@ -373,12 +373,8 @@
;; {@min}, {@max} and {@mean} apply to ages. ;; {@min}, {@max} and {@mean} apply to ages.
(should (should
(equal (equal
(org-columns-number-to-string (let ((org-columns--time (float-time (current-time))))
(float-time (org-columns--summary-min-age (list "<2014-03-04 Tue>") nil))
(time-subtract
(current-time)
(apply #'encode-time (org-parse-time-string "<2014-03-04 Tue>"))))
"@min")
(org-test-with-temp-text (org-test-with-temp-text
"* H "* H
** S1 ** S1
@ -393,12 +389,8 @@
(get-char-property (point) 'org-columns-value-modified)))) (get-char-property (point) 'org-columns-value-modified))))
(should (should
(equal (equal
(org-columns-number-to-string (let ((org-columns--time (float-time (current-time))))
(float-time (org-columns--summary-max-age (list "<2012-03-29 Thu>") nil))
(time-subtract
(current-time)
(apply #'encode-time (org-parse-time-string "<2012-03-29 Thu>"))))
"@max")
(org-test-with-temp-text (org-test-with-temp-text
"* H "* H
** S1 ** S1
@ -413,17 +405,9 @@
(get-char-property (point) 'org-columns-value-modified)))) (get-char-property (point) 'org-columns-value-modified))))
(should (should
(equal (equal
(org-columns-number-to-string (let ((org-columns--time (float-time (current-time))))
(/ (+ (float-time (org-columns--summary-mean-age
(time-subtract (list "<2012-03-29 Thu>" "<2014-03-04 Tue>") nil))
(current-time)
(apply #'encode-time (org-parse-time-string "<2014-03-04 Tue>"))))
(float-time
(time-subtract
(current-time)
(apply #'encode-time (org-parse-time-string "<2012-03-29 Thu>")))))
2)
"@mean")
(org-test-with-temp-text (org-test-with-temp-text
"* H "* H
** S1 ** S1