实际上,一些代码块太长并且占用太多空间。
默认情况下,希望显示所有代码块,仅在设置要隐藏的代码块时隐藏。
假设org文件中存在需要隐藏的代码块,例如:
#+BEGIN_SRC emacs-lisp :hidden
;;; org babel - Choose individual startup visibility of org-mode's source blocks - Emacs Stack Exchange: https://emacs.stackexchange.com/questions/44914/choose-individual-startup-visibility-of-org-modes-source-blocks#answer-44923
(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))
#+END_SRC
当使用命令“individual-visibility-source-blocks”时,除了上述代码块之外将显示所有代码块。