diff options
author | mfrasca <mario@anche.no> | 2020-06-14 10:52:41 -0500 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2020-06-28 08:45:11 +0200 |
commit | 0c1740c919d7e239f8a6bea84a437c0f12ae9b84 (patch) | |
tree | c1a027334e6b6f064275c8bfaff003f0526480be | |
parent | 07ae5456b1736451c803d9f5fb9f2389a49f7767 (diff) | |
download | org-mode-0c1740c919d7e239f8a6bea84a437c0f12ae9b84.tar.gz |
org-plot: reducing complexity of test
* lisp/org-plot.el (org-plot/gnuplot): readability of test, looking
for some non satisfying elements.
-rw-r--r-- | lisp/org-plot.el | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/lisp/org-plot.el b/lisp/org-plot.el index a23195d..bf81d3c 100644 --- a/lisp/org-plot.el +++ b/lisp/org-plot.el @@ -309,26 +309,20 @@ line directly before or after the table." (`grid (let ((y-labels (org-plot/gnuplot-to-grid-data table data-file params))) (when y-labels (plist-put params :ylabels y-labels))))) - ;; Check for timestamp ind column. - (let ((ind (1- (plist-get params :ind)))) - (when (and (>= ind 0) (eq '2d (plist-get params :plot-type))) - (if (= (length - (delq 0 (mapcar - (lambda (el) - (if (string-match org-ts-regexp3 el) 0 1)) - (mapcar (lambda (row) (nth ind row)) table)))) - 0) - (plist-put params :timeind t) - ;; Check for text ind column. - (if (or (string= (plist-get params :with) "hist") - (> (length - (delq 0 (mapcar - (lambda (el) - (if (string-match org-table-number-regexp el) - 0 1)) - (mapcar (lambda (row) (nth ind row)) table)))) - 0)) - (plist-put params :textind t))))) + ;; Check type of ind column (timestamp? text?) + (when (eq `2d (plist-get params :plot-type)) + (let* ((ind (1- (plist-get params :ind))) + (ind-column (mapcar (lambda (row) (nth ind row)) table))) + (cond ((< ind 0) nil) ; ind is implicit + ((cl-every (lambda (el) + (string-match org-ts-regexp3 el)) + ind-column) + (plist-put params :timeind t)) ; ind holds timestamps + ((or (string= (plist-get params :with) "hist") + (cl-notevery (lambda (el) + (string-match org-table-number-regexp el)) + ind-column)) + (plist-put params :textind t))))) ; ind holds text ;; Write script. (with-temp-buffer (if (plist-get params :script) ; user script |