1

Sometimes when I close all the folds in org mode one of my headings becomes invisible.

It depends on where my cursor is at the time of the fold. But despite my testing I don't know a hard fast rule for where the cursor needs to be to reproduce it. Although it occurs often enough that I can reproduce it by blind guessing a cursor point and calling C-u C-u org-cycle-folds.

This is an example of an invisible heading:

invisible heading

This is what the org document should look like:

org document without invisible heading

To fix this I have looked into redraw-display and redraw-frame.

(add-advice #'org-cycle-folds :after (lambda () (redraw-display))

Unfortunately and unusually this did not work. Or, at least, when the display was redrawn it was redrawn with the hidden fold.

The only solution that seems to work is placing my cursor on the heading.

Based on this I made a hack that seems to work (I haven't been able to reproduce the problem again).

It is

(advice-add #'org-cycle :after (lambda (&rest rest)
                                 (next-line) (previous-line)))

;; I also tested this for evil and it works the same way
(advice-add #'evil-close-folds :after
            (lambda ()
              (next-line) (previous-line)))

Interestingly, If I do (save-excursion (next-line) (previous-line)) (which I tried because I'm paranoid and think I could end up on different original point somehow), it doesn't work.

Of course, this not the best solution. What confuses me the most is what exactly triggers the heading to display correctly. I know it's associated with moving the point into the heading, which is why I move to the next line and back again.

Any ideas as to what's actually responsible for this heading hiding and how I can resolve it in a more direct way (rather than the hacky way I have)?

  • I have seen this happen, but like you, I don't know how to reproduce it, so I have not pursued it. It's also been easy to "fix": if you move the cursor a bit and do a C-l, the heading comes back. But you probably should report it to the org-mode mailing list, particularly if you can find a way to reliably reproduce it. – NickD Mar 22 '18 at 17:42
  • Yes, it's definitely not a major problem. But it annoys me as it can be a bit jarring and unexpected when I see it happen. I will take your advice and report it to the mailing list. Additionally, I'll play with it a bit more to see if I can determine how to reproduce it reliably as well. – Aquaactress Mar 23 '18 at 1:53

Your Answer

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

Browse other questions tagged or ask your own question.