org-startup-folded: Make values consistent with #+STARTUP keyword

* lisp/org.el (org-startup-folded): Document all the allowed values in
the docstring.  Allow symbols named the same as #+STARTUP option.
(org-startup-options): Allow `org-startup-folded' to have values
corresponding to the corresponding #+STARTUP options.
This commit is contained in:
Ihor Radchenko 2024-02-11 13:40:17 +01:00
parent d3a1394270
commit c2a58bbd53
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
2 changed files with 31 additions and 8 deletions

View File

@ -615,7 +615,7 @@ With a numeric prefix, show all headlines up to that level."
(cond (cond
;; `fold' is technically not allowed value, but it is often ;; `fold' is technically not allowed value, but it is often
;; intuitively tried by users by analogy with #+STARTUP: fold. ;; intuitively tried by users by analogy with #+STARTUP: fold.
((memq org-startup-folded '(t fold)) ((memq org-startup-folded '(t fold overview))
(org-cycle-overview)) (org-cycle-overview))
((eq org-startup-folded 'content) ((eq org-startup-folded 'content)
(org-cycle-content)) (org-cycle-content))

View File

@ -1005,7 +1005,30 @@ equivalent option for agenda views."
:group 'org) :group 'org)
(defcustom org-startup-folded 'showeverything (defcustom org-startup-folded 'showeverything
"Non-nil means entering Org mode will switch to OVERVIEW. "Initial folding state of headings when entering Org mode.
Allowed values are:
symbol `nofold'
Do not fold headings.
symbol `fold'
Fold everything, leaving only top-level headings visible.
symbol `content'
Leave all the headings and sub-headings visible, but hide their
text. This is an equivalent of table of contents.
symbol `show2levels', `show3levels', `show4levels', `show5levels'
Show headings up to Nth level.
symbol `showeverything' (default)
Start Org mode in fully unfolded state. Unlike all other allowed
values, this value prevents drawers, blocks, and archived subtrees
from being folded even when `org-cycle-hide-block-startup',
`org-cycle-open-archived-trees', or `org-cycle-hide-drawer-startup'
are non-nil. Per-subtree visibility settings (see manual node
`(org)Initial visibility)') are also ignored.
This can also be configured on a per-file basis by adding one of This can also be configured on a per-file basis by adding one of
the following lines anywhere in the buffer: the following lines anywhere in the buffer:
@ -1022,8 +1045,8 @@ time."
:group 'org-startup :group 'org-startup
:package-version '(Org . "9.4") :package-version '(Org . "9.4")
:type '(choice :type '(choice
(const :tag "nofold: show all" nil) (const :tag "nofold: show all" nofold)
(const :tag "fold: overview" t) (const :tag "fold: overview" fold)
(const :tag "fold: show two levels" show2levels) (const :tag "fold: show two levels" show2levels)
(const :tag "fold: show three levels" show3levels) (const :tag "fold: show three levels" show3levels)
(const :tag "fold: show four levels" show4evels) (const :tag "fold: show four levels" show4evels)
@ -4067,10 +4090,10 @@ After a match, the following groups carry important information:
4 the second time, if it is a range.") 4 the second time, if it is a range.")
(defconst org-startup-options (defconst org-startup-options
'(("fold" org-startup-folded t) '(("fold" org-startup-folded fold)
("overview" org-startup-folded t) ("overview" org-startup-folded overview)
("nofold" org-startup-folded nil) ("nofold" org-startup-folded nofold)
("showall" org-startup-folded nil) ("showall" org-startup-folded showall)
("show2levels" org-startup-folded show2levels) ("show2levels" org-startup-folded show2levels)
("show3levels" org-startup-folded show3levels) ("show3levels" org-startup-folded show3levels)
("show4levels" org-startup-folded show4levels) ("show4levels" org-startup-folded show4levels)