Browse Source

org-colview: Allow to force global column view

* lisp/org-colview.el (org-columns): Add new argument to force global
  column view.

* doc/org.texi (Using column view): Document change.
Nicolas Goaziou 9 years ago
parent
commit
23f1119042
3 changed files with 27 additions and 15 deletions
  1. 9 8
      doc/org.texi
  2. 5 1
      etc/ORG-NEWS
  3. 13 6
      lisp/org-colview.el

+ 9 - 8
doc/org.texi

@@ -5703,14 +5703,15 @@ today.
 @orgcmd{C-c C-x C-c,org-columns}
 @orgcmd{C-c C-x C-c,org-columns}
 @vindex org-columns-default-format
 @vindex org-columns-default-format
 Turn on column view.  If the cursor is before the first headline in the file,
 Turn on column view.  If the cursor is before the first headline in the file,
-column view is turned on for the entire file, using the @code{#+COLUMNS}
-definition.  If the cursor is somewhere inside the outline, this command
-searches the hierarchy, up from point, for a @code{:COLUMNS:} property that
-defines a format.  When one is found, the column view table is established
-for the tree starting at the entry that contains the @code{:COLUMNS:}
-property.  If no such property is found, the format is taken from the
-@code{#+COLUMNS} line or from the variable @code{org-columns-default-format},
-and column view is established for the current entry and its subtree.
+or the function called with the universal prefix argument, column view is
+turned on for the entire file, using the @code{#+COLUMNS} definition.  If the
+cursor is somewhere inside the outline, this command searches the hierarchy,
+up from point, for a @code{:COLUMNS:} property that defines a format.  When
+one is found, the column view table is established for the tree starting at
+the entry that contains the @code{:COLUMNS:} property.  If no such property
+is found, the format is taken from the @code{#+COLUMNS} line or from the
+variable @code{org-columns-default-format}, and column view is established
+for the current entry and its subtree.
 @orgcmd{r,org-columns-redo}
 @orgcmd{r,org-columns-redo}
 Recreate the column view, to include recent changes made in the buffer.
 Recreate the column view, to include recent changes made in the buffer.
 @orgcmd{g,org-columns-redo}
 @orgcmd{g,org-columns-redo}

+ 5 - 1
etc/ORG-NEWS

@@ -208,7 +208,11 @@ When defining a "columnview" dynamic block, it is now possible to add
 an :indent parameter, much like the one in the clock table.
 an :indent parameter, much like the one in the clock table.
 
 
 On the other hand, stars no longer appear in an ITEM field.
 On the other hand, stars no longer appear in an ITEM field.
-*** New variable : ~org-agenda-view-columns-initially~
+*** Columns view
+**** ~org-columns~ accepts a prefix argument
+When called with a prefix argument, ~org-columns~ apply to the whole
+buffer unconditionally.
+**** New variable : ~org-agenda-view-columns-initially~
 The variable used to be a ~defvar~, it is now a ~defcustom~.
 The variable used to be a ~defvar~, it is now a ~defcustom~.
 *** Preview LaTeX snippets in buffers not visiting files
 *** Preview LaTeX snippets in buffers not visiting files
 *** New option ~org-attach-commit~
 *** New option ~org-attach-commit~

+ 13 - 6
lisp/org-colview.el

@@ -701,10 +701,18 @@ Also sets `org-columns-top-level-marker' to the new position."
 	  (t (org-back-to-heading) (point))))))
 	  (t (org-back-to-heading) (point))))))
 
 
 ;;;###autoload
 ;;;###autoload
-(defun org-columns (&optional columns-fmt-string)
-  "Turn on column view on an org-mode file.
+(defun org-columns (&optional global columns-fmt-string)
+  "Turn on column view on an Org mode file.
+
+Column view applies to the whole buffer if point is before the
+first headline.  Otherwise, it applies to the first ancestor
+setting \"COLUMNS\" property.  If there is none, it defaults to
+the current headline.  With a \\[universal-argument] prefix \
+argument, turn on column
+view for the whole buffer unconditionally.
+
 When COLUMNS-FMT-STRING is non-nil, use it as the column format."
 When COLUMNS-FMT-STRING is non-nil, use it as the column format."
-  (interactive)
+  (interactive "P")
   (org-columns-remove-overlays)
   (org-columns-remove-overlays)
   (move-marker org-columns-begin-marker (point))
   (move-marker org-columns-begin-marker (point))
   (org-columns-goto-top-level)
   (org-columns-goto-top-level)
@@ -715,9 +723,8 @@ When COLUMNS-FMT-STRING is non-nil, use it as the column format."
   (unless org-columns-inhibit-recalculation (org-columns-compute-all))
   (unless org-columns-inhibit-recalculation (org-columns-compute-all))
   (save-excursion
   (save-excursion
     (save-restriction
     (save-restriction
-      (narrow-to-region
-       (point)
-       (if (org-at-heading-p) (org-end-of-subtree t t) (point-max)))
+      (when (and (not global) (org-at-heading-p))
+	(narrow-to-region (point) (org-end-of-subtree t t)))
       (when (assoc-string "CLOCKSUM" org-columns-current-fmt-compiled t)
       (when (assoc-string "CLOCKSUM" org-columns-current-fmt-compiled t)
 	(org-clock-sum))
 	(org-clock-sum))
       (when (assoc-string "CLOCKSUM_T" org-columns-current-fmt-compiled t)
       (when (assoc-string "CLOCKSUM_T" org-columns-current-fmt-compiled t)