2

I have an org table with has a NAME label like:

#+NAME: TBL
| Foo | Bar |

In the past I have always been able to expand and collapse the whole table by cycling using TAB on the #+NAME line.

However in the latest version of emacs (26.1), this doesn't seem to work.

If I replace #+NAME: TBL with #+RESULTS: TBL it works fine. Pressing TAB on the RESULTS line hides the table, pressing it again reveals the table once more.

Is there an org setting to define which which blocks can be expanded/folded, or some other requirement I'm missing?

Thanks

  • Would you consider using drawers and keeping your tables inside them? – dangom Dec 2 '18 at 11:34
1

I don't know if the foldable elements are documented elsewhere, but the "folding" is done in the functions org-hide-block-toggle-maybe and org-hide-block-toggle (the former just calls the latter and ignores errors). The list is as follows:

(center-block comment-block dynamic-block example-block
             export-block quote-block special-block
             src-block verse-block)

Instead of using #+RESULT for this (which is specifically meant for results of source blocks), I would use an example block:

#+BEGIN_EXAMPLE
#+NAME: TBL
| Foo | Bar |
#+END_EXAMPLE

I tried to find an org version that actually folds #+NAME (or #+TABLE) elements and I couldn't come up with one, although I went back five years to version 8.1 (of course, I could have made a mistake). Are you sure that this was ever the case? If so, what version of org-mode (M-x org-version will tell) was that?

UPDATE: org-hide-block-toggle is used for blocks, but not for results. Results are handled through the org-tab-first-hook variable: ob-core.el adds org-babel-hide-result-toggle-maybe to the hook and that is what folds/unfolds results. AFAICT however, that is not used for #+NAME folding - still looking.

  • Thanks for this - strangely the version it works on is "Org-mode version 8.2.10 (release_8.2.10 @ /usr/share/emacs/24.5/lisp/org/)" - I suspect it's the default Org for Ubuntu 16.04. Which suggests that there is some setting being pulled in from elsewhere. I'll double check all my settings again. – Phil Oct 2 '18 at 8:39
  • Interestingly on my version of 8.2 M-x org-hide-block-toggle returns Not looking at a source block for both NAME and RESULTS. In both cases TAB expands and folds. – Phil Oct 2 '18 at 8:53
  • Final test - If I run as emacs -q and thus load no plugins or config, the feature still exists in Ubuntu 16.04's build of emacs 24.5.1/Org 8.2.10, but not in my source build of 26.1/Org 9.1.9. So it looks like it was a core change to emacs or org rather than config or settings? – Phil Oct 2 '18 at 9:04
  • ... or I made a mistake. I'll check again when I have some time. – NickD Oct 2 '18 at 12:15
  • "Interestingly on my version of 8.2 M-x org-hide-block-toggle returns Not looking at a source block for both NAME and RESULTS. In both cases TAB expands and folds" - you are right: see UPDATE. – NickD Oct 2 '18 at 16: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.