Emacs Org-Mode: how to collapse a block without blocking the header?

I know that I can go to the block header and collapse / expand by pressing the TAB key. However, suppose I'm inside a block that has hundreds of lines, and I just want to collapse the current block without going to the block title - is there a keyboard shortcut that can do this? Or is there an elisp function that does this, so that I can associate some shortcut with this function?

+4
source share
3 answers

Create a key binding that performs the following function:

(defun zin/org-cycle-current-headline () (interactive) (outline-previous-heading) (org-cycle)) 

This will return to the previous header and the next loop. Since the title is already open, it will close it. It also puts a dot at the beginning of the title.

If you complete the two commands in (save-excursion ) , it will save the point, however, this can lead to the entry of information inside the ellipsis without realizing it. Alternatively, you can change the command to invoke a non-interactive form:

 (defun zin/org-cycle-current-headline () (interactive) (org-cycle-internal-local)) 

This is equivalent to the above with (save-excursion ) .

+4
source

Cc Cp will lead you to the header, TAB will discard the cards. You can create a keyboard macro for this or an equivalent ELISP:

 (defun up-n-fold () (interactive) (progn (outline-previous-visible-heading 1) (org-cycle))) 

Edit: adjusted Cc p for Cc Cp, as indicated by many below. Thanks!

+3
source

I am not sure if such a function exists, but it is not difficult to create it. Just replace the following keystrokes with functions: CMr ^ * Enter tab .

0
source

Source: https://habr.com/ru/post/1387604/


All Articles