瀏覽代碼

New startup options, #+startup: show<n>levels

* lisp/org.el (org-startup-folded, org-startup-options)
  (org-set-startup-visibility): Add new startup options
Gustav Wikström 4 年之前
父節點
當前提交
a71ac14e46
共有 4 個文件被更改,包括 33 次插入2 次删除
  1. 2 2
      doc/org-guide.org
  2. 8 0
      doc/org-manual.org
  3. 6 0
      etc/ORG-NEWS
  4. 17 0
      lisp/org.el

+ 2 - 2
doc/org-guide.org

@@ -169,8 +169,8 @@ Org uses just two commands, bound to {{{kbd(TAB)}}} and
 When Emacs first visits an Org file, the global state is set to
 When Emacs first visits an Org file, the global state is set to
 OVERVIEW, i.e., only the top level headlines are visible.  This can be
 OVERVIEW, i.e., only the top level headlines are visible.  This can be
 configured through the variable ~org-startup-folded~, or on a per-file
 configured through the variable ~org-startup-folded~, or on a per-file
-basis by adding a =STARTUP= keyword to =overview=, =content=, or
-=showall=, like this:
+basis by adding a =STARTUP= keyword to =overview=, =content=,
+=showall=, =showeverything= or =show<n>levels= (n = 2..5) like this:
 
 
 : #+STARTUP: content
 : #+STARTUP: content
 
 

+ 8 - 0
doc/org-manual.org

@@ -578,6 +578,10 @@ buffer:
 ,#+STARTUP: overview
 ,#+STARTUP: overview
 ,#+STARTUP: content
 ,#+STARTUP: content
 ,#+STARTUP: showall
 ,#+STARTUP: showall
+,#+STARTUP: show2levels
+,#+STARTUP: show3levels
+,#+STARTUP: show4levels
+,#+STARTUP: show5levels
 ,#+STARTUP: showeverything
 ,#+STARTUP: showeverything
 #+end_example
 #+end_example
 
 
@@ -18960,6 +18964,10 @@ changes.
   | =overview=       | Top-level headlines only.  |
   | =overview=       | Top-level headlines only.  |
   | =content=        | All headlines.             |
   | =content=        | All headlines.             |
   | =showall=        | No folding on any entry.   |
   | =showall=        | No folding on any entry.   |
+  | =show2levels=    | Headline levels 1-2.       |
+  | =show3levels=    | Headline levels 1-3.       |
+  | =show4levels=    | Headline levels 1-4.       |
+  | =show5levels=    | Headline levels 1-5.       |
   | =showeverything= | Show even drawer contents. |
   | =showeverything= | Show even drawer contents. |
 
 
   #+vindex: org-startup-indented
   #+vindex: org-startup-indented

+ 6 - 0
etc/ORG-NEWS

@@ -112,6 +112,12 @@ package, to convert pandas Dataframes into orgmode tables:
 | 2 | 3 | 6 |
 | 2 | 3 | 6 |
 #+end_src
 #+end_src
 
 
+*** New startup options =#+startup: show<n>levels=
+
+These startup options complement the existing =overview=, =content=,
+=showall=, =showeverything= with a way to start the document with n
+levels shown, where n goes from 2 to 5.
+
 *** New =u= table formula flag to enable Calc units simplification mode
 *** New =u= table formula flag to enable Calc units simplification mode
 
 
 A new =u= mode flag for Calc formulas in Org tables has been added to
 A new =u= mode flag for Calc formulas in Org tables has been added to

+ 17 - 0
lisp/org.el

@@ -939,6 +939,7 @@ the following lines anywhere in the buffer:
    #+STARTUP: fold              (or `overview', this is equivalent)
    #+STARTUP: fold              (or `overview', this is equivalent)
    #+STARTUP: nofold            (or `showall', this is equivalent)
    #+STARTUP: nofold            (or `showall', this is equivalent)
    #+STARTUP: content
    #+STARTUP: content
+   #+STARTUP: show<n>levels (<n> = 2..5)
    #+STARTUP: showeverything
    #+STARTUP: showeverything
 
 
 Set `org-agenda-inhibit-startup' to a non-nil value if you want
 Set `org-agenda-inhibit-startup' to a non-nil value if you want
@@ -949,6 +950,10 @@ time."
   :type '(choice
   :type '(choice
 	  (const :tag "nofold: show all" nil)
 	  (const :tag "nofold: show all" nil)
 	  (const :tag "fold: overview" t)
 	  (const :tag "fold: overview" t)
+	  (const :tag "fold: show two levels" show2levels)
+	  (const :tag "fold: show three levels" show3levels)
+	  (const :tag "fold: show four levels" show4evels)
+	  (const :tag "fold: show five levels" show5levels)
 	  (const :tag "content: all headlines" content)
 	  (const :tag "content: all headlines" content)
 	  (const :tag "show everything, even drawers" showeverything)))
 	  (const :tag "show everything, even drawers" showeverything)))
 
 
@@ -4121,6 +4126,10 @@ After a match, the following groups carry important information:
     ("overview" org-startup-folded t)
     ("overview" org-startup-folded t)
     ("nofold" org-startup-folded nil)
     ("nofold" org-startup-folded nil)
     ("showall" org-startup-folded nil)
     ("showall" org-startup-folded nil)
+    ("show2levels" org-startup-folded show2levels)
+    ("show3levels" org-startup-folded show3levels)
+    ("show4levels" org-startup-folded show4levels)
+    ("show5levels" org-startup-folded show5levels)
     ("showeverything" org-startup-folded showeverything)
     ("showeverything" org-startup-folded showeverything)
     ("content" org-startup-folded content)
     ("content" org-startup-folded content)
     ("indent" org-startup-indented t)
     ("indent" org-startup-indented t)
@@ -6553,6 +6562,14 @@ With a numeric prefix, show all headlines up to that level."
     (org-overview))
     (org-overview))
    ((eq org-startup-folded 'content)
    ((eq org-startup-folded 'content)
     (org-content))
     (org-content))
+   ((eq org-startup-folded 'show2levels)
+    (org-content 2))
+   ((eq org-startup-folded 'show3levels)
+    (org-content 3))
+   ((eq org-startup-folded 'show4levels)
+    (org-content 4))
+   ((eq org-startup-folded 'show5levels)
+    (org-content 5))
    ((or (eq org-startup-folded 'showeverything)
    ((or (eq org-startup-folded 'showeverything)
 	(eq org-startup-folded nil))
 	(eq org-startup-folded nil))
     (org-show-all)))
     (org-show-all)))