Files
org_web/lisp/sidenotes.el
2026-03-20 23:54:11 +00:00

27 lines
979 B
EmacsLisp
Executable File

(defun z/no-sidenotes-file-p (file)
"Return non-nil if FILE should be rendered without sidenotes.
A file is no-sidenotes if:
- It has a #+NO_SIDENOTES: keyword, or
- Its FILETAGS contain :NO_SIDENOTES: or :KANBAN:, or
- Any top-level heading contains \"KANBAN\"."
(when (file-exists-p file)
(with-temp-buffer
(insert-file-contents file)
(org-mode)
(let* ((case-fold-search t)
(keywords (org-collect-keywords
'("NO_SIDENOTES" "FILETAGS")))
(flag (cadr (assoc "NO_SIDENOTES" keywords)))
(filetags (cadr (assoc "FILETAGS" keywords))))
(or
(and flag (string-match-p "\\S-" flag))
(and filetags
(string-match-p
":\\(NO_SIDENOTES\\|KANBAN\\):"
(concat ":" filetags ":")))
(save-excursion
(goto-char (point-min))
(re-search-forward "^\\*+ .*KANBAN.*" nil t)))))))
(provide 'sidenotes)