summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2016-02-04 18:43:08 +0100
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2016-02-04 23:06:03 +0100
commit99697abdb98f67d8fad90a2fd39316ea3c0982dd (patch)
treed5fc512191579da97d77d352403fa2ca08d3c47a
parent00f0c70418ab306a9559a7d73472f3b374925fb8 (diff)
downloadorg-mode-99697abdb98f67d8fad90a2fd39316ea3c0982dd.tar.gz
org-colview: Add :indent parameter
* lisp/org-colview.el (org-dblock-write:columnview): Handle :indent parameter. * doc/org.texi (Capturing column view): Document new feature.
-rw-r--r--doc/org.texi2
-rw-r--r--etc/ORG-NEWS4
-rw-r--r--lisp/org-colview.el37
3 files changed, 35 insertions, 8 deletions
diff --git a/doc/org.texi b/doc/org.texi
index a14917c..606539e 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -5798,6 +5798,8 @@ When set to a number, don't capture entries below this level.
@item :skip-empty-rows
When set to @code{t}, skip rows where the only non-empty specifier of the
column view is @code{ITEM}.
+@item :indent
+When non-@code{nil}, indent each @code{ITEM} field according to its level.
@end table
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 53fd34d..a78ef7f 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -203,7 +203,11 @@ Custom language environments for LaTeX export can now define the
string to be inserted during export, using attributes to indicate the
position of the elements. See variable ~org-latex-custom-lang-environments~
for more details.
+*** Accept ~:indent~ parameter when capturing column view
+When defining a "columnview" dynamic block, it is now possible to add
+an :indent parameter, much like the one in the clock table.
+On the other hand, stars no longer appear in an ITEM field.
** New functions
*** ~org-next-line-empty-p~
It replaces the deprecated ~next~ argument to ~org-previous-line-empty-p~.
diff --git a/lisp/org-colview.el b/lisp/org-colview.el
index 2b1a5c4..dea1294 100644
--- a/lisp/org-colview.el
+++ b/lisp/org-colview.el
@@ -1254,7 +1254,7 @@ PARAMS is a property list of parameters:
(skip-empty-rows (plist-get params :skip-empty-rows))
(columns-fmt (plist-get params :format))
(case-fold-search t)
- tbl id idpos nfields tmp recalc line
+ tbl id idpos nfields recalc line
id-as-string view-file view-pos)
(when (setq id (plist-get params :id))
(setq id-as-string (cond ((numberp id) (number-to-string id))
@@ -1290,19 +1290,40 @@ PARAMS is a property list of parameters:
(move-marker pos nil)
(when tbl
(when (plist-get params :hlines)
- (setq tmp nil)
- (while tbl
- (if (eq (car tbl) 'hline)
- (push (pop tbl) tmp)
- (if (string-match "\\` *\\(\\*+\\)" (caar tbl))
+ (let (tmp)
+ (while tbl
+ (if (eq (car tbl) 'hline)
+ (push (pop tbl) tmp)
+ (when (string-match "\\` *\\(\\*+\\)" (caar tbl))
(if (and (not (eq (car tmp) 'hline))
(or (eq hlines t)
(and (numberp hlines)
(<= (- (match-end 1) (match-beginning 1))
hlines))))
(push 'hline tmp)))
- (push (pop tbl) tmp)))
- (setq tbl (nreverse tmp)))
+ (push (pop tbl) tmp)))
+ (setq tbl (nreverse tmp))))
+ ;; Remove stars. Add indentation entities, if required.
+ (let ((index (cl-position
+ "ITEM"
+ (mapcar #'cadr org-columns-current-fmt-compiled)
+ :test #'equal)))
+ (when index
+ (dolist (row tbl)
+ (unless (eq row 'hline)
+ (let ((item (nth index row)))
+ (setf (nth index row)
+ (replace-regexp-in-string
+ "\\`\\(\\*+\\) +"
+ (if (plist-get params :indent)
+ (lambda (m)
+ (let ((l (org-reduced-level
+ (length (match-string 1 m)))))
+ (if (= l 1) ""
+ (concat "\\\\_"
+ (make-string (* 2 (1- l)) ?\s)))))
+ "")
+ item)))))))
(when vlines
(setq tbl (mapcar (lambda (x)
(if (eq 'hline x) x (cons "" x)))