Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

show org-mode outline up to a certain heading level

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.

like image 283
daniel kullmann Avatar asked Jun 01 '11 08:06

daniel kullmann


People also ask

How do you use Org mode tags?

Org mode has extensive support for tags. Every headline can contain a list of tags; they occur at the end of the headline. Tags are normal words containing letters, numbers, ' _ ', and ' @ '. Tags must be preceded and followed by a single colon, e.g., ' :work: '.

What does Org mode do?

Org Mode (also: org-mode; /ˈɔːrɡ moʊd/) is a document editing, formatting, and organizing mode, designed for notes, planning, and authoring within the free software text editor Emacs.


4 Answers

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...)

like image 149
Whil Avatar answered Oct 11 '22 02:10

Whil


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)))
like image 33
daniel kullmann Avatar answered Oct 11 '22 02:10

daniel kullmann


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))

```

like image 33
Att Righ Avatar answered Oct 11 '22 01:10

Att Righ


I am way late to the party, but let us add a simple way for posterity. Simply use Cycle Global Visibility (<backtab>). If your headings are open, it will close them. However, if you apply it repeatedly with all headings collapsed, they will open to the level you want.

I use it from the keyboard by <SHIFT>+<TAB>. You can also find it in the Org menu (in Emacs) under Show/Hide -> Cycle Global Visibility ()

like image 28
Pablo A Perez-Fernandez Avatar answered Oct 11 '22 01:10

Pablo A Perez-Fernandez