emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Orgmode] First column of tables from sub headings and drawyers


From: Bastien
Subject: Re: [Orgmode] First column of tables from sub headings and drawyers
Date: Fri, 29 Feb 2008 20:19:38 +0000
User-agent: Gnus/5.110007 (No Gnus v0.7) Emacs/23.0.60 (gnu/linux)

"Antano Solar" <address@hidden> writes:

> There is one more things I would like to know.
> When I do C-c C-x r it is generating the column view from the second level and
> all levels deeper than that.
> How do I restrict the rows generated only to the sub heading with the
> properties defined.

I'm not 100% sure to understand what you mean.  

If you mean that you want to assign a limit to the number of levels
displayed in the captured column view, it is currently not possible.  

But I think it's a good idea.

Here is a patch against latest CVS that does it.

Carsten, what do you think?  If you think it's useful, do you think the
limit parameter be interactively set when `C-c C-x r'?

diff --git a/org.el b/org.el
index 8b57f7b..7463fbe 100644
--- a/org.el
+++ b/org.el
@@ -17430,15 +17430,20 @@ 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 limit)
+  "Get the column view of the current buffer or subtree.
+An optional argument LIMIT sets the level depth limit.
+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 limit)
+                     (>= limit (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
@@ -17466,6 +17471,7 @@ PARAMS is a property list of parameters:
   (let ((pos (move-marker (make-marker) (point)))
        (hlines (plist-get params :hlines))
        (vlines (plist-get params :vlines))
+       (limit (plist-get params :limit))
        tbl id idpos nfields tmp)
     (save-excursion
       (save-restriction
@@ -17477,7 +17483,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 limit))
        (setq nfields (length (car tbl)))
        (org-columns-quit)))
     (goto-char pos)
-- 
Bastien

reply via email to

[Prev in Thread] Current Thread [Next in Thread]