Is it possible to set #+RESULTS section for specific source blocks to folded? Just like you would add visibility folded property to a heading.
2 Answers
TAB (bound to org-cycle) will fold #+RESULTS interactively.
From lisp, you can use the functions org-babel-hide-result-toggle-maybe, org-babel-hide-result-toggle, org-babel-result-hide-all to hide results. The toggles are idempotent, so another call will show the results. The inverse of the last is org-babel-result-show-all. Check their docstrings for details.
I don't think there is a way to control that out of the box using properties.
- Thanks for the reply. I should have indicated in the questions that I was aware of these options. It's a pity that there is no visibility option for this.Arktik– Arktik2023-02-25 18:30:52 +00:00Commented Feb 25, 2023 at 18:30
I suppose this is a workaround. I am fairly happy with it. I use named source blocks anyway, so one can use the results block name to fold it on file opening.
(defun ib//org-babel-fold-named-results (block-names) "" (save-excursion (dolist (name block-names) (org-babel-goto-named-result name) (end-of-line) (if (not (overlays-at (point))) (org-babel-hide-result-toggle))))) For example, the following folds a source block called "test" in the org file.
#+name: test #+begin_src python print(3.) #+end_src #+RESULTS: test : 3.0 # Local Variables: # eval: (ib//org-babel-fold-named-results '("test")) # End: