3

After I upgraded to Org Mode 9.4.5, I learned about the startup option hideblocks, but it won't work as advertised for me.

OK, when I start emacs with the flag -Q, it did, so I went hunting for culprits in my .emacs. All suspicious-looking settings and packages have been removed, but hideblocks still doesn't work.

Oddly enough, when I visit a test file with #+STARTUP: hideblocks, the variable org-hide-block-startup do indeed change from nil, which is default, to t. Despite this, the block remains unfolded!

I can make all blocks fold on start-up, if I set org-hide-block-startup with a local variables section at the end of the file, but I consider that to be an ugly, last resort solution.

Is there a smart way of tracking down when and where the hideblock setting is reversed, intercepted, toggled, or whatever happens?


Addendum April 4:

Since writing the above, I stumbled upon one additional interesting symptom. When I was led astray with the theory that my Org Mode installation was somehow faulty, I took a look at the installation instructions in the info documentation. Among other things, it says the following about an org mode installation with elpa:

Important: You need to do this in a session where no ‘.org’ file has been visited, i.e., where no Org built-in function have been loaded. Otherwise autoload Org functions will mess up the installation.

So I did M-x list-packages, threw out org mode, restarted Emacs, installed org mode anew, and visited my test file.

Lo and behold, my block was folded at start-up.

However, the effect was short-lasting, and trying to open the same file later did not work as expected.

5
  • 2
    "All suspicious-looking settings and packages have been removed". Clearly "suspicious-looking" isn't enough. If you see no problem with emacs -Q the bisect your init file till you've narrowed it down to just what's causing the problem. You can use comment-region to bisect it.
    – Drew
    Commented Apr 2, 2021 at 18:13
  • How do you set org-hide-block-startup in the first place? Did you customize the variable?
    – NickD
    Commented Apr 2, 2021 at 21:44
  • @Drew: I suppose there is no way around that kind of elbow grease in the end. @NickD: Before I upgraded Org Mode I did nothing. I didn't even know I could control this behaviour at all. This time, I have tried to obtain per file control, with the help of #+STARTUP hideblocks. (As I wrote above, setting org-hide-block-startup in a local variables section at the end of the file, the blocks start folded. I do not like this workaround, however.) Commented Apr 4, 2021 at 14:55
  • 1
    Elbow grease? Bisecting is a binary search - very quick. Use comment-region to comment out 1/2, then 3/4, 7/8, 15/16, 31/32,... till you find exactly what, in your init file, is the culprit. Plain C-u with comment-region uncomments.
    – Drew
    Commented Apr 4, 2021 at 15:19
  • Right now, I have started wondering if the fact that my Org Mode is "shadowing a built-in package" could have something to do with my problems. I am the kind of lazy guy who has installed Emacs with a Debian package, including an older version of Org Mode. On top of (?) this, I have slapped a newer version of Org Mode with the help of elpa. Before I write another word on this, I will do my bisection homework... Commented Apr 6, 2021 at 12:17

1 Answer 1

2
+50

The solution is much simpler than suggested by my own theories (see above). It turns out that the intended effect of #+STARTUP: hideblocks is overruled by the initial visibility setting #+STARTUP: showeverything, which is now default.

So, by combining #+STARTUP: hideblocks with #+STARTUP: showall or (equivalently) #+STARTUP: nohide, the desired effect can be obtained.

N.B. "nohide" is hiding pretty well in the info documentation, but can be found if one looks at the documentation for the variable org-startup-folded.

2
  • Here's a recent discussion of exactly this question on the Org mode ML.
    – NickD
    Commented Apr 9, 2021 at 15:52
  • Should I have #+STARTUP: folded showall then?
    – alper
    Commented Apr 24, 2023 at 11:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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