Emacs org-mode: How can I reset everything except the current header?

I use org-mode to handle my tasks and projects in multiple files.

On the weekly agenda, you can navigate to the location of each TODO entry using <TAB> or <RET> . If the target file was not previously opened, it is loaded, the cursor is positioned on the correct header, and the entire document is expanded, including mailboxes.

I would really like to see only a rare tree with everything except the correct addition of the title (the visibility of the subtree does not matter).

You can collapse the whole tree cyclically using global visibility using Cu <TAB , but then I need to find the title again.

I know that I can hide the rest by narrowing the buffer, as described here: Emacs, how can I display only the current task and hide others in org-mode? but then I lose context (parent title, easy access to siblings) and the boxes are still open.

Ideally, I would like to have a team that shows the following:

  • Top Level Headers
  • Current title and all its parents to the top level
  • Current kids title

Edit:

The small modified version of user3173715 functions seems to do the trick:

 (defun org-show-current-heading-tidily () "Show next entry, keeping other entries closed." (if (save-excursion (end-of-line) (outline-invisible-p)) (progn (org-show-entry) (show-children)) (outline-back-to-heading) (unless (and (bolp) (org-on-heading-p)) (org-up-heading-safe) (hide-subtree) (error "Boundary reached")) (org-overview) (org-reveal t) (org-show-entry) (show-children))) 
+6
source share
3 answers

I am not very sure that this is your requirement (I just think that it is suitable for your question), but I use these two functions with a lot of fun, linking them in the org-mode speed command. You can find these two functions in org-mode hackers . I changed them a bit to complete my tasks.

Two functions support:

  • Expand all headers except the current heading
  • Move the current heading to the top of the screen for a wider reading area.

To accomplish (2), you need (setq recenter-positions '(top bottom)) , there might be some better solutions, but I did not dig into it.

 (defun ded/org-show-next-heading-tidily () "Show next entry, keeping other entries closed." (if (save-excursion (end-of-line) (outline-invisible-p)) (progn (org-show-entry) (show-children)) (outline-next-heading) (unless (and (bolp) (org-on-heading-p)) (org-up-heading-safe) (hide-subtree) (error "Boundary reached")) (org-overview) (org-reveal t) (org-show-entry) (recenter-top-bottom) (show-children) (recenter-top-bottom))) (defun ded/org-show-previous-heading-tidily () "Show previous entry, keeping other entries closed." (let ((pos (point))) (outline-previous-heading) (unless (and (< (point) pos) (bolp) (org-on-heading-p)) (goto-char pos) (hide-subtree) (error "Boundary reached")) (org-overview) (org-reveal t) (org-show-entry) (recenter-top-bottom) (show-children) (recenter-top-bottom))) 

And you can associate them with the org-mode speed key using j and l , then you can use j and l to control the folding of the headers when your cursor is at the beginning of the headers.

 (setq org-speed-commands-user '(("j" . ded/org-show-next-heading-tidily) ("l" . ded/org-show-previous-heading-tidily)))) 

It is ideal for reading files in org-mode, greetings!

+2
source

This is based on the response in the wording in the current question.

If helping someone: When I tried to associate the above with a hotkey, I always got an error, commandp incorrectly argued for something ... It turned out that I needed to add a (interactive) flag to make it work. The following is an example of a function related to M - =

 (defun org-show-current-heading-tidily () (interactive) ;Inteactive "Show next entry, keeping other entries closed." (if (save-excursion (end-of-line) (outline-invisible-p)) (progn (org-show-entry) (show-children)) (outline-back-to-heading) (unless (and (bolp) (org-on-heading-p)) (org-up-heading-safe) (hide-subtree) (error "Boundary reached")) (org-overview) (org-reveal t) (org-show-entry) (show-children))) (global-set-key "\M-=" 'org-show-current-heading-tidily) 

@ Patrick.B thanks for editing!

+4
source

Check org startup options ( customize-group > org-startup ), such as org-startup-folded or org-agenda-inhibit-startup (others have already mentioned this), and set the options to display only the folded view. Org mode options such as #+STARTUP are discussed here .

You may notice that everything adds up when you go to the agenda, even the parents of the active element may not be visible. Then you can make the context (parents, children, next brother) visible with org-reveal ( Cc Cr according to manual )

0
source

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


All Articles