From 23f111904207c9a489245ad66df16af031079978 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sun, 14 Feb 2016 22:25:49 +0100 Subject: [PATCH] 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. --- doc/org.texi | 17 +++++++++-------- etc/ORG-NEWS | 6 +++++- lisp/org-colview.el | 19 +++++++++++++------ 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/doc/org.texi b/doc/org.texi index a5c4e67f6..ed84836e7 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -5703,14 +5703,15 @@ today. @orgcmd{C-c C-x C-c,org-columns} @vindex org-columns-default-format 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} Recreate the column view, to include recent changes made in the buffer. @orgcmd{g,org-columns-redo} diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 47c5479fb..90923c886 100644 --- a/etc/ORG-NEWS +++ b/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. 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~. *** Preview LaTeX snippets in buffers not visiting files *** New option ~org-attach-commit~ diff --git a/lisp/org-colview.el b/lisp/org-colview.el index 6e1956bf2..f5de4d09d 100644 --- a/lisp/org-colview.el +++ b/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)))))) ;;;###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." - (interactive) + (interactive "P") (org-columns-remove-overlays) (move-marker org-columns-begin-marker (point)) (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)) (save-excursion (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) (org-clock-sum)) (when (assoc-string "CLOCKSUM_T" org-columns-current-fmt-compiled t)