Added support for :maxlevel and :skip-empty-rows parameters to columnview dblock.

This commit is contained in:
Bastien Guerry 2008-03-01 09:58:17 +00:00
parent 96e96fa684
commit f247d16417
3 changed files with 73 additions and 40 deletions

View File

@ -1,4 +1,15 @@
2008-02-29 Bastien Guerry <Bastien.Guerry@ens.fr>
2008-03-01 Bastien Guerry <bzg@altern.org>
* org.texi (Capturing Column View): Documented new parameters for
the column view dynamic block: :maxlevel and :skip-empty-rows.
2008-03-01 Bastien Guerry <bzg@altern.org>
* org.el (org-dblock-write:columnview, org-columns-capture-view):
Added support for :maxlevel and :skip-empty-rows as argument for
the columnview dynamic block.
2008-02-29 Bastien Guerry <bzg@altern.org>
* org-irc.el: Require 'cl and 'erc. Added dynamically scoped
variables.
@ -88,7 +99,7 @@
customizable.
(org-default-extensions): New option.
2008-02-26 Bastien Guerry <Bastien.Guerry@ens.fr>
2008-02-26 Bastien Guerry <bzg@altern.org>
* org.el (org-agenda-to-appt): New argument `refresh' let the user
delete previous appointments stored in `appt-time-msg-list'.
@ -448,7 +459,7 @@ Installed as 5.19a
(Quoted examples): New section.
(Enhancing text): New verbatim environments.
2007-11-04 Bastien Guerry <Bastien.Guerry@ens.fr>
2007-11-04 Bastien Guerry <bzg@altern.org>
* org.el (org-export-with-special-strings): New option.
(org-export-html-convert-special-strings): New function.
@ -656,7 +667,7 @@ Installed as 5.11
* org.texi (Appointment reminders): New section.
2007-10-05 Bastien Guerry <Bastien.Guerry@ens.fr>
2007-10-05 Bastien Guerry <bzg@altern.org>
* org-export-latex.el (org-export-latex-protect-string):
Renaming of `org-latex-protect'.
@ -700,7 +711,7 @@ Installed as 5.10
(org-indent-item): Fix bullet type before thinking about
renumbering.
2007-09-26 Bastien Guerry <Bastien.Guerry@ens.fr>
2007-09-26 Bastien Guerry <bzg@altern.org>
* org-export-latex.el (org-export-latex-emphasis-alist):
Each list of the alist now requires three elements.

32
org.el
View File

@ -17431,15 +17431,24 @@ printf a printf format for computed values"
;;; Dynamic block for Column view
(defun org-columns-capture-view ()
"Get the column view of the current buffer and return it as a list.
The list will contains the title row and all other rows. Each row is
a list of fields."
(defun org-columns-capture-view (&optional maxlevel skip-empty-rows)
"Get the column view of the current buffer or subtree.
The first optional argument MAXLEVEL sets the level limit. A
second optional argument SKIP-EMPTY-ROWS tells whether to skip
empty rows, an empty row being one where all the column view
specifiers except ITEM are empty. This function returns a list
containing the title row and all other rows. Each row is a list
of fields."
(save-excursion
(let* ((title (mapcar 'cadr org-columns-current-fmt-compiled))
(n (length title)) row tbl)
(goto-char (point-min))
(while (re-search-forward "^\\*+ " nil t)
(while (and (re-search-forward "^\\(\\*+\\) " nil t)
(or (null maxlevel)
(>= maxlevel
(if org-odd-levels-only
(/ (1+ (length (match-string 1))) 2)
(length (match-string 1))))))
(when (get-char-property (match-beginning 0) 'org-columns-key)
(setq row nil)
(loop for i from 0 to (1- n) do
@ -17448,7 +17457,9 @@ a list of fields."
"")
row))
(setq row (nreverse row))
(push row tbl)))
(unless (and skip-empty-rows
(eq 1 (length (delete "" (delete-dups row)))))
(push row tbl))))
(append (list title 'hline) (nreverse tbl)))))
(defun org-dblock-write:columnview (params)
@ -17463,10 +17474,15 @@ PARAMS is a property list of parameters:
to column view).
:hlines When t, insert a hline before each item. When a number, insert
a hline before each level <= that number.
:vlines When t, make each column a colgroup to enforce vertical lines."
:vlines When t, make each column a colgroup to enforce vertical lines.
:maxlevel When set to a number, don't capture headlines below this level.
:skip-empty-rows
When t, skip rows where all specifiers other than ITEM are empty."
(let ((pos (move-marker (make-marker) (point)))
(hlines (plist-get params :hlines))
(vlines (plist-get params :vlines))
(maxlevel (plist-get params :maxlevel))
(skip-empty-rows (plist-get params :skip-empty-rows))
tbl id idpos nfields tmp)
(save-excursion
(save-restriction
@ -17478,7 +17494,7 @@ PARAMS is a property list of parameters:
(goto-char idpos))
(t (error "Cannot find entry with :ID: %s" id))))
(org-columns)
(setq tbl (org-columns-capture-view))
(setq tbl (org-columns-capture-view maxlevel skip-empty-rows))
(setq nfields (length (car tbl)))
(org-columns-quit)))
(goto-char pos)

View File

@ -3774,8 +3774,8 @@ values.
The first column, @samp{%25ITEM}, means the first 25 characters of the
item itself, i.e. of the headline. You probably always should start the
column definition with the ITEM specifier. The other specifiers create
columns @samp{Owner} with a list of names as allowed values, for
column definition with the @samp{ITEM} specifier. The other specifiers
create columns @samp{Owner} with a list of names as allowed values, for
@samp{Status} with four different possible values, and for a checkbox
field @samp{Approved}. When no width is given after the @samp{%}
character, the column will be exactly as wide as it needs to be in order
@ -3859,8 +3859,8 @@ Delete the current column.
Since column view is just an overlay over a buffer, it cannot be
exported or printed directly. If you want to capture a column view, use
the dynamic block (@pxref{Dynamic blocks}). The frame of this block
looks like this:
ths @code{columnview} dynamic block (@pxref{Dynamic blocks}). The frame
of this block looks like this:
@example
* The column view
@ -3888,6 +3888,12 @@ When @code{t}, insert a hline after every line. When a number N, insert
a hline before each headline with level @code{<= N}.
@item :vlines
When set to @code{t}, enforce column groups to get vertical lines.
@item :maxlevel
When set to a number, don't capture entries below this level.
@item :skip-empty-rows
When set to @code{t}, skip row where the only non-empty specifier of the
column view is @code{ITEM}.
@end table
@noindent