>From f561ed24863ee0b501c538ffa565e290c0eeb99e Mon Sep 17 00:00:00 2001 From: Marco Wahl Date: Thu, 11 Jul 2019 12:21:12 +0200 Subject: [PATCH 4/4] Make show-children applicable to whole file * lisp/org.el (org-ctrl-c-tab): Extend and refactor. --- lisp/org.el | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index fecfc451c..de5b5855f 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -18070,14 +18070,20 @@ context. See the individual commands for more information." (interactive) (org-return t)) -(defun org-ctrl-c-tab (&optional _arg) +(defun org-ctrl-c-tab (&optional arg) "Toggle columns width in a table, or show children. Call `org-table-toggle-column-width' if point is in a table. -Otherwise, call `org-show-children'." +Otherwise, call `org-show-children'. ARG is the level to hide." (interactive "p") - (call-interactively - (if (org-at-table-p) #'org-table-toggle-column-width - #'org-show-children))) + (if (org-at-table-p) + (call-interactively #'org-table-toggle-column-width) + (if (org-before-first-heading-p) + (progn + (org-flag-above-first-heading) + (outline-hide-sublevels (or arg 1)) + (goto-char (point-min))) + (outline-hide-subtree) + (org-show-children arg)))) (defun org-ctrl-c-star () "Compute table, or change heading status of lines. -- 2.22.0