From 244182c74fe103e59ad3f52df37ef08c01871e95 Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Sun, 13 Aug 2023 16:34:30 -0400 Subject: Org settings --- emacs/.config/emacs-kj/lisp/kj-org.el | 75 +++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) (limited to 'emacs/.config') diff --git a/emacs/.config/emacs-kj/lisp/kj-org.el b/emacs/.config/emacs-kj/lisp/kj-org.el index 9636df6..7ad7030 100644 --- a/emacs/.config/emacs-kj/lisp/kj-org.el +++ b/emacs/.config/emacs-kj/lisp/kj-org.el @@ -41,6 +41,81 @@ (defvar kj/publish-directory "/ssh:orbekk@dragon.orbekk.com:/storage/srv/kj.orbekk.com") (add-to-list 'org-modules 'org-habit) +(defvar org-publish-project-alist) +(defun kj/find-agenda-files-containing-tag (tag) + (setq org-agenda-archives-mode nil) + (let* ((org-agenda-archives-mode nil) + (candidates (org-agenda-files nil 'ifmode)) + (matcher (cdr (org-make-tags-matcher tag))) + (files)) + ;; (message "Results:") + (dolist (file candidates files) + (org-check-agenda-file file) + (with-current-buffer (org-get-agenda-file-buffer file) + ;; (message "%S" (org-scan-tags 'agenda matcher nil)) + (when (org-scan-tags 'agenda matcher nil) + (push file files)))))) + +(defun kj/org-publish (&optional project force) + (interactive) + (setq project (or project "all")) + (setq force (or force current-prefix-arg)) + (setq org-agenda-files (list org-roam-directory)) + (let* ((static-files-re (string-join '("css" "txt" "jpg" "png" "gif" "svg") "\\|")) + (files-to-include (kj/find-agenda-files-containing-tag kj/publish-tag)) + ;; Disable org babel exports during publish entirely to speed up publish. + ;; This messes up babel output handling. + ;; (org-export-use-babel nil) + (org-babel-default-header-args + (kj/assq-replace '((:exports . "both") + (:eval . "never-export")) + org-babel-default-header-args)) + (org-publish-project-alist + `( + ("static" + :base-directory ,(concat org-roam-directory "/static") + :base-extension ,static-files-re + :recursive t + :publishing-directory ,(concat kj/publish-directory "/static") + :publishing-function org-publish-attachment) + ("source" + :base-directory ,org-roam-directory + :base-extension "org" + :exclude ".*" + :include ,files-to-include + :recursive t + :publishing-directory ,kj/publish-directory + :publishing-function org-publish-attachment) + ("html" + :base-directory ,org-roam-directory + :base-extension "org" + :recursive t + :exclude ".*" + :include ,files-to-include + :publishing-directory ,kj/publish-directory + :publishing-function org-html-publish-to-html + + :with-broken-links t + :with-toc nil + :with-latex t + :with-drawers t + :with-title t + :section-numbers nil + + ;; HTML options + :html-toplevel-hlevel 2 + :html-preamble "" + :html-postamble "" + :html-html5-fancy t + :html-doctype "html5" + :html-head "" + :html-head-include-scripts nil + :html-head-include-default-style nil + :html-container article) + + ("all" :components ("static" "source" "html"))))) + + (org-publish project force))) ; (setq org-appear-autolinks t) ; (use-package! org-appear ; :hook (org-mode . org-appear-mode)) -- cgit v1.2.3