org: Improve consistency for org-ctrl-c-tab and children folding

* lisp/org.el (org-ctrl-c-tab): Don't move point when acting on
  outline level 0 (which is before first heading). This is consistent to
  the behavior for level > 0. And refactor some. And correct the
  docstring.
This commit is contained in:
Marco Wahl 2020-07-07 00:39:35 +02:00
parent 8b92bcd827
commit ab864a29be
1 changed files with 12 additions and 10 deletions

View File

@ -17802,17 +17802,19 @@ When inserting a newline, indent the new line if
(defun org-ctrl-c-tab (&optional arg) (defun org-ctrl-c-tab (&optional arg)
"Toggle columns width in a table, or show children. "Toggle columns width in a table, or show children.
Call `org-table-toggle-column-width' if point is in a table. Call `org-table-toggle-column-width' if point is in a table.
Otherwise, call `org-show-children'. ARG is the level to hide." Otherwise provide a compact view of the children. ARG is the
level to hide."
(interactive "p") (interactive "p")
(if (org-at-table-p) (cond
(call-interactively #'org-table-toggle-column-width) ((org-at-table-p)
(if (org-before-first-heading-p) (call-interactively #'org-table-toggle-column-width))
(progn ((org-before-first-heading-p)
(org-flag-above-first-heading) (save-excursion
(outline-hide-sublevels (or arg 1)) (org-flag-above-first-heading)
(goto-char (point-min))) (outline-hide-sublevels (or arg 1))))
(outline-hide-subtree) (t
(org-show-children arg)))) (outline-hide-subtree)
(org-show-children arg))))
(defun org-ctrl-c-star () (defun org-ctrl-c-star ()
"Compute table, or change heading status of lines. "Compute table, or change heading status of lines.