[oni-org] Automatically hide source code blocks marked as hidden
Source: https://emacs.stackexchange.com/questions/44914/choose-individual-startup-visibility-of-org-modes-source-blocks
This commit is contained in:
parent
4ab9d3c4b3
commit
e54b77c8d7
1 changed files with 18 additions and 1 deletions
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
;; Author: Tom Willemse <tom@ryuslash.org>
|
;; Author: Tom Willemse <tom@ryuslash.org>
|
||||||
;; Keywords: local
|
;; Keywords: local
|
||||||
;; Version: 2023.0530.174013
|
;; Version: 2023.0601.224638
|
||||||
;; Package-Requires: (oni-yasnippet oni-alert oni-hydra org org-bullets org-edna diminish all-the-icons olivetti form-feed org-pretty-table)
|
;; Package-Requires: (oni-yasnippet oni-alert oni-hydra org org-bullets org-edna diminish all-the-icons olivetti form-feed org-pretty-table)
|
||||||
|
|
||||||
;; This program is free software; you can redistribute it and/or modify
|
;; This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -1210,5 +1210,22 @@ otherwise return ‘oni-org-link-nonexistent-file’."
|
||||||
|
|
||||||
(org-link-set-parameters "file" :face #'oni-org-file-face-selector)
|
(org-link-set-parameters "file" :face #'oni-org-file-face-selector)
|
||||||
|
|
||||||
|
;;; Automatically hide code blocks that specify they should be hidden.
|
||||||
|
;; Inspired by
|
||||||
|
;; https://emacs.stackexchange.com/questions/44914/choose-individual-startup-visibility-of-org-modes-source-blocks
|
||||||
|
|
||||||
|
(defun oni-org-hide-hidden-code-blocks ()
|
||||||
|
"Hide any code blocks that have been marked as hidden.
|
||||||
|
This is done by adding a ‘:hidden t’ header argument to the code block."
|
||||||
|
(interactive)
|
||||||
|
(org-block-map
|
||||||
|
(lambda ()
|
||||||
|
(let ((element (org-element-at-point)))
|
||||||
|
(when (and (equal (org-element-type element) 'src-block)
|
||||||
|
(map-elt (nth 2 (org-babel-get-src-block-info)) :hidden))
|
||||||
|
(org-fold-hide-block-toggle t nil element))))))
|
||||||
|
|
||||||
|
(add-hook 'org-mode-hook #'oni-org-hide-hidden-code-blocks)
|
||||||
|
|
||||||
(provide 'oni-org)
|
(provide 'oni-org)
|
||||||
;;; oni-org.el ends here
|
;;; oni-org.el ends here
|
||||||
|
|
Loading…
Reference in a new issue