summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2016-02-20 23:24:54 +0100
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2016-02-21 00:44:17 +0100
commit15101fe7a65b11f834901bb327dc9cdaac7da7c9 (patch)
treee1ea90de6728f61053f4d22a5e665d4b744799a7
parent58d387661ac38055e0747119496df23310950c7f (diff)
downloadorg-mode-15101fe7a65b11f834901bb327dc9cdaac7da7c9.tar.gz
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.
-rw-r--r--lisp/org-colview.el92
-rw-r--r--lisp/org.el7
-rw-r--r--testing/lisp/test-org-colview.el30
3 files changed, 21 insertions, 108 deletions
diff --git a/lisp/org-colview.el b/lisp/org-colview.el
index 846357b..81d05a6 100644
--- a/lisp/org-colview.el
+++ b/lisp/org-colview.el
@@ -202,22 +202,18 @@ VALUE is the real value of the property, as a string.
This function assumes `org-columns-current-fmt-compiled' is
initialized."
- (pcase (assoc-string property org-columns-current-fmt-compiled t)
- (`(,_ ,_ ,_ ,operator ,printf ,_)
- (cond
- ((and (functionp org-columns-modify-value-for-display-function)
- (funcall
- org-columns-modify-value-for-display-function
- (nth 1 (assoc-string property org-columns-current-fmt-compiled t))
- value)))
- ((equal (upcase property) "ITEM")
- (concat (make-string (1- (org-current-level))
- (if org-hide-leading-stars ?\s ?*))
- "* "
- (org-columns-compact-links value)))
- (printf (org-columns-number-to-string
- (org-columns-string-to-number value operator) operator printf))
- (value)))))
+ (cond
+ ((and (functionp org-columns-modify-value-for-display-function)
+ (funcall
+ org-columns-modify-value-for-display-function
+ (nth 1 (assoc-string property org-columns-current-fmt-compiled t))
+ value)))
+ ((equal (upcase property) "ITEM")
+ (concat (make-string (1- (org-current-level))
+ (if org-hide-leading-stars ?\s ?*))
+ "* "
+ (org-columns-compact-links value)))
+ (value)))
(defun org-columns--collect-values (&optional agenda)
"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))))))
-;;;###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
diff --git a/lisp/org.el b/lisp/org.el
index 58c8f38..6cb13a8 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -4726,7 +4726,6 @@ Otherwise, these types are allowed:
;; 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-compute "org-colview" (property))
@@ -15600,8 +15599,7 @@ strings."
(let ((clocksum (get-text-property (point) :org-clock-minutes)))
(when clocksum
(push (cons "CLOCKSUM"
- (org-columns-number-to-string
- (/ clocksum 60.0) ":"))
+ (org-minutes-to-clocksum-string clocksum))
props)))
(when specific (throw 'exit props)))
(when (or (not specific) (string= specific "CLOCKSUM_T"))
@@ -15609,8 +15607,7 @@ strings."
:org-clock-minutes-today)))
(when clocksumt
(push (cons "CLOCKSUM_T"
- (org-columns-number-to-string
- (/ clocksumt 60.0) ":"))
+ (org-minutes-to-clocksum-string clocksumt))
props)))
(when specific (throw 'exit props)))
(when (or (not specific) (string= specific "ITEM"))
diff --git a/testing/lisp/test-org-colview.el b/testing/lisp/test-org-colview.el
index 8f83873..9dfa352 100644
--- a/testing/lisp/test-org-colview.el
+++ b/testing/lisp/test-org-colview.el
@@ -373,12 +373,8 @@
;; {@min}, {@max} and {@mean} apply to ages.
(should
(equal
- (org-columns-number-to-string
- (float-time
- (time-subtract
- (current-time)
- (apply #'encode-time (org-parse-time-string "<2014-03-04 Tue>"))))
- "@min")
+ (let ((org-columns--time (float-time (current-time))))
+ (org-columns--summary-min-age (list "<2014-03-04 Tue>") nil))
(org-test-with-temp-text
"* H
** S1
@@ -393,12 +389,8 @@
(get-char-property (point) 'org-columns-value-modified))))
(should
(equal
- (org-columns-number-to-string
- (float-time
- (time-subtract
- (current-time)
- (apply #'encode-time (org-parse-time-string "<2012-03-29 Thu>"))))
- "@max")
+ (let ((org-columns--time (float-time (current-time))))
+ (org-columns--summary-max-age (list "<2012-03-29 Thu>") nil))
(org-test-with-temp-text
"* H
** S1
@@ -413,17 +405,9 @@
(get-char-property (point) 'org-columns-value-modified))))
(should
(equal
- (org-columns-number-to-string
- (/ (+ (float-time
- (time-subtract
- (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")
+ (let ((org-columns--time (float-time (current-time))))
+ (org-columns--summary-mean-age
+ (list "<2012-03-29 Thu>" "<2014-03-04 Tue>") nil))
(org-test-with-temp-text
"* H
** S1