show org-mode outline up to a certain heading leve

2019-02-08 10:16发布

I'm making an outline for my thesis using org-mode, and I'd like to show all headings up to a certain level (e.g. all level-1 and level-2 headings).

I haven't found anything about that in the org-mode manual. Cycling shows either only level-1 headings, or all headings, which is too much information in my outline right now.

Thanks,

daniel.

Update: I found a workaround for his: set the variable org-cycle-max-level. This is a global setting, though.

3条回答
家丑人穷心不美
2楼-- · 2019-02-08 10:39

I found a solution that suits me: The command org-content shows the folder hierarchy, and giving it a numeric argument does exactly what I want: limit the maximum level shown. In my example, I wanted to show 2 levels, so I can do C-2 M-x org-content <RET>.

I also added my own command to my .emacs init file, binding that command to C-c m

(defun org-show-two-levels ()
  (interactive)
  (org-content 2))

(add-hook 'org-mode-hook
  (lambda ()
    (define-key org-mode-map "\C-cm" 'org-show-two-levels)))
查看更多
Explosion°爆炸
3楼-- · 2019-02-08 10:39

If the prefix arguments from M. Kullman's answer take too much mental capacity for you (a limited resource when you are thinking hard about something else at the same time) then you can use the following functions to expand contract headings

(defvar hf-org-depth-point nil)
(defvar hf-org-depth-depth nil)

(defun hf-org-depth-increase ()
   (interactive)
   (hf-org-depth-incr 1))

(defun hf-org-depth-decrease ()
    (interactive)
    (hf-org-depth-incr -1))

(defun hf-org-depth-incr (incr)
    (when (not (equal (point) hf-org-depth-point))
        (setq hf-org-depth-point nil)
        (setq hf-org-depth-depth 0))a
    (setq hf-org-depth-point (point))
    (setq hf-org-depth-depth (max (+ hf-org-depth-depth incr) 0))
    (hide-subtree)
    (show-children hf-org-depth-depth))

```

查看更多
淡お忘
4楼-- · 2019-02-08 10:50

Just stumbled on this question. One year later but what the heck.. There are commands for this that allows you to show headings to a certain level.

One command is C-<n> C-c tab will show subheadings up to level <n> (<n>=1,2,3...).

Another command is C-<n> S-tab which will operate on the whole buffer. It shows all headings up to level <n> (<n>=1,2,3...)

查看更多
登录 后发表回答