diff options
Diffstat (limited to 'config/emacs.org')
| -rw-r--r-- | config/emacs.org | 379 |
1 files changed, 247 insertions, 132 deletions
diff --git a/config/emacs.org b/config/emacs.org index 99aff38..446643c 100644 --- a/config/emacs.org +++ b/config/emacs.org @@ -125,6 +125,64 @@ syntax elsewhere. Generally, however, these are all unordered and not dependent ;; same as above (defun remove-annoying-pairing () (remove-hook 'post-self-insert-hook #'yaml-electric-bar-and-angle t)) + +;; taken from blog https://writepermission.com/org-blogging-rss-feed.html +(defun rp/org-rss-publish-to-rss (plist filename pub-dir) + "Publish RSS with PLIST, only when FILENAME is 'rss.org'. +PUB-DIR is when the output will be placed." + (if (equal "rss.org" (file-name-nondirectory filename)) + (org-rss-publish-to-rss plist filename pub-dir))) + +(defun format-rss-feed-entry (entry style project) + "Format ENTRY for the RSS feed. +ENTRY is a file name. STYLE is either 'list' or 'tree'. +PROJECT is the current project." + (cond ((not (directory-name-p entry)) + (let* ((file (org-publish--expand-file-name entry project)) + (title (org-publish-find-title entry project)) + (date (format-time-string "%Y-%m-%d" (org-publish-find-date entry project))) + (link (concat (file-name-sans-extension entry) ".html"))) + (with-temp-buffer + (org-mode) + + (insert (format "* [[file:%s][%s]]\n" file title)) + (org-set-property "RSS_PERMALINK" link) + (org-set-property "PUBDATE" date) + (insert-file-contents file) + (buffer-string)))) + ((eq style 'tree) + ;; Return only last subdir. + (file-name-nondirectory (directory-file-name entry))) + (t entry))) + +(defun format-rss-feed (title list) + "Generate the rss.org file from the formatted list." + (with-temp-buffer + (org-mode) + (insert "#+TITLE: " title "\n\n") + (insert (org-list-to-generic list '(:istart "" :icount "" :isep "\n"))) + (buffer-substring-no-properties (point-min) (point-max)))) + +(try (require 'url-util)) + +(defun org-sitemap-format-xml (title list) + "Format the sitemap list as a standard XML file." + (concat "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n" + (org-list-to-generic list '(:splice t :item-bullet "" :item-wrap nil)) + "\n</urlset>\n")) + +(defun org-sitemap-format-entry-xml (entry style project) + "Format ENTRY in PROJECT for XML sitemap." + (let* ((file (file-name-sans-extension entry)) + (link (url-encode-url (concat "https://ret2pop.net/" file ".html"))) + (date (org-publish-find-date entry project)) + (lastmod (format-time-string "%Y-%m-%d" date))) + (format "<url>\n <loc>%s</loc>\n <lastmod>%s</lastmod>\n</url>" link lastmod))) + +(defun rp/org-sitemap-publish-function (plist filename pub-dir) + (when (string-equal (file-name-nondirectory filename) "sitemap.xml") + (org-publish-attachment plist filename pub-dir))) #+end_src ** Random Packages These are packages that I require in order to write some scripts in emacs-lisp. @@ -148,6 +206,7 @@ Emacs is self documenting, after all! (use-package emacs :custom ;; global defaults + (enable-local-variables :all "don't emit local variable warnings when publishing") (indent-tabs-mode nil "no real tabs, only spaces") (tab-width 2 "tab show as 2 spaces") (standard-indent 2 "base indentation") @@ -206,24 +265,26 @@ of course Emacs was not designed to be fully imperative. ** Org Mode This is my org mode configuration, which also configures latex. #+begin_src emacs-lisp :tangle ../nix/init.el - (use-package org - :demand t - :after (f s dash nix-mode) - :hook - ((org-mode . remove-annoying-pairing)) - :custom - ;; Fix terrible indentation issues - (org-edit-src-content-indentation 0) - (org-src-tab-acts-natively t) - (org-src-preserve-indentation t) +(use-package org + :demand t + :after (f s dash nix-mode) + :hook + ((org-mode . remove-annoying-pairing)) + :custom + (org-export-allow-bind-keywords t "don't emit warnings") + (org-confirm-babel-evaluate nil "I want to evaluate stuff when publishing") + ;; Fix terrible indentation issues + (org-edit-src-content-indentation 0) + (org-src-tab-acts-natively t) + (org-src-preserve-indentation t) - (TeX-PDF-mode t) - (org-confirm-babel-evaluate nil "Don't ask to evaluate code block") - (org-export-with-broken-links t "publish website even with broken links") - (org-src-fontify-natively t "Colors!") + (TeX-PDF-mode t) + (org-confirm-babel-evaluate nil "Don't ask to evaluate code block") + (org-export-with-broken-links t "publish website even with broken links") + (org-src-fontify-natively t "Colors!") - ;; org-latex - (org-format-latex-header "\\documentclass{article} \ + ;; org-latex + (org-format-latex-header "\\documentclass{article} \ \\usepackage[usenames]{color} \ [DEFAULT-PACKAGES] \ [PACKAGES] \ @@ -243,132 +304,186 @@ This is my org mode configuration, which also configures latex. \\addtolength{\\topmargin}{-2.54cm} \ \\usepackage{amsmath} \ ") - (org-preview-latex-image-directory (expand-file-name "~/.cache/ltximg/") "don't use weird cache location") - (org-latex-preview-ltxpng-directory (expand-file-name "~/.cache/ltximg/") "don't use weird cache location") - (org-latex-to-html-convert-command "printf '%%s' %i | pandoc -f latex -t html --mathml | tr -d '\\n' | sed -e 's/^<p>//' -e 's/<\\/p>$//'" "latex to MathML with special character handling") - (org-latex-to-mathml-convert-command "printf '%%s' %i | pandoc -f latex -t html --mathml | tr -d '\\n' | sed -e 's/^<p>//' -e 's/<\\/p>$//'" "latex to MathML with special character handling") + (org-preview-latex-image-directory (expand-file-name "~/.cache/ltximg/") "don't use weird cache location") + (org-latex-preview-ltxpng-directory (expand-file-name "~/.cache/ltximg/") "don't use weird cache location") + (org-latex-to-html-convert-command "printf '%%s' %i | pandoc -f latex -t html --mathml | tr -d '\\n' | sed -e 's/^<p>//' -e 's/<\\/p>$//'" "latex to MathML with special character handling") + (org-latex-to-mathml-convert-command "printf '%%s' %i | pandoc -f latex -t html --mathml | tr -d '\\n' | sed -e 's/^<p>//' -e 's/<\\/p>$//'" "latex to MathML with special character handling") + + (TeX-engine 'xetex "set xelatex as default engine") + (preview-default-option-list '("displaymath" "textmath" "graphics") "preview latex") + ;; (preview-image-type 'png "Use PNGs") + (org-preview-latex-default-process 'dvipng) + (org-format-latex-options + '(:foreground default + :background default + :scale 2 + :html-foreground "Black" + :html-background "Transparent" + :html-scale 1.5 + :matchers ("begin" "$1" "$" "$$" "\\(" "\\[")) "space latex better") + (org-return-follows-link t "be able to follow links without mouse") + (org-startup-indented t "Indent the headings") + (org-image-actual-width '(300) "Cap width") + (org-startup-with-latex-preview t "see latex previews on opening file") + (org-startup-with-inline-images t "See images on opening file") + (org-hide-emphasis-markers t "prettify org mode") + (org-use-sub-superscripts "{}" "Only display superscripts and subscripts when enclosed in {}") + (org-pretty-entities t "prettify org mode") + (org-agenda-files (list "~/monorepo/agenda.org" "~/org/notes.org" "~/org/agenda.org") "set default org files") + (org-default-notes-file (concat org-directory "/notes.org") "Notes file") - (TeX-engine 'xetex "set xelatex as default engine") - (preview-default-option-list '("displaymath" "textmath" "graphics") "preview latex") - ;; (preview-image-type 'png "Use PNGs") - (org-preview-latex-default-process 'dvipng) - (org-format-latex-options - '(:foreground default - :background default - :scale 2 - :html-foreground "Black" - :html-background "Transparent" - :html-scale 1.5 - :matchers ("begin" "$1" "$" "$$" "\\(" "\\[")) "space latex better") - (org-return-follows-link t "be able to follow links without mouse") - (org-startup-indented t "Indent the headings") - (org-image-actual-width '(300) "Cap width") - (org-startup-with-latex-preview t "see latex previews on opening file") - (org-startup-with-inline-images t "See images on opening file") - (org-hide-emphasis-markers t "prettify org mode") - (org-use-sub-superscripts "{}" "Only display superscripts and subscripts when enclosed in {}") - (org-pretty-entities t "prettify org mode") - (org-agenda-files (list "~/monorepo/agenda.org" "~/org/notes.org" "~/org/agenda.org") "set default org files") - (org-default-notes-file (concat org-directory "/notes.org") "Notes file") + ;; ricing + (org-auto-align-tags nil) + (org-tags-column 0) + (org-catch-invisible-edits 'show-and-error) + (org-special-ctrl-a/e t) + (org-insert-heading-respect-content t) + (org-hide-emphasis-markers t) + (org-pretty-entities t) + (org-agenda-tags-column 0) + (org-ellipsis "…") + :config + (org-babel-do-load-languages 'org-babel-load-languages + '((shell . t) + (python . t) + (nix . t) + (latex . t)))) - ;; ricing - (org-auto-align-tags nil) - (org-tags-column 0) - (org-catch-invisible-edits 'show-and-error) - (org-special-ctrl-a/e t) - (org-insert-heading-respect-content t) - (org-hide-emphasis-markers t) - (org-pretty-entities t) - (org-agenda-tags-column 0) - (org-ellipsis "…") - :config - (org-babel-do-load-languages 'org-babel-load-languages - '((shell . t) - (python . t) - (nix . t) - (latex . t)))) +(use-package org-tempo + :after org) - (use-package org-tempo - :after org) +(use-package org-habit + :after org + :custom + (org-habit-preceding-days 7 "See org habit entries") + (org-habit-following-days 35 "See org habit entries") + (org-habit-show-habits t "See org habit entries") + (org-habit-show-habits-only-for-today nil "See org habit entries") + (org-habit-show-all-today t "Show org habit graph")) - (use-package org-habit - :after org - :custom - (org-habit-preceding-days 7 "See org habit entries") - (org-habit-following-days 35 "See org habit entries") - (org-habit-show-habits t "See org habit entries") - (org-habit-show-habits-only-for-today nil "See org habit entries") - (org-habit-show-all-today t "Show org habit graph")) +(use-package htmlize + :demand t + :after (catppuccin-theme doom-themes yaml-mode)) +(unless noninteractive (use-package htmlize - :demand t - :after (catppuccin-theme doom-themes yaml-mode)) + :after (doom-themes))) - (unless noninteractive - (use-package htmlize - :after (doom-themes))) +(use-package ox-latex + :after (org) + :custom + (org-latex-compiler "xelatex" "Use latex as default") + (org-latex-pdf-process '("xelatex -interaction=nonstopmode -output-directory=%o %f") "set xelatex as default")) - (use-package ox-latex - :after (org) - :custom - (org-latex-compiler "xelatex" "Use latex as default") - (org-latex-pdf-process '("xelatex -interaction=nonstopmode -output-directory=%o %f") "set xelatex as default")) +(use-package ox-html + :demand t + :after (org htmlize) + :custom + (org-html-htmlize-output-type 'css "allow styling from CSS file") + (org-html-with-latex 'html "let my html handler handle latex") + (org-html-mathjax-options nil "disable mathjax, use MathML") + (org-html-mathjax-template "" "disable mathjax, use MathML") + (org-html-head-include-default-style nil "use my own css for everything") + (org-html-head-include-scripts nil "use my own js for everything") + (org-html-postamble (concat "Copyright © 2024 " system-fullname) "set copyright notice on bottom of site") + (org-html-divs '((preamble "header" "preamble") + (content "main" "content") + (postamble "footer" "postamble")) "semantic html exports") + (org-html-viewport '((width "device-width") + (initial-scale "1.0") + (minimum-scale "1.0")) "Prevent zooming out past default size") + :config (advice-add 'org-html-latex-environment :around #'org-html-latex-environment-pandoc-fix)) - (use-package ox-html - :demand t - :after (org htmlize) - :custom - (org-html-htmlize-output-type 'css "allow styling from CSS file") - (org-html-with-latex 'html "let my html handler handle latex") - (org-html-mathjax-options nil "disable mathjax, use MathML") - (org-html-mathjax-template "" "disable mathjax, use MathML") - (org-html-head-include-default-style nil "use my own css for everything") - (org-html-head-include-scripts nil "use my own js for everything") - (org-html-postamble (concat "Copyright © 2024 " system-fullname) "set copyright notice on bottom of site") - (org-html-divs '((preamble "header" "preamble") - (content "main" "content") - (postamble "footer" "postamble")) "semantic html exports") - (org-html-viewport '((width "device-width") - (initial-scale "1.0") - (minimum-scale "1.0")) "Prevent zooming out past default size") - :config (advice-add 'org-html-latex-environment :around #'org-html-latex-environment-pandoc-fix)) +(use-package ox-rss + :after org + :demand t) - (use-package ox-publish - :demand t - :after (org f s dash ox-html) - :custom - (org-publish-project-alist - `(("website-org" - :base-directory "~/monorepo" - :base-extension "org" - :exclude "nix/README\\.org" - :publishing-directory "~/website_html" - :with-author t - :with-date t - :recursive t - :publishing-function org-html-publish-to-html - :headline-levels 4 - :html-footnotes-section "<div id=\"footnotes\"><hr><div id=\"text-footnotes\"><span class=\"footnotes-label-hidden\">%s</span>%s</div></div>" - :html-head ,(concat "<meta name=\"theme-color\" content=\"#ffffff\">\n<link rel=\"preload\" href=\"/fonts/Inconsolata-Medium.woff2\" as=\"font\" type=\"font/woff2\" crossorigin>\n<meta name=\"theme-color\" content=\"#ffffff\">\n<link rel=\"preload\" href=\"/fonts/Lora-Medium.woff2\" as=\"font\" type=\"font/woff2\" crossorigin>\n<link rel=\"preload\" href=\"/fonts/CormorantGaramond-Bold.woff2\" as=\"font\" type=\"font/woff2\" crossorigin>\n<link rel=\"preload\" href=\"/fonts/CormorantGaramond-Medium.woff2\" as=\"font\" type=\"font/woff2\" crossorigin>\n<link rel=\"manifest\" href=\"/site.webmanifest\">\n<link rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/favicon-16x16.png\">\n<link rel=\"mask-icon\" href=\"/safari-pinned-tab.svg\" color=\"#5bbad5\">\n<link rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/favicon-32x32.png\">\n<link rel=\"apple-touch-icon\" sizes=\"180x180\" href=\"/apple-touch-icon.png\"><meta name=\"msapplication-TileColor\" content=\"#da532c\">\n" - "<style>" - (->> (create-htmlize-css) - (s-replace-regexp "<style[^>]*>" "") - (s-replace "</style>" "") - (s-replace "<![CDATA[/*><![CDATA[/*>\n" "") - (s-replace "/*]]>*/-->" "") - (s-trim) - (minify-css)) - (f-read-text "~/monorepo/style.css" 'utf-8) - "</style>") - :html-preamble t - :html-preamble-format (("en" "<p class=\"preamble\"><a href=\"/index.html\">home</a> | <a href=\"./index.html\">section main page</a></p><hr>"))) - ("website-static" - :base-directory "~/monorepo" - :base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf\\|ico\\|asc\\|pub\\|webmanifest\\|xml\\|svg\\|txt\\|webp\\|conf" - :publishing-directory "~/website_html/" - :recursive t - :publishing-function org-publish-attachment) - ("website" :auto-sitemap t :components ("website-org" "website-static"))) "functions to publish website")) +(use-package ox-publish + :demand t + :after (org f s dash ox-html ox-rss) + :custom + (org-publish-project-alist + `(("website-org" + :base-directory "~/monorepo" + :base-extension "org" + :exclude "nix/README\\.org\\|blog/rss\\.org\\|result/.*\\|nix/.*" + :publishing-directory "~/website_html" + :with-author t + :with-date t + :with-broken-links t + :language en + + :recursive t + :publishing-function org-html-publish-to-html + :headline-levels 4 + :html-footnotes-section "<div id=\"footnotes\"><hr><div id=\"text-footnotes\"><span class=\"footnotes-label-hidden\">%s</span>%s</div></div>" + :html-head ,(concat "<meta name=\"theme-color\" content=\"#ffffff\">\n<link rel=\"preload\" href=\"/fonts/Inconsolata-Medium.woff2\" as=\"font\" type=\"font/woff2\" crossorigin>\n<meta name=\"theme-color\" content=\"#ffffff\">\n<link rel=\"preload\" href=\"/fonts/Lora-Medium.woff2\" as=\"font\" type=\"font/woff2\" crossorigin>\n<link rel=\"preload\" href=\"/fonts/CormorantGaramond-Bold.woff2\" as=\"font\" type=\"font/woff2\" crossorigin>\n<link rel=\"preload\" href=\"/fonts/CormorantGaramond-Medium.woff2\" as=\"font\" type=\"font/woff2\" crossorigin>\n<link rel=\"manifest\" href=\"/site.webmanifest\">\n<link rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/favicon-16x16.png\">\n<link rel=\"mask-icon\" href=\"/safari-pinned-tab.svg\" color=\"#5bbad5\">\n<link rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/favicon-32x32.png\">\n<link rel=\"apple-touch-icon\" sizes=\"180x180\" href=\"/apple-touch-icon.png\"><meta name=\"msapplication-TileColor\" content=\"#da532c\">\n" + "<style>" + (->> (create-htmlize-css) + (s-replace-regexp "<style[^>]*>" "") + (s-replace "</style>" "") + (s-replace "<![CDATA[/*><![CDATA[/*>\n" "") + (s-replace "/*]]>*/-->" "") + (s-trim) + (minify-css)) + (f-read-text "~/monorepo/style.css" 'utf-8) + "</style>") + :html-preamble t + :html-preamble-format (("en" "<p class=\"preamble\"><a href=\"/index.html\">home</a> | <a href=\"./index.html\">section main page</a></p><hr>")) + + ;; sitemap.html stuff + :auto-sitemap t + :sitemap-filename "sitemap.org" + :sitemap-title "Site Index" + :sitemap-style list + :sitemap-sort-files anti-chronologically) + + ("website-blog-rss" + :base-directory "~/monorepo/blog" + :base-extension "org" + :recursive nil + :exclude "rss\\.org\\|index\\.org\\|404\\.org" + :rss-extension "xml" + + :publishing-directory "~/website_html/blog" + :publishing-function rp/org-rss-publish-to-rss + :html-link-home "https://ret2pop.net/blog/" + :html-link-use-abs-url t + + ;; use custom sitemap functionality to publish rss feed + :auto-sitemap t + :sitemap-filename "rss.org" + :sitemap-title "Blog Feed" + :sitemap-style list + :sitemap-sort-folders ignore + :sitemap-sort-files anti-chronologically + :sitemap-format-entry format-rss-feed-entry + :sitemap-function format-rss-feed) + + ("website-sitemap-xml" + :base-directory "~/monorepo" + :base-extension "org" + :recursive t + :exclude "nix/README\\.org\\|blog/rss\\.org" + :publishing-directory "~/website_html" + :publishing-function rp/org-sitemap-publish-function + :auto-sitemap t + :sitemap-filename "sitemap.xml" + :sitemap-format-entry org-sitemap-format-entry-xml + :sitemap-style list + :sitemap-function org-sitemap-format-xml) + + ("website-static" + :base-directory "~/monorepo" + :base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf\\|ico\\|asc\\|pub\\|webmanifest\\|xml\\|svg\\|txt\\|webp\\|conf" + :publishing-directory "~/website_html/" + :recursive t + :publishing-function org-publish-attachment) + + ("website" + :auto-sitemap t + :components ("website-org" "website-static" "website-blog-rss" "website-sitemap-xml"))) + "functions to publish website")) #+end_src As you can see, I only have one real entry in config here (I don't count requires even though they have to be on the top) |
