Hi Vitaly,

Vitaly <jau...@gmail.com> writes:

> Why not handling this somewhere in "+STARTUP: content N" or anywhere
> similar? Since org-mode handles arguments for org-global-cycle, why
> not handle them on startup?

The following patch handle content-2 and content-3 keywords, and allow
`org-startup-folded' to be set to an integer.

I don't like content-1 content-2, this is dirty.

But maybe we can simply allow integers for `org-startup-folded' and
then the user could `org-startup-folded' as a local variable.

Let me know what you think,

diff --git a/lisp/org.el b/lisp/org.el
index 1e22699..d446b66 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -587,6 +587,8 @@ the following lines anywhere in the buffer:
    #+STARTUP: fold              (or `overview', this is equivalent)
    #+STARTUP: nofold            (or `showall', this is equivalent)
    #+STARTUP: content
+   #+STARTUP: content-2         (up to headlines of level 2)
+   #+STARTUP: content-3         (up to headlines of level 3)
    #+STARTUP: showeverything
 
 By default, this option is ignored when Org opens agenda files
@@ -597,6 +599,7 @@ option, set `org-agenda-inhibit-startup' to nil."
 	  (const :tag "nofold: show all" nil)
 	  (const :tag "fold: overview" t)
 	  (const :tag "content: all headlines" content)
+	  (integerp :tag "content: all headlines up to N level" 2)
 	  (const :tag "show everything, even drawers" showeverything)))
 
 (defcustom org-startup-truncated t
@@ -4632,6 +4635,8 @@ After a match, the following groups carry important information:
     ("showall" org-startup-folded nil)
     ("showeverything" org-startup-folded showeverything)
     ("content" org-startup-folded content)
+    ("content-2" org-startup-folded 2)
+    ("content-3" org-startup-folded 3)
     ("indent" org-startup-indented t)
     ("noindent" org-startup-indented nil)
     ("hidestars" org-hide-leading-stars t)
@@ -6660,6 +6665,8 @@ With a numeric prefix, show all headlines up to that level."
   (cond
    ((eq org-startup-folded t)
     (org-cycle '(4)))
+   ((integerp org-startup-folded)
+    (org-global-cycle org-startup-folded))
    ((eq org-startup-folded 'content)
     (let ((this-command 'org-cycle) (last-command 'org-cycle))
       (org-cycle '(4)) (org-cycle '(4)))))
-- 
 Bastien

Reply via email to