1

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 2

1

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.

1
  • 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
    Commented Feb 25, 2023 at 18:30
1

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:

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.