0

How can you keep a heading's main content always visible in org-mode? Perhaps a property that can be set, so that S-tab never collapses it? (Not keeping the children's contents visible, unless they are also set the same way, not impacting e.g. narrowing etc.)

  • 1
    AFAIK, there is no such property: a heading can always be folded. – NickD May 22 at 2:00
1

The built-in which-function-mode normally displays the name of the function the point is currently in for languages like C and Python. But in org-mode it treats the current headline as the "function" name to display.

Turn it on temporarily with M-x which-function-mode or permanently for all org-mode files with (add-to-hook 'org-mode-hook #'which-function-mode) in your .emacs.

By default this displays the name in the mode-line at the bottom of the buffer. I find it gets a little crowded down there, so I add it and the buffer name to the header instead:

(defun header-buffer-name ()
  (let (
        (props (if (powerline-selected-window-active)
                   '(:box "grey80" :background "grey50" :foreground "black")
                 '(:box "grey80" )))
        )
    (propertize (buffer-name) 'font-lock-face props)
    ))

(defun header-function-name ()
  (let (
        (props (if (powerline-selected-window-active)
                   '(:box "Gold1" :background "goldenrod" :foreground "black")
                 '(:box "Gold1" )))
        (func (when which-function-mode (which-function)))
        )
    (if func
        (propertize (which-function) 'font-lock-face props) "")
    ))

(setq-default header-line-format
              '(:eval
                (list
                 (header-buffer-name)
                 " "
                 (header-function-name)
                 )))
| improve this answer | |
  • I'm upvoting this since it's actually incredibly useful (perhaps you or I can ask it as a separate question and mark it as solved there). Sadly however, I don't think it actually answers my intended question here — which is about visibility of code folding! – avv May 23 at 22:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.