Preface
When you work a lot with source blocks in Org Mode, the file can quickly become super long. For that reason, it's often very helpful to have certain source blocks start in a folded state. For this, I found the following function that automatically hides source blocks which have the keyword :hidden in the source block.
Example
(defun individual-visibility-source-blocks ()
"Fold some blocks in the current buffer."
(interactive)
(org-show-block-all)
(org-block-map
(lambda ()
(let ((case-fold-search t))
(when (and
(save-excursion
(beginning-of-line 1)
(looking-at org-block-regexp))
(cl-assoc
':hidden
(cl-third
(org-babel-get-src-block-info))))
(org-hide-block-toggle))))))
(add-hook
'org-mode-hook
(function individual-visibility-source-blocks))print("hello world")References
org babel - Choose individual startup visibility of org-mode's source blocks