dotfiles/.doom.d/config.org

1706 lines
63 KiB
Org Mode
Raw Normal View History

2019-09-13 02:14:31 +00:00
#+TITLE: DOOM Emacs Configuration
2021-01-09 21:07:13 +00:00
#+STARTUP: indent overview
#+PROPERTY: header-args :tangle config.el
2019-09-13 02:14:31 +00:00
2021-01-21 03:08:37 +00:00
* Look And Feel
** Theme
2023-05-22 00:58:17 +00:00
It's Catppuccin time!
2021-01-09 21:07:47 +00:00
#+begin_src emacs-lisp
2023-05-22 00:58:17 +00:00
(use-package! catppuccin-theme
2023-05-23 04:07:13 +00:00
:init (setq catppuccin-flavor 'macchiato)
:config (setq doom-theme 'catppuccin))
2021-01-09 21:07:47 +00:00
#+end_src
2021-06-28 23:36:53 +00:00
** Default font
#+begin_src emacs-lisp
2021-08-02 19:47:03 +00:00
(setq doom-font (font-spec :family "Inconsolata" :size 16))
2021-06-28 23:36:53 +00:00
#+end_src
2021-01-21 03:08:37 +00:00
** Dashboard
Customize the Doom Emacs dashboard with commissioned artwork, chosen randomly.
The dashboard can be reloaded with the =g= key.
2020-01-24 16:44:57 +00:00
#+begin_src emacs-lisp
2021-01-21 03:08:37 +00:00
(defun my/choice (&rest things)
(let ((index (random (length things))))
(nth index things)))
(defun my/dashboard-randomize ()
(interactive)
(let ((logo (my/choice "~/Pictures/Patreon/Jon Bliss/phoenix-and-catgirl-500.png"
"~/Pictures/Patreon/Jon Bliss/Bassist-final-transparent-500.png"
"~/Pictures/Patreon/Jon Bliss/catgirl-final-transparent-500.png"
"~/Pictures/Patreon/Jon Bliss/lapiz-final-transparent-500.png"
"~/Pictures/Patreon/Jon Bliss/Poledancer-final-transparent-500.png"
"~/Pictures/Patreon/Jon Bliss/Hacker-final-transparent-500.png"
"~/Pictures/Patreon/Bee/IMG_3666_transparent_500.png")))
(setq fancy-splash-image logo)
(if (called-interactively-p)
(+doom-dashboard-reload))))
(my/dashboard-randomize)
(map!
:map +doom-dashboard-mode-map
"g" #'my/dashboard-randomize)
2020-01-24 16:44:57 +00:00
#+end_src
2021-01-21 03:08:37 +00:00
** Frame transparency
Set the background transparency to 90% so my wallpaper shows through.
2020-02-06 15:39:09 +00:00
#+begin_src emacs-lisp
(set-frame-parameter (selected-frame) 'alpha '(98 . 98))
(add-to-list 'default-frame-alist '(alpha . (98 . 98)))
2020-02-06 15:39:09 +00:00
#+end_src
2020-12-23 22:17:10 +00:00
** Comic Sans Mono
Why not, it's fun 🤣
2021-01-21 03:08:37 +00:00
Adds a command to switch to the monospaced Comic Sans font, and make it the
default font for PHP buffers.
2020-12-23 22:17:10 +00:00
https://dtinth.github.io/comic-mono-font/
#+begin_src emacs-lisp
(defun my/buffer-face-comic-mono ()
(interactive)
(setq buffer-face-mode-face '(:family "Comic Mono"))
(buffer-face-mode))
(after! php-mode
(add-hook 'php-mode-hook #'my/buffer-face-comic-mono))
#+end_src
2021-01-21 03:08:37 +00:00
** Mixed Pitch
Facilitates mixing monospace and proportional fonts. I'm using an MIT-licensed
version of the [[https://github.com/edwardtufte/et-book][Edward Tufte book font]] because it's /gorgeous/.
2021-01-09 21:07:13 +00:00
#+begin_src emacs-lisp
2021-01-21 03:08:37 +00:00
(use-package! mixed-pitch
:hook ((org-mode markdown-mode rst-mode) . mixed-pitch-mode))
(setq doom-variable-pitch-font (font-spec :family "ETBookOT"))
2021-01-09 21:07:13 +00:00
#+end_src
2021-01-21 03:08:37 +00:00
* UX Improvements
** Disable C-z backgrounding when the GUI is loaded
In OSX, this minimizes the window. It's incredibly annoying, and I accidentally
hit it too much. I also can't think of any reason I'd want to background Emacs
outside of a terminal session.
2021-01-09 21:07:13 +00:00
#+begin_src emacs-lisp
2021-01-21 03:08:37 +00:00
(if (display-graphic-p)
(global-unset-key (kbd "C-z")))
2021-01-09 21:07:13 +00:00
#+end_src
2021-01-21 03:08:37 +00:00
** Custom settings
Store options set via =customize-*= in a separate file (Emacs stores
them in =init.el= by default).
2021-01-09 21:07:13 +00:00
2021-01-21 03:08:37 +00:00
#+BEGIN_SRC emacs-lisp
(setq custom-file "~/.emacs.d/custom.el")
(if (file-exists-p custom-file)
(load custom-file))
2021-01-09 21:07:13 +00:00
2021-01-21 03:08:37 +00:00
(setf custom-safe-themes t)
#+END_SRC
** Eval and Replace
Replace an s-expression with its value. Taken from [[http://emacsredux.com/blog/2013/06/21/eval-and-replace/][Emacs Redux]].
2021-01-09 21:07:13 +00:00
2019-09-17 17:37:54 +00:00
#+begin_src emacs-lisp
2021-01-21 03:08:37 +00:00
(defun eval-and-replace ()
"Replace the preceding sexp with its value."
(interactive)
(backward-kill-sexp)
(condition-case nil
(prin1 (eval (read (current-kill 0)))
(current-buffer))
(error (message "Invalid expression")
(insert (current-kill 0)))))
2019-09-17 17:37:54 +00:00
2021-01-21 03:08:37 +00:00
(global-set-key (kbd "C-)") 'eval-and-replace)
2019-09-17 17:37:54 +00:00
#+end_src
2021-08-02 19:47:18 +00:00
** Prompt for unsafe local variables
Doom sets this to =:safe=, logging unsafe variables for later addressing. I'd
rather continue to be prompted.
#+begin_src emacs-lisp
(setq enable-local-variables t)
#+end_src
2021-01-21 03:08:37 +00:00
* Writing
** BibTeX
Tell Emacs where to find my bibliography files. I keep most everything in my
Calibre library, which I regularly export and keep synced via Nextcloud.
2020-07-18 23:35:29 +00:00
#+begin_src emacs-lisp
(setq my/bibliographies
'("~/Documents/bibliography/references.bib"
"~/Documents/bibliography/calibre.bib"))
#+end_src
2021-01-21 03:08:37 +00:00
*** Helm BibTeX
2020-07-18 23:35:29 +00:00
#+begin_src emacs-lisp
2022-02-04 03:17:36 +00:00
(setq bibtex-completion-bibliography my/bibliographies
bibtex-completion-pdf-field "File"
bibtex-completion-notes-path "~/org/roam")
2020-07-18 23:35:29 +00:00
#+end_src
2021-12-19 03:20:22 +00:00
*** Citar
#+begin_src emacs-lisp
2022-02-04 03:17:36 +00:00
(setq citar-bibliography my/bibliographies
citar-notes-paths '("~/org/roam"))
2021-12-19 03:20:22 +00:00
#+end_src
2021-01-21 03:08:37 +00:00
** Org
2019-09-13 02:14:31 +00:00
:PROPERTIES:
:header-args: :tangle no :noweb-ref org
:END:
2021-01-21 03:08:37 +00:00
Configure a variety of options and tools for [[https://orgmode.org][Org Mode]], the markup I use for
everything from simple notes to task management.
2021-01-30 04:16:11 +00:00
#+begin_src emacs-lisp :noweb yes :tangle "config.el" :noweb-ref org-all
2019-09-13 15:25:02 +00:00
(after! org
2019-09-13 02:14:31 +00:00
<<org>>)
#+end_src
2021-01-21 03:08:37 +00:00
*** Override DOOM indentation behavior
2019-09-13 02:14:31 +00:00
#+begin_src emacs-lisp
(defun my/org-init-babel ()
(setq org-src-preserve-indentation nil))
(add-hook! 'org-mode-hook #'my/org-init-babel)
#+end_src
2021-01-21 03:08:37 +00:00
*** Disable DOOM's centralized attachment system
2019-09-13 02:14:31 +00:00
It's incompatible with all of the org files I already have using the standard
setup.
#+begin_src emacs-lisp
(setq org-attach-directory "data/")
(remove-hook! 'org-load-hook
#'(+org-init-centralized-attachments-h))
#+end_src
2021-01-21 03:08:37 +00:00
*** Agenda
Set up my agenda view. I use separate files for my personal TODOs and my work
TODOs, synced externally using Nextcloud.
2019-09-13 15:47:23 +00:00
#+begin_src emacs-lisp
(after! org-agenda
(require 'f)
(setq my/agenda-files '((personal . ("~/Nextcloud/org/personal.org"))
(work . ("~/Nextcloud/org/aweber.org")))
2019-09-13 15:47:23 +00:00
org-agenda-files (-filter #'f-exists?
(-concat
2021-06-24 15:02:23 +00:00
(if (string-equal (system-name) "s1326.ofc.lair")
2019-09-13 15:47:23 +00:00
(cdr (assoc 'work my/agenda-files))
(cdr (assoc 'personal my/agenda-files))))))
(setq org-stuck-projects
'("+LEVEL=1/-DONE" ("TODO" "NEXT" "NEXTACTION") nil ""))
;; https://www.tompurl.com/2015-12-29-emacs-eisenhower-matrix.html
(setq org-tag-alist '(("important" . ?i)
("urgent" . ?u)))
(setq org-agenda-custom-commands
'(("n" "Agenda and all TODOs"
2020-03-02 22:01:28 +00:00
((agenda "" ((org-agenda-span 'week)))
2019-09-13 15:47:23 +00:00
(tags-todo "DEADLINE<=\"<+7d>\""
((org-agenda-overriding-header "Due soon")))
(todo ""
((org-agenda-overriding-header "Unscheduled")
(org-agenda-skip-function '(org-agenda-skip-entry-if 'scheduled 'deadline)))))
2019-09-13 15:47:23 +00:00
((org-agenda-start-with-log-mode t)
(org-agenda-start-day nil)
2019-09-13 15:47:23 +00:00
(org-agenda-span 'day)
(org-agenda-log-mode-items '(clock state closed)))
("~/Public/org/agenda.html"
"~/Public/org/agenda.ics"))
2019-09-13 15:47:23 +00:00
("l" "Log"
agenda ""
((org-agenda-span 'fortnight)
(org-agenda-start-day "-1w")
(org-agenda-start-with-log-mode t)
(org-agenda-log-mode-items '(clock state closed))
(org-agenda-include-deadlines nil)
(org-agenda-skip-scheduled-delay-if-deadline t))
("~/Public/org/agenda-log.html"))
2019-09-13 15:47:23 +00:00
("e" "Eisenhower Matrix"
((tags-todo "+important+urgent"
((org-agenda-overriding-header "Do")))
(tags-todo "+important-urgent"
((org-agenda-overriding-header "Decide")))
(tags-todo "-important+urgent"
((org-agenda-overriding-header "Delegate")))
(tags-todo "-important-urgent"
((org-agenda-overriding-header "Delete"))))
((org-agenda-start-with-log-mode t)
(org-agenda-span 'day)
(org-agenda-log-mode-items '(clock state closed))))))
(defun my/org-agenda-timeline ()
(interactive)
(let ((org-agenda-files (list (buffer-file-name))))
(org-agenda)))
(setq org-agenda-start-on-weekday nil)
(setq org-agenda-span 'fortnight)
(setq org-agenda-todo-ignore-scheduled 'future)
(setq org-agenda-tags-todo-honor-ignore-options t)
(setq org-agenda-skip-deadline-prewarning-if-scheduled t)
(add-hook 'org-agenda-finalize-hook (lambda () (hl-line-mode)))
(setq
org-icalendar-use-scheduled '(todo-start event-if-todo)
org-icalendar-combined-agenda-file (expand-file-name "~/Documents/org.ics")))
#+end_src
2021-01-21 03:08:37 +00:00
*** LaTeX Export
**** Document Classes
Tell Emacs about all of the LaTeX classes I use to export documents.
2019-09-13 02:14:31 +00:00
#+BEGIN_SRC emacs-lisp
(use-package! ox-latex
:config
(seq-map (apply-partially #'add-to-list 'org-latex-classes)
'(("koma-letter"
"\\documentclass{scrlttr2}"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
("koma-article"
"\\documentclass{scrartcl}"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
("koma-book"
"\\documentclass{scrbook}"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
("koma-book-chapters"
"\\documentclass{scrbook}"
("\\chapter{%s}" . "\\chapter*{%s}")
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
("koma-report"
"\\documentclass{scrreprt}"
("\\chapter{%s}" . "\\chapter*{%s}")
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
("memoir"
"\\documentclass{memoir}"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
("hitec"
"\\documentclass{hitec}"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
("paper"
"\\documentclass{paper}"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
("letter"
"\\documentclass{letter}"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
("tufte-handout"
"\\documentclass{tufte-handout}"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
("tufte-book"
"\\documentclass{tufte-book}"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
("tufte-book-chapters"
"\\documentclass{tufte-book}"
("\\chapter{%s}" . "\\chapter*{%s}")
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
("labbook"
"\\documentclass{labbook}"
("\\chapter{%s}" . "\\chapter*{%s}")
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\labday{%s}")
("\\subsubsection{%s}" . "\\experiment{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
("thermal-paper"
"\\documentclass{paper}
\\usepackage[paperwidth=52mm]{geometry}"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
2019-09-13 02:14:31 +00:00
("\\subparagraph{%s}" . "\\subparagraph*{%s}")))))
#+END_SRC
2021-01-21 03:08:37 +00:00
**** DnD
This adds an additional LaTeX export option that outputs documents resembling a
Dungeons and Dragons manual.
2020-06-24 01:13:17 +00:00
#+begin_src emacs-lisp
(use-package! ox-dnd
:after ox)
#+end_src
2021-01-21 03:08:37 +00:00
*** Capture templates
Set up my capture templates for making new notes and journal entries.
2019-09-13 14:54:23 +00:00
#+begin_src emacs-lisp
(setq org-capture-templates
`(
;; Personal
("j" "Journal Entry" plain
(file+datetree "~/org/journal.org")
"%U\n\n%?" :empty-lines-before 1)
("t" "TODO" entry
(file+headline "~/Nextcloud/org/personal.org" "Unsorted")
2019-09-13 14:54:23 +00:00
"* TODO %^{Description}\n%?")
("n" "Note" entry
(file+headline "~/Nextcloud/org/personal.org" "Notes")
2019-09-13 14:54:23 +00:00
"* %^{Description}\n%U\n\n%?")
2023-05-23 04:07:46 +00:00
("c" "Cookbook Recipe" entry
(file "~/org/cookbook/index.org")
"%(org-chef-get-recipe-from-url)"
:empty-lines 1)
2019-09-13 14:54:23 +00:00
;; Org-Protocol
("b" "Bookmark" entry
(file+headline "~/org/bookmarks.org" "Unsorted")
"* %^{Title}\n\n Source: %u, %c\n\n %i")
("p" "Webpage" entry
(file "~/org/articles.org")
"* %a\n\n%U %?\n\n%:initial")
2019-09-13 02:14:31 +00:00
2019-09-13 14:54:23 +00:00
;; Email
;; https://martinralbrecht.wordpress.com/2016/05/30/handling-email-with-emacs/
("r" "respond to email (mu4e)"
entry (file+headline "~/org/todo.org" "Email")
"* REPLY to [[mailto:%:fromaddress][%:fromname]] on %a\nDEADLINE: %(org-insert-time-stamp (org-read-date nil t \"+1d\"))\n%U\n\n"
:immediate-finish t
:prepend t)
2019-09-13 02:14:31 +00:00
2019-09-13 14:54:23 +00:00
;; Work
("w" "Work")
("wt" "Work TODO" entry
(file+headline "~/Nextcloud/org/aweber.org" "Unsorted")
2019-09-13 14:54:23 +00:00
"* TODO %^{Description}\n%?")
("wl" "Log Work Task" entry
(file+datetree "~/org-aweber/worklog.org")
"* %^{Description} %^g\nAdded: %U\n\n%?"
:clock-in t
:clock-keep t)
("wL" "Log Work Task (no clock)" entry
(file+datetree "~/org-aweber/worklog.org")
"* %^{Description} %^g\nAdded: %U\n\n%?")
("wj" "Log work on JIRA issue" entry
(file+datetree "~/org-aweber/worklog.org")
,(concat
"* %?\n"
":PROPERTIES:\n"
":JIRA_ID: %^{JIRA_ID}\n"
":END:\n"
"Added: %U\n\n"
"[[jira:%\\1][%\\1]]")
:clock-in t
:clock-keep t)
("wr" "respond to email (mu4e)"
entry (file+headline "~/Nextcloud/org/aweber.org" "Unsorted")
2019-09-13 14:54:23 +00:00
"* REPLY to [[mailto:%:fromaddress][%:fromname]] on %a\nDEADLINE: %(org-insert-time-stamp (org-read-date nil t \"+1d\"))\n%U\n\n"
:immediate-finish t
:prepend t)))
#+end_src
2021-01-21 03:08:37 +00:00
*** Custom ID generation
2019-09-13 14:54:23 +00:00
Because I'm all kinds of crazy, I like the custom IDs of my work log entries to
be based on their headings.
#+begin_src emacs-lisp
(use-package! org-id
:after org
:config
;; https://writequit.org/articles/emacs-org-mode-generate-ids.html#automating-id-creation
(defun eos/org-custom-id-get (&optional pom create prefix)
"Get the CUSTOM_ID property of the entry at point-or-marker POM.
If POM is nil, refer to the entry at point. If the entry does
not have an CUSTOM_ID, the function returns nil. However, when
CREATE is non nil, create a CUSTOM_ID if none is present
already. PREFIX will be passed through to `org-id-new'. In any
case, the CUSTOM_ID of the entry is returned."
(interactive)
(org-with-point-at pom
(let ((id (org-entry-get nil "CUSTOM_ID")))
(cond
((and id (stringp id) (string-match "\\S-" id))
id)
(create
(setq id (org-id-new (concat prefix "h")))
(org-entry-put pom "CUSTOM_ID" id)
(org-id-add-location id (buffer-file-name (buffer-base-buffer)))
id)))))
(defun eos/org-add-ids-to-headlines-in-file ()
"Add CUSTOM_ID properties to all headlines in the current
file which do not already have one. Only adds ids if the
`auto-id' option is set to `t' in the file somewhere. ie,
,#+OPTIONS: auto-id:t"
(interactive)
(save-excursion
(widen)
(goto-char (point-min))
(when (re-search-forward "^#\\+OPTIONS:.*auto-id:t" (point-max) t)
(org-map-entries (lambda () (eos/org-id-get (point) 'create)))))
(save-excursion
(widen)
(goto-char (point-min))
(when (re-search-forward "^#\\+OPTIONS:.*auto-id:worklog" (point-max) t)
(let ((my/org-worklog-id-depth 2))
(org-map-entries (lambda () (my/org-worklog-id-get (point) 'create))))))
(save-excursion
(widen)
(goto-char (point-min))
(when (re-search-forward "^#\\+OPTIONS:.*auto-id:readable" (point-max) t)
(let ((my/org-worklog-id-depth 0))
(org-map-entries (lambda () (my/org-worklog-id-get (point) 'create)))))))
;; automatically add ids to saved org-mode headlines
(add-hook 'org-mode-hook
(lambda ()
(add-hook 'before-save-hook
(lambda ()
(when (and (eq major-mode 'org-mode)
(eq buffer-read-only nil))
(eos/org-add-ids-to-headlines-in-file))))))
(defun my/org-remove-all-ids ()
(interactive)
(save-excursion
(widen)
(goto-char (point-min))
(org-map-entries (lambda () (org-entry-delete (point) "CUSTOM_ID")))))
(defvar my/org-worklog-id-depth 2)
(defun my/org-worklog-id-new (&optional prefix)
(let ((path (or (-drop my/org-worklog-id-depth (org-get-outline-path t))
(last (org-get-outline-path t)))))
(mapconcat
(lambda (s)
(->> s
(s-downcase)
(s-replace-regexp "[^[:alnum:]]+" "-")))
path
"-")))
(defun my/org-worklog-id-get (&optional pom create prefix)
(interactive)
(org-with-point-at pom
(let ((id (org-entry-get nil "CUSTOM_ID")))
(cond
((and id (stringp id) (string-match "\\S-" id))
id)
(create
(setq id (my/org-worklog-id-new prefix))
(org-entry-put pom "CUSTOM_ID" id)
id))))))
#+end_src
2021-01-21 03:08:37 +00:00
*** Publish projects
Tell Emacs how to build the document collections I export to HTML.
2019-09-13 14:54:23 +00:00
#+begin_src emacs-lisp
(require 'org-attach)
2019-09-13 14:54:23 +00:00
(setq org-html-mathjax-options
'((path "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-AMS-MML_HTMLorMML")))
2019-11-01 17:17:08 +00:00
(setq org-re-reveal-root "https://cdn.jsdelivr.net/reveal.js/3.0.0/")
2019-09-13 14:54:23 +00:00
(defun my/org-work-publish-to-html (plist filename pub-dir)
(message "Publishing %s" filename)
(cond ((string-match-p "slides.org$" filename)
2019-11-01 17:17:08 +00:00
(org-re-reveal-publish-to-reveal plist filename pub-dir))
2019-09-13 14:54:23 +00:00
(t (let ((org-html-head
(concat
;; Tufte
;; "<link rel=\"stylesheet\" href=\"" my/org-base-url "styles/tufte-css/tufte.css\"/>"
;; "<link rel=\"stylesheet\" href=\"" my/org-base-url "styles/tufte-css/latex.css\"/>"
;; Org-Spec
;; "<link href=\"https://fonts.googleapis.com/css?family=Roboto+Slab:400,700|Inconsolata:400,700\" rel=\"stylesheet\" type=\"text/css\" />"
;; "<link rel=\"stylesheet\" href=\"" my/org-base-url "styles/org-spec/style.css\"/>"
;; "<link rel=\"stylesheet\" type=\"text/css\" href=\"" my/org-base-url "css/info.css\" />"
;; ReadTheOrg
"<link rel=\"stylesheet\" type=\"text/css\" href=\"" my/org-base-url "styles/readtheorg/css/htmlize.css\"/>"
"<link rel=\"stylesheet\" type=\"text/css\" href=\"" my/org-base-url "styles/readtheorg/css/readtheorg.css\"/>"
"<link rel=\"stylesheet\" type=\"text/css\" href=\"" my/org-base-url "css/info.css\" />"
"<script src=\"https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js\"></script>"
"<script src=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js\"></script>"
"<script type=\"text/javascript\" src=\"" my/org-base-url "styles/lib/js/jquery.stickytableheaders.min.js\"></script>"
"<script type=\"text/javascript\" src=\"" my/org-base-url "styles/readtheorg/js/readtheorg.js\"></script>"
;; Bigblow
;; "<link rel=\"stylesheet\" type=\"text/css\" href=\"" my/org-base-url "styles/bigblow/css/htmlize.css\"/>"
;; "<link rel=\"stylesheet\" type=\"text/css\" href=\"" my/org-base-url "styles/bigblow/css/bigblow.css\"/>"
;; "<link rel=\"stylesheet\" type=\"text/css\" href=\"" my/org-base-url "styles/bigblow/css/hideshow.css\"/>"
;; "<script type=\"text/javascript\" src=\"" my/org-base-url "styles/bigblow/js/jquery-1.11.0.min.js\"></script>"
;; "<script type=\"text/javascript\" src=\"" my/org-base-url "styles/bigblow/js/jquery-ui-1.10.2.min.js\"></script>"
;; "<script type=\"text/javascript\" src=\"" my/org-base-url "styles/bigblow/js/jquery.localscroll-min.js\"></script>"
;; "<script type=\"text/javascript\" src=\"" my/org-base-url "styles/bigblow/js/jquery.scrollTo-1.4.3.1-min.js\"></script>"
;; "<script type=\"text/javascript\" src=\"" my/org-base-url "styles/bigblow/js/jquery.zclip.min.js\"></script>"
;; "<script type=\"text/javascript\" src=\"" my/org-base-url "styles/bigblow/js/bigblow.js\"></script>"
;; "<script type=\"text/javascript\" src=\"" my/org-base-url "styles/bigblow/js/hideshow.js\"></script>"
;; "<script type=\"text/javascript\" src=\"" my/org-base-url "styles/lib/js/jquery.stickytableheaders.min.js\"></script>"
)))
(save-excursion
(save-restriction
(org-html-publish-to-html plist filename pub-dir)))))))
;; (setq my/org-base-url (concat "/~" (getenv "USER") "/org/"))
(setq my/org-base-url "/")
2019-11-01 17:17:08 +00:00
(setq my/org-base-url "https://correlr.gitlab.aweber.io/org/")
2019-09-13 14:54:23 +00:00
(setq org-publish-project-alist
`(
;; ("work-common"
;; :base-directory "~/org/common"
;; :publishing-directory "~/Public/org"
;; :base-extension "css\\|gif\\|jpe?g\\|png\\|svg"
;; :recursive t
;; :publishing-function org-publish-attachment)
("work-themes"
:base-directory "~/.emacs.local.d/org-html-themes/styles"
:publishing-directory "~/Public/org/styles"
:base-extension "js\\|css\\|gif\\|jpe?g\\|png\\|svg\\|ogv"
:recursive t
:publishing-function org-publish-attachment)
("work-html"
:base-directory "~/org-aweber"
:base-extension "org"
;; :exclude "\\(^knowledge-transfer.org$\\|-archive.org$\\)"
2021-06-28 23:39:41 +00:00
:exclude "\\(^README.org$\\|^worklog\\|roam/.*\\)"
2019-09-13 14:54:23 +00:00
:publishing-directory "~/Public/org"
:publishing-function (my/org-work-publish-to-html
org-org-publish-to-org
2019-11-01 17:17:08 +00:00
org-babel-tangle-publish)
;; :htmlized-source t
2019-09-13 14:54:23 +00:00
;; :html-head "<link rel=\"stylesheet\" type=\"text/css\" href=\"http://thomasf.github.io/solarized-css/solarized-dark.min.css\" />"
;; :html-head-extra "<link rel=\"stylesheet\" type=\"text/css\" href=\"/~croush/org/css/org.css\" />"
;; :setup-file "~/.emacs.local.d/org-html-themes/setup/theme-readtheorg-local.setup"
:html-link-home ,my/org-base-url
:html-doctype "html5"
:html-html5-fancy t
:with-sub-superscript nil
:section-numbers nil
2019-09-13 14:54:23 +00:00
;; :infojs-opt "path:http://thomasf.github.io/solarized-css/org-info.min.js view:showall"
:auto-sitemap t
:sitemap-filename "index.org"
:sitemap-title "Correl Roush's Org Documents"
:sitemap-sort-folders last
:recursive t)
2020-07-23 14:11:15 +00:00
("work-roam-html"
:base-directory "~/org-aweber/roam"
:base-extension "org"
:publishing-directory "~/Public/org/roam"
:recursive t
:with-toc nil
:section-numbers nil
:auto-sitemap t
:sitemap-filename "index.org"
:sitemap-title "Correl Roush's Org Roam Notes"
:publishing-function org-html-publish-to-html
:html-head "<link rel=\"stylesheet\" href=\"https://gongzhitaao.org/orgcss/org.css\"/>")
2019-09-13 14:54:23 +00:00
("work-assets"
:base-directory "~/org-aweber"
:base-extension "css\\|gif\\|jpe?g\\|png\\|svg\\|pdf\\|ogv\\|py\\|html\\|ya?ml"
:include (".gitlab-ci.yml")
:publishing-directory "~/Public/org"
:publishing-function org-publish-attachment
:display-custom-times t
2019-09-13 14:54:23 +00:00
:recursive t)
("work-todo"
:base-directory "~/Nextcloud/org"
:exclude ".*"
:include ("aweber.org")
:html-head "<link rel=\"stylesheet\" href=\"styles/tufte-css/tufte.css\"/>"
:html-head-extra "<link rel=\"stylesheet\" href=\"styles/tufte-css/latex.css\"/>"
:publishing-directory "~/Public/org"
:publishing-function org-html-publish-to-tufte-html)
2020-07-23 14:11:15 +00:00
("work" :components ("work-html" "work-roam-html" "work-todo" "work-assets" "work-themes"))
2019-09-13 14:54:23 +00:00
2023-02-05 22:46:50 +00:00
("cookbook-html"
:base-directory "~/org/cookbook"
:base-extension "org"
:publishing-directory "~/Public/cookbook"
:recursive t
:with-toc nil
:section-numbers nil
:auto-sitemap nil
:publishing-function org-html-publish-to-html
:html-head "<link rel=\"stylesheet\" href=\"https://gongzhitaao.org/orgcss/org.css\"/>")
("cookbook-assets"
:base-directory "~/org/cookbook"
:base-extension "css\\|js\\|json\\|gif\\|jpe?g\\|png\\|svg\\|pdf"
:publishing-directory "~/Public/cookbook"
:publishing-function org-publish-attachment
:recursive t)
("cookbook" :components ("cookbook-html" "cookbook-assets"))
2019-09-13 14:54:23 +00:00
("dotfiles-common"
:base-directory "~/dotfiles"
:publishing-directory "~/Public/dotfiles"
:base-extension "css\\|gif\\|jpe?g\\|png\\|svg"
:recursive t
:publishing-function org-publish-attachment)
("dotfiles-html"
:base-directory "~/dotfiles"
:base-extension "org"
:publishing-directory "~/Public/dotfiles"
:publishing-function (org-html-publish-to-html
org-babel-tangle-publish)
:htmlized-source t
:html-head "<link rel=\"stylesheet\" type=\"text/css\" href=\"http://thomasf.github.io/solarized-css/solarized-dark.min.css\" />"
:html-head-extra "<link rel=\"stylesheet\" type=\"text/css\" href=\"/~croush/org/css/org.css\" />"
:html-link-home "/~croush/dotfiles/"
:html-doctype "html5"
:html-html5-fancy t
:with-sub-superscript nil
:infojs-opt "path:http://thomasf.github.io/solarized-css/org-info.min.js view:showall"
:auto-sitemap t
:sitemap-filename "index.org"
:sitemap-title "Correl Roush's Dotfiles"
:sitemap-sort-folders last
:recursive t)
("dotfiles-assets"
:base-directory "~/dotfiles"
:base-extension "css\\|gif\\|jpe?g\\|png\\|svg"
:publishing-directory "~/Public/dotfiles"
:publishing-function org-publish-attachment
:recursive t)
("dotfiles" :components ("dotfiles-common" "dotfiles-html" "dotfiles-assets"))
("personal-themes"
:base-directory "~/.emacs.local.d/org-html-themes/styles"
:publishing-directory "~/Public/personal/styles"
:base-extension "js\\|css\\|gif\\|jpe?g\\|png\\|svg"
:recursive t
:publishing-function org-publish-attachment)
("personal-html"
:base-directory "~/org"
:base-extension "org"
:publishing-directory "~/Public/personal"
:recursive t
:with-toc t
:auto-sitemap t
:sitemap-title "Correl Roush's Org Files"
:sitemap-filename "index.org"
:publishing-function org-html-publish-to-tufte-html
:html-head ,(concat
;; Tufte
"<link rel=\"stylesheet\" href=\"" my/org-base-url "styles/tufte-css/tufte.css\"/>"
2019-11-01 17:17:08 +00:00
"<link rel=\"stylesheet\" href=\"" my/org-base-url "styles/tufte-css/latex.css\"/>"))
;; Org-Spec
;; "<link href=\"http://fonts.googleapis.com/css?family=Roboto+Slab:400,700|Inconsolata:400,700\" rel=\"stylesheet\" type=\"text/css\" />"
;; "<link href=\"http://demo.thi.ng/org-spec/css/style.css\" rel=\"stylesheet\" type=\"text/css\" />"
2019-09-13 14:54:23 +00:00
("personal-files"
:base-directory "~/org"
:base-extension "css\\|gif\\|jpe?g\\|png\\|svg"
:publishing-directory "~/Public/personal"
:recursive t
:publishing-function org-publish-attachment)
("personal-assets"
:base-directory "~/org"
:base-extension "css\\|gif\\|jpe?g\\|png\\|svg\\|pdf"
:publishing-directory "~/Public/personal"
:publishing-function org-publish-attachment
:recursive t)
("personal" :components ("personal-themes" "personal-html" "personal-files" "personal-assets"))
("journal"
:base-directory "~/org"
:exclude ".*"
:include ("journal.org")
:publishing-directory "~/journal"
:publishing-function (org-html-publish-to-html
org-latex-export-to-pdf))
("roam-html"
:base-directory "~/org/roam"
:base-extension "org"
:publishing-directory "~/Public/roam"
:recursive t
:with-toc nil
:section-numbers nil
:auto-sitemap nil
:publishing-function org-html-publish-to-html
:html-head "<link rel=\"stylesheet\" href=\"https://gongzhitaao.org/orgcss/org.css\"/>")
("roam-assets"
:base-directory "~/org/roam"
:base-extension "css\\|js\\|json\\|gif\\|jpe?g\\|png\\|svg\\|pdf"
:publishing-directory "~/Public/roam"
:publishing-function org-publish-attachment
:recursive t)
("roam" :components ("roam-html" "roam-assets"))
2019-09-13 14:54:23 +00:00
("sicp-html"
:base-directory "~/code/sicp"
:base-extension "org"
:publishing-directory "~/Public/sicp"
:publishing-function (org-html-publish-to-html
org-org-publish-to-org
org-babel-tangle-publish)
:htmlized-source t
:html-head "<link rel=\"stylesheet\" type=\"text/css\" href=\"http://thomasf.github.io/solarized-css/solarized-light.min.css\" />"
:html-link-home "/"
:html-doctype "html5"
:html-html5-fancy t
:with-sub-superscript nil
:auto-sitemap t
:sitemap-filename "index.org"
:sitemap-title "SICP Exercises and Notes"
:sitemap-sort-folders last
:recursive t)
("sicp-assets"
:base-directory "~/code/sicp"
:base-extension "css\\|gif\\|jpe?g\\|png\\|svg\\|scheme\\|pl"
:publishing-directory "~/Public/sicp"
:publishing-function org-publish-attachment
:recursive t)
2019-11-01 17:17:08 +00:00
("sicp" :components ("sicp-html" "sicp-assets"))))
2019-09-13 14:54:23 +00:00
;; Don't prompt for babel evaluation, ever.
(setq org-confirm-babel-evaluate nil)
(require 'ox-confluence)
(defun my/org-publish ()
2019-09-13 14:54:23 +00:00
(interactive)
(org-publish "work")
(let ((org-link-abbrev-alist (seq-concatenate 'list org-link-abbrev-alist
'(("jira" . "https://jira.aweber.io/browse/")
("gitlab" . "https://gitlab.aweber.io/")))))
(org-store-agenda-views))
2019-09-13 14:54:23 +00:00
(shell-command "org-publish"))
(bind-key "C-c o p" #'my/org-publish)
#+end_src
2021-01-21 03:08:37 +00:00
*** Enhanced Confluence export
Adds [[https://github.com/correl/ox-confluence-en][my own package]] that extends the built-in Confluence wiki markup exporter
with better formatting and macro support.
2019-09-13 14:54:23 +00:00
#+begin_src emacs-lisp
(use-package! ox-confluence-en
:after ox
:commands ox-confluence-en-export-as-confluence)
#+end_src
2021-01-21 03:08:37 +00:00
*** Reload images on source execution
Force images to redisplay after executing a source code block, so I can
immediately see the result of regenerating graphs and diagrams.
#+begin_src emacs-lisp
(defun my/redisplay-org-images ()
(when org-inline-image-overlays
(org-redisplay-inline-images)))
(add-hook 'org-babel-after-execute-hook
'my/redisplay-org-images)
#+end_src
2021-01-21 03:08:37 +00:00
*** Sticky headers
Keeps the current heading visible at the top of the Emacs window.
2019-12-05 19:16:21 +00:00
#+begin_src emacs-lisp
(use-package! org-sticky-header
:hook (org-mode . org-sticky-header-mode)
:config (setq org-sticky-header-full-path 'full))
#+end_src
2021-01-21 03:08:37 +00:00
*** Library of Babel
Load shared code snippets to be used in org documents.
#+begin_src emacs-lisp
(let ((org-dirs '("~/org" "~/org-aweber")))
(seq-map #'org-babel-lob-ingest
(seq-filter #'f-exists?
(seq-map (lambda (path) (f-join path "library-of-babel.org"))
org-dirs))))
#+end_src
2021-01-21 03:08:37 +00:00
*** Nicer looking timestamps
#+begin_src emacs-lisp
(setq org-time-stamp-custom-formats '("<%A, %B %d %Y>" . "<%A, %B %d %Y %H:%M>"))
(defun org-export-filter-timestamp-remove-brackets (timestamp backend info)
"removes relevant brackets from a timestamp"
(cond
((org-export-derived-backend-p backend 'latex)
(replace-regexp-in-string "[<>]\\|[][]" "" timestamp))
((org-export-derived-backend-p backend 'ascii)
(replace-regexp-in-string "[<>]\\|[][]" "" timestamp))
((org-export-derived-backend-p backend 'html)
(replace-regexp-in-string "&[lg]t;\\|[][]" "" timestamp))))
(after! ox
(add-to-list
'org-export-filter-timestamp-functions
'org-export-filter-timestamp-remove-brackets))
#+end_src
2021-01-21 03:08:37 +00:00
*** Tufte HTML
Gorgeous HTML exports.
#+begin_src emacs-lisp
(use-package! ox-tufte
:after ox)
#+end_src
2021-01-21 03:08:37 +00:00
*** Journal
2020-07-11 04:09:42 +00:00
#+begin_src emacs-lisp
(use-package org-journal
:if (f-dir? "~/org-aweber")
:custom
(org-journal-date-prefix "#+title: ")
(org-journal-file-format "%Y-%m-%d.org")
(org-journal-dir "~/org-aweber")
(org-journal-date-format "%A, %d %B %Y"))
#+end_src
2023-05-23 04:07:46 +00:00
*** Cookbook
#+begin_src emacs-lisp
(use-package! org-chef
:commands (org-chef-get-recipe-from-url))
#+end_src
2021-01-21 03:08:37 +00:00
*** Ref
Tools for linking and taking notes on books and papers.
2020-07-18 23:35:29 +00:00
#+begin_src emacs-lisp
(use-package! org-ref
:config
(setq reftex-default-bibliography my/bibliographies)
;; see org-ref for use of these variables
(setq org-ref-bibliography-notes "~/Documents/bibliography/notes.org"
org-ref-default-bibliography my/bibliographies
org-ref-pdf-directory "~/Documents/bibliography/bibtex-pdfs/"))
#+end_src
2021-01-21 03:08:37 +00:00
*** Roam
Powerful cross-linked note-taking.
https://orgroam.com
**** Capture templates
#+begin_src emacs-lisp
(setq org-roam-capture-templates
2022-10-29 04:33:55 +00:00
'(("d" "default" plain "%?" :target
(file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}
")
:unnarrowed t)))
#+end_src
2021-01-21 03:08:37 +00:00
**** Add backlinks to org-roam exports
#+begin_src emacs-lisp
(use-package! org-roam-export-backlinks
:commands org-roam-export-backlinks-preprocessor
:init
(add-to-list 'org-export-before-processing-hook
#'org-roam-export-backlinks-preprocessor))
#+end_src
2021-01-21 03:08:37 +00:00
**** Org Roam Bibtex
Make it easy to take notes on books and papers that I'm reading.
2020-07-18 23:35:29 +00:00
#+begin_src emacs-lisp
(use-package! org-roam-bibtex
:after org-roam
:hook (org-roam . org-roam-bibtex-mode)
:bind (:map org-mode-map
(("C-c n r b" . orb-note-actions))))
2020-07-18 23:35:29 +00:00
#+end_src
2022-10-29 04:33:55 +00:00
**** Org Roam UI
2021-01-21 03:08:37 +00:00
Provides a fun way to browse through a collection of notes.
2021-08-06 18:19:49 +00:00
#+begin_src emacs-lisp
(use-package! org-roam-ui
:after org-roam
:commands org-roam-ui-mode
:config
(setq org-roam-ui-sync-theme t
org-roam-ui-follow t
org-roam-ui-update-on-save t
org-roam-ui-open-on-start t))
#+end_src
2021-01-21 03:08:37 +00:00
**** Use writeroom in org-roam buffers
Makes for a much nicer note-taking experience.
#+begin_src emacs-lisp
(defun my/org-roam-writeroom ()
;; Use a buffer-local local variables hook to ensure the org-roam-directory is
;; set properly
(add-hook 'hack-local-variables-hook
(lambda ()
(when (and org-roam-directory
(f-ancestor-of?
(expand-file-name org-roam-directory)
(or (buffer-file-name) default-directory)))
(writeroom-mode t)))
nil t))
(add-hook! 'org-mode-hook #'my/org-roam-writeroom)
#+end_src
**** Provide seamless switching between org-roam slipboxes
When we visit a buffer in a different slip box (different =org-roam-directory=)
than we were visiting previously, ensure the cache is updated.
#+begin_src emacs-lisp
(defvar my/org-roam-directory-cache (list
(cons (expand-file-name org-roam-directory)
(expand-file-name org-roam-db-location))))
(after! savehist
(add-to-list 'savehist-additional-variables
'my/org-roam-directory-cache))
(defun my/org-roam-directory--lookup (path)
(alist-get path my/org-roam-directory-cache nil nil #'s-equals?))
(defun my/org-roam-directory--update ()
(setq my/org-roam-directory-cache
(cons (cons org-roam-directory org-roam-db-location)
(seq-filter
(lambda (x) (not (s-equals? org-roam-directory (car x))))
my/org-roam-directory-cache))))
(add-hook! 'org-roam-buffer-prepare-hook #'my/org-roam-directory--update)
(defun my/org-roam-find-in-directory ()
(interactive)
(let* ((org-roam-directory (completing-read "Roam Directory"
(mapcar #'car my/org-roam-directory-cache)))
(org-roam-db-location (my/org-roam-directory--lookup
org-roam-directory)))
(org-roam-find-file)))
(map! :leader
(:prefix-map ("n" . "notes")
(:prefix ("r" . "roam")
:desc "Find file in slipbox" "F" #'my/org-roam-find-in-directory)))
#+end_src
When setting up additional slipboxes, be sure to set both =org-roam-directory=
/and/ =org-roam-db-location=. An example =.dir-locals.el=:
#+begin_example
((nil . ((eval . (setq-local org-roam-directory (expand-file-name "./")
org-roam-db-location (expand-file-name "./org-roam.db"))))))
#+end_example
2021-01-21 03:08:37 +00:00
*** Sidebar
Display a sidebar with file-local todos and scheduling.
#+begin_src emacs-lisp
(use-package! org-sidebar
:bind (:map org-mode-map
(("C-c l v s" . org-sidebar-toggle)
("C-c l v S" . org-sidebar-tree-toggle)))
:commands (org-sidebar
org-sidebar-toggle
org-sidebar-tree
org-sidebar-tree-toggle))
#+end_src
2021-01-21 03:08:37 +00:00
*** Transclusion
Show linked org document sections inline.
#+begin_src emacs-lisp
(use-package! org-transclusion
2022-06-09 03:44:46 +00:00
:after org
:init
(map!
:map global-map "<f12>" #'org-transclusion-add
:leader
:prefix "n"
:desc "Org Transclusion Mode" "t" #'org-transclusion-mode))
#+end_src
*** Ditaa
Download and use a recent version of [[https://github.com/stathissideris/ditaa][ditaa]] for rendering ASCII diagrams.
#+begin_src emacs-lisp
(after! ob-ditaa
(let ((jar-url "https://github.com/stathissideris/ditaa/releases/download/v0.11.0/ditaa-0.11.0-standalone.jar")
(jar-path (concat doom-etc-dir "ditaa.jar")))
(unless (f-exists? jar-path)
(url-copy-file jar-url jar-path))
(setq org-ditaa-jar-path jar-path
org-ditaa-eps-jar-path jar-path)))
#+end_src
** ReStructuredText
#+begin_src emacs-lisp
(use-package! polymode
:defer t)
(use-package! poly-rst
:mode ("\\.rst\\'" . poly-rst-mode))
#+end_src
2021-01-21 03:08:37 +00:00
** Unfill
Does the opposite of =fill (M-q)=, removing line breaks from a paragraph or
region.
#+begin_src emacs-lisp
2021-01-21 03:08:37 +00:00
(use-package! unfill
:commands (unfill-paragraph
unfill-region)
:bind ("M-Q" . unfill-paragraph))
#+end_src
* Reading
** Epub reader
A major mode for reading and navigating =.epub= files.
#+begin_src emacs-lisp
(use-package! nov
:mode ("\\.epub\\'" . nov-mode)
:config
(setq nov-save-place-file (concat doom-cache-dir "nov-places")))
#+end_src
** Kanji Mode
Minor mode for displaying Japanese characters' stroke orders.
#+begin_src emacs-lisp
(use-package! kanji-mode
:commands kanji-mode)
#+end_src
** Kanji Glasses Mode
Study kanji by overlaying hiragana readings.
#+begin_src emacs-lisp
(use-package! kanji-glasses-mode
:commands kanji-glasses-mode)
#+end_src
* Coding
2023-02-05 22:41:44 +00:00
** Arduino
#+begin_src emacs-lisp
(use-package! arduino-mode
:mode "\\.ino\\'")
(use-package! arduino-cli-mode
:hook arduino-mode
:custom
(arduino-cli-warnings 'all)
(arduino-cli-verify t))
#+end_src
2021-01-21 03:08:37 +00:00
** Erlang
*** Kerl
Select the active erlang installation managed with [[https://github.com/kerl/kerl][kerl]].
#+begin_src emacs-lisp
(use-package! kerl
:commands (kerl-use))
#+end_src
** Lisp
*** Paredit
Adds shortcuts to edit the structure of lisp code.
#+begin_src emacs-lisp
(use-package! paredit
:hook ((emacs-lisp-mode . enable-paredit-mode)))
#+end_src
2023-02-04 06:12:44 +00:00
** OpenSCAD
Mode for editing OpenSCAD 3D modeling files. Files can be opened externally for
live-updated previews within OpenSCAD itself using =C-c C-o=.
#+begin_src emacs-lisp
(use-package! scad-mode
:mode "\\.scad\\'")
#+end_src
2021-01-21 03:08:37 +00:00
* Applications
** Email
Configure MU4E to read email synced from my personal and work accounts.
#+begin_src emacs-lisp
(use-package! mu4e
:bind (("<f9>" . mu4e))
:config
2019-09-13 15:25:02 +00:00
(require 'f)
(setq mu4e-maildir "~/Mail")
(setq user-full-name "Correl Roush")
(setq mu4e-contexts
(list (make-mu4e-context
:name "work"
:vars `((user-mail-address . "correlr@aweber.com")
2021-01-19 05:48:33 +00:00
(mu4e-drafts-folder . "/Work/[Gmail]/Drafts")
(mu4e-sent-folder . "/Work/[Gmail]/Sent Mail")
(mu4e-trash-folder . "/Work/[Gmail]/Trash")
(mu4e-maildir-shortcuts . (("/Work/INBOX" . ?i)
2021-01-19 05:48:33 +00:00
("/Work/[Gmail]/All Mail" . ?a)
("/Work/[Gmail]/Starred" . ?S)
("/Work/[Gmail]/Sent Mail" . ?s)
("/Work/[Gmail]/Trash" . ?t)))
(mu4e-compose-signature . ,(with-temp-buffer
(insert-file-contents "~/.signature-aweber")
2021-01-19 05:48:33 +00:00
(buffer-string)))
(smtpmail-smtp-user . "correlr@aweber.com")
2021-01-19 05:48:33 +00:00
(smtpmail-smtp-server . "smtp.gmail.com")
(smtpmail-smtp-service . 465)
(smtpmail-stream-type . ssl)))))
(when (f-exists?
(f-join mu4e-maildir "Personal"))
(add-to-list
'mu4e-contexts
(make-mu4e-context
:name "personal"
:vars `((user-mail-address . "correl@gmail.com")
2021-01-19 05:48:33 +00:00
(mu4e-drafts-folder . "/Personal/[Gmail]/Drafts")
(mu4e-sent-folder . "/Personal/[Gmail]/Sent Mail")
(mu4e-trash-folder . "/Personal/[Gmail]/Trash")
(mu4e-maildir-shortcuts . (("/Personal/INBOX" . ?i)
2021-01-19 05:48:33 +00:00
("/Personal/[Gmail]/All Mail" . ?a)
("/Personal/[Gmail]/Starred" . ?S)
("/Personal/[Gmail]/Sent Mail" . ?s)
("/Personal/[Gmail]/Trash" . ?t)))
(mu4e-compose-signature . ,(with-temp-buffer
(insert-file-contents "~/.signature")
2021-01-19 05:48:33 +00:00
(buffer-string)))
(smtpmail-smtp-user . "correl@gmail.com")
2021-01-19 05:48:33 +00:00
(smtpmail-smtp-server . "smtp.gmail.com")
(smtpmail-smtp-service . 465)
(smtpmail-stream-type . ssl)))))
(setq mu4e-context-policy 'pick-first)
(setq mu4e-compose-context-policy 'ask)
(setq mu4e-compose-dont-reply-to-self t)
2021-01-27 04:43:36 +00:00
(setq mu4e-index-lazy-check nil)
(setq mu4e-headers-include-related nil)
(setq mu4e-headers-skip-duplicates t)
(setq mu4e-user-mail-address-list '("correlr@aweber.com"
"correl@gmail.com")))
#+end_src
2021-01-26 15:38:18 +00:00
Prefer sending HTML-formatted messages with plain text as a fallback option
(alternative formats should be specified in increasing level of preference per
[[https://www.w3.org/Protocols/rfc1341/7_2_Multipart.html][RFC-1341]]).
#+begin_src emacs-lisp
(use-package! org-msg
2022-04-13 22:51:34 +00:00
:after mu4e
:config
(setq org-msg-default-alternatives '(text html)
org-msg-options "html-postamble:nil toc:nil author:nil email:nil ^:nil"))
2021-01-26 15:38:18 +00:00
#+end_src
2021-01-21 03:08:37 +00:00
** Chat
2021-06-02 03:01:45 +00:00
*** Circe
#+begin_src emacs-lisp
2021-06-02 03:01:45 +00:00
(after! circe
(set-irc-server!
"liberachat"
`(:tls nil
:host "znc.phoenixinquis.is-a-geek.org"
:port 8667
:nick "correl"
:user "correl/liberachat"
:pass (lambda (&rest _) (+pass-get-secret "Social/znc.phoenixinquis.is-a-geek.org/correl"))))
(set-irc-server!
"twitch"
`(:tls nil
:host "znc.phoenixinquis.is-a-geek.org"
:port 8667
:nick "correl"
:user "correl/twitch"
:pass (lambda (&rest _) (+pass-get-secret "Social/znc.phoenixinquis.is-a-geek.org/correl")))))
#+end_src
2021-01-21 03:08:37 +00:00
** Music
Configure EMMS for playing music files on my computer.
2021-01-21 03:08:37 +00:00
#+begin_src emacs-lisp
(use-package! emms
:commands (emms
emms-play-file
emms-play-directory
emms-smart-browse)
:config
(let ((emms-player-base-format-list
;; Add some VGM formats to the list for VLC to play
(append emms-player-base-format-list '("nsf" "spc" "gym"))))
(require 'emms-player-vlc))
(require 'emms-setup)
(emms-all)
(setq emms-player-list '(emms-player-vlc))
;; Use the installed VLC app if we're in OSX
(if (f-exists? "/Applications/VLC.app/Contents/MacOS/VLC")
(setq emms-player-vlc-command-name
"/Applications/VLC.app/Contents/MacOS/VLC")))
2021-01-21 03:08:37 +00:00
(map! :leader
(:prefix-map ("x" . "EMMS")
:desc "Play file" "f" #'emms-play-file
:desc "Play directory" "d" #'emms-play-directory
:desc "Smart Browser" "b" #'emms-smart-browse))
#+end_src
2021-01-21 03:08:37 +00:00
** News Aggregation
Read blogs and articles from the RSS feeds I follow.
2019-09-13 15:31:23 +00:00
#+begin_src emacs-lisp
(use-package! elfeed
:commands (elfeed my/elfeed my/elfeed-emacs my/elfeed-blogs)
:bind
(("<f2>" . elfeed)
("C-c n n" . my/elfeed)
("C-c n a" . my/elfeed-all)
("C-c n e" . my/elfeed-emacs)
("C-c n b" . my/elfeed-blogs))
:init
(global-set-key [f2] 'elfeed)
:config
(use-package! elfeed-org
:config (progn (elfeed-org)
(setq rmh-elfeed-org-files '("~/org/elfeed.org"))))
(defun my/elfeed-with-filters (filters)
(elfeed)
(setq elfeed-search-filter
(if (listp filters) (mapconcat #'identity filters " ")
filters))
(elfeed-search-update :force))
(defun my/elfeed ()
(interactive)
(my/elfeed-with-filters "@6-months-ago +unread"))
(defun my/elfeed-all ()
(interactive)
(my/elfeed-with-filters "@6-months-ago"))
(defun my/elfeed-emacs ()
(interactive)
(my/elfeed-with-filters "@6-months-ago +emacs +unread"))
(defun my/elfeed-blogs ()
(interactive)
(my/elfeed-with-filters "@6-months-ago +unread +blog"))
(add-hook! 'elfeed-show-mode-hook #'mixed-pitch-mode))
2019-09-13 15:31:23 +00:00
#+end_src
2021-01-21 03:08:37 +00:00
** Kubernetes
Manage a Kubernetes cluster and set up remote shell/file access via TRAMP.
2019-11-01 17:52:45 +00:00
2019-12-05 20:44:57 +00:00
#+begin_src emacs-lisp
(use-package! kubernetes
:commands (kubernetes-overview)
:config)
(set-popup-rule! "^\\*kubernetes" :ignore t)
2020-07-23 19:29:09 +00:00
(use-package! kubernetes-tramp
2022-04-13 22:51:34 +00:00
:commands (eshell find-file)
2020-07-23 19:29:09 +00:00
:config
(setq tramp-remote-shell-executable "sh"))
2019-12-05 20:44:57 +00:00
#+end_src
2021-01-21 03:08:37 +00:00
** Twitter
It's Twitter, in Emacs.
#+begin_src emacs-lisp
(define-key! twittering-mode-map
"f" #'twittering-favorite
"F" #'twittering-unfavorite)
#+end_src
2021-01-21 03:08:37 +00:00
** Project Management
*** Projectile
Pre-load Projectile with projects in my usual code directories.
2020-01-02 15:23:04 +00:00
#+begin_src emacs-lisp
2021-01-21 03:08:37 +00:00
(after! projectile
(require 'dash)
(require 'f)
(setq projectile-switch-project-action #'magit-status)
(let ((project-directories (-filter #'f-directory?
'("~/code"
"~/git"))))
(-map
(lambda (directory)
(-map (lambda (project)
(-> (concat project "/") ;; Projectile likes trailing slashes
(projectile-add-known-project)))
(-filter (lambda (f) (and (not (s-ends-with? "." f))
(f-directory? f)))
(-map (lambda (f) (concat directory "/" f))
(directory-files directory)))))
project-directories))
(projectile-cleanup-known-projects))
2020-01-02 15:23:04 +00:00
#+end_src
2021-01-21 03:08:37 +00:00
*** Jira
Add some commands for interacting with Jira within org documents.
2020-01-09 19:41:26 +00:00
#+begin_src emacs-lisp
2022-04-13 22:51:34 +00:00
(after! org
(use-package jira-api
:config (setq jira-api-host "jira.aweber.io"
jira-api-user "correlr"))
(defun my/org-clock-last-time-in-seconds ()
(save-excursion
(let ((end (save-excursion (org-end-of-subtree))))
(when (re-search-forward (concat org-clock-string
".*\\(\\[[^]]+\\]\\)--\\(\\[[^]]+\\]\\)")
end t)
(let* ((start (match-string 1))
(end (match-string 2)))
(floor (- (org-time-string-to-seconds end)
(org-time-string-to-seconds start))))))))
(defun my/org-jira-add-worklog-latest ()
(interactive)
(let ((jira-id (org-entry-get (point) "JIRA_ID"))
(seconds (my/org-clock-last-time-in-seconds)))
(when (and jira-id seconds)
(jira-api-log-work jira-id seconds)
(message
(format "Logged %d minutes to %s on JIRA"
(/ seconds 60)
jira-id)))))
(defun my/org-jira-add-worklog-total ()
(interactive)
(let ((jira-id (org-entry-get (point) "JIRA_ID"))
(seconds (* 60 (org-clock-sum-current-item))))
(when (and jira-id seconds)
(jira-api-log-work jira-id seconds)
(message
(format "Logged %d minutes to %s on JIRA"
(/ seconds 60)
jira-id)))))
(defun my/org-clock-add-jira-worklog-last ()
"Add a work log entry to a JIRA.
2020-01-09 19:41:26 +00:00
To log work to JIRA, set a property named JIRA_ID on the entry to be
logged to a JIRA issue ID."
2022-04-13 22:51:34 +00:00
(interactive)
(save-excursion
(save-window-excursion
(org-clock-goto)
(my/org-jira-add-worklog-latest))))
2020-01-09 19:41:26 +00:00
2022-04-13 22:51:34 +00:00
(defun my/org-jira-browse ()
(interactive)
(-if-let (jira-id (org-entry-get (point) "JIRA_ID"))
(let ((protocol (if jira-api-use-ssl "https" "http")))
(browse-url
(concat
protocol "://" jira-api-host "/browse/" jira-id)))))
2020-01-09 19:41:26 +00:00
2022-04-13 22:51:34 +00:00
(defun my/org-jira-list ()
(interactive)
(let ((buffer (generate-new-buffer "*org-jira*")))
(switch-to-buffer buffer)
(org-mode)
(insert "ohai")
(setq-local buffer-read-only t)
(display-buffer buffer)))
;; (add-hook 'org-clock-out-hook 'my/org-clock-add-jira-worklog-last)
(map! :map org-mode-map
"C-c j t" #'my/org-jira-add-worklog-total
"C-c j l" #'my/org-jira-add-worklog-latest
"C-c j b" #'my/org-jira-browse
"C-c j c" #'jira-api-create-issue-from-heading
"C-c j u" #'jira-api-update-issue-from-heading))
#+end_src
2021-06-24 15:03:02 +00:00
** Source Control
#+begin_src emacs-lisp
(after! forge
(add-to-list
'forge-alist
'("gitlab.aweber.io" "gitlab.aweber.io/api/v4" "gitlab.aweber.io" forge-gitlab-repository)))
#+end_src
2021-01-21 03:08:37 +00:00
** Eshell
*** Change directory in the context of a remote host
Add an =lcd= command that functions similarly to =cd=, but is scoped to the
remote host being accessed. Basically means I can use =lcd /= and other absolute
paths and not worry about being bounced back to my local filesystem.
2020-12-31 04:00:29 +00:00
#+begin_src emacs-lisp
2021-01-21 03:08:37 +00:00
(defun eshell/lcd (&optional directory)
(interactive)
(if (file-remote-p default-directory)
(with-parsed-tramp-file-name default-directory nil
(eshell/cd (tramp-make-tramp-file-name
(tramp-file-name-method v)
(tramp-file-name-user v)
(tramp-file-name-domain v)
(tramp-file-name-host v)
(tramp-file-name-port v)
(or directory "")
(tramp-file-name-hop v))))
(eshell/cd directory)))
#+end_src
*** Disable company autocompletion on remote hosts
#+begin_src emacs-lisp
(defun my/toggle-shell-autocomplete ()
(when (fboundp 'company-mode)
(company-mode (if (file-remote-p default-directory) -1 1))))
(add-hook! 'eshell-directory-change-hook #'my/toggle-shell-autocomplete)
#+end_src
2021-01-21 03:08:37 +00:00
** Background Processes
Manage background services
#+begin_src emacs-lisp
(use-package! prodigy
:defer 2
2020-12-31 04:00:29 +00:00
:config
2021-01-21 03:08:37 +00:00
(global-set-key (kbd "<f7>") 'prodigy)
2020-12-31 04:00:29 +00:00
2021-01-21 03:08:37 +00:00
(prodigy-define-tag
:name 'work)
(prodigy-define-tag
:name 'personal)
2020-12-31 04:00:29 +00:00
2021-01-21 03:08:37 +00:00
;; https://martinralbrecht.wordpress.com/2016/05/30/handling-email-with-emacs/
(when (executable-find "imapnotify")
(prodigy-define-tag
:name 'email
:ready-message "Checking Email using IMAP IDLE. Ctrl-C to shutdown.")
(prodigy-define-service
:name "imapnotify-work"
:command "imapnotify"
:args (list "-c" (expand-file-name "~/.config/imap_inotify/work.js"))
:tags '(email work autostart)
:kill-signal 'sigkill)
(unless (string-equal "croush" (user-login-name))
(prodigy-define-service
:name "imapnotify-personal"
:command "imapnotify"
:args (list "-c" (expand-file-name "~/.config/imap_inotify/personal.js"))
:tags '(email personal autostart)
:kill-signal 'sigkill)))
(when (f-exists? (expand-file-name "~/code/elm-dashboard"))
(prodigy-define-service
:name "elm-dashboard"
:command "python"
:args '("-m" "SimpleHTTPServer" "3000")
:cwd (expand-file-name "~/code/elm-dashboard")
:tags '(personal elm)
:stop-signal 'sigkill
:kill-process-buffer-on-stop t))
(when (f-exists? (expand-file-name "~/git/www"))
(prodigy-define-service
:name "AWeber WWW"
:command "npm"
:args '("start")
:cwd (expand-file-name "~/git/www")
:tags '(work)))
(when (f-exists? (expand-file-name "~/Public/org"))
(prodigy-define-service
:name "Org Documents"
:command "python"
:args '("-m" "http.server" "3001")
:cwd (expand-file-name "~/Public/org")
:tags '(work autostart)
:kill-signal 'sigkill))
2021-05-29 01:11:58 +00:00
(when (f-exists? (expand-file-name "~/Public/roam"))
(prodigy-define-service
:name "Org Roam Documents"
:command "python"
:args '("-m" "http.server" "3002")
:cwd (expand-file-name "~/Public/roam")
:tags '(personal autostart)
:kill-signal 'sigkill))
2021-01-21 03:08:37 +00:00
(mapcar
#'prodigy-start-service
(-concat (prodigy-services-tagged-with 'autostart))))
2020-12-31 04:00:29 +00:00
#+end_src
** Screen Sharing
*** Showing keypresses
#+begin_src emacs-lisp
(use-package! keypression
:commands (keypression-mode)
:bind (("C-c t k" . keypression-mode))
:config
(setq keypression-fade-out-delay 2.0
keypression-cast-command-name t
keypression-combine-same-keystrokes t
keypression-combine-format "%s (%d times)"
keypression-y-offset 100
keypression-font-face-attribute '(:height 400 :weight bold)))
#+end_src
2021-01-21 03:08:37 +00:00
** UUID Generation
#+begin_src emacs-lisp
2021-01-21 03:08:37 +00:00
(use-package! uuidgen
:commands (uuidgen))
#+end_src
2022-02-04 03:14:30 +00:00
** Wordle
#+begin_src emacs-lisp
(use-package! wordle
:commands (wordel wordel-marathon))
#+end_src
2021-01-21 03:08:37 +00:00
* Operating Systems
** Linux
*** EXWM
**** Set Emacs + EXWM as the default X window manager
2021-01-21 03:08:37 +00:00
#+begin_src sh :tangle ~/.dmrc
[Desktop]
session=~/.doom.d/start-exwm.sh
#+end_src
#+begin_src sh :tangle start-exwm.sh :shebang #!/bin/sh
emacs -mm -l ~/.doom.d/exwm.el
#+end_src
**** Configure EXWM
- Sets the desktop background
- Starts a bar/system tray and various applets
- Sets up workspaces
- Names X window buffers based on which application is running
#+begin_src emacs-lisp :tangle exwm.el
(defun my/exwm-update-class ()
(exwm-workspace-rename-buffer exwm-class-name))
(defun my/run-in-background (command)
(let ((command-parts (split-string command "[ ]+")))
(apply #'call-process `(,(car command-parts) nil 0 nil ,@(cdr command-parts)))))
(defun my/set-desktop-background ()
(interactive)
(start-process-shell-command "feh" nil "feh --bg-scale ~/Pictures/Wallpapers/1520742811045.png"))
(defun my/exwm-init-hook ()
;; Start tint2 bar
(my/run-in-background "tint2")
;; Start system tray applets
(my/run-in-background "nm-applet")
(my/run-in-background "pasystray")
(my/run-in-background "blueman-applet")
(my/run-in-background "nextcloud --background")
(my/run-in-background "compton"))
(use-package! exwm
:config
(setq exwm-input-global-keys
`(([?\s-r] . exwm-reset)
([?\s-w] . exwm-workspace-switch)
,@(mapcar (lambda (i)
`(,(kbd (format "s-%d" i)) .
(lambda ()
(interactive)
(exwm-workspace-switch-create ,(- i 1)))))
(number-sequence 1 9))
([?\s-&] . (lambda (command)
(interactive (list (read-shell-command "$ ")))
(start-process-shell-command command nil command)))))
(setq exwm-workspace-number 4)
(exwm-input-set-key (kbd "s-SPC") #'counsel-linux-app)
(add-hook! 'exwm-update-class-hook #'my/exwm-update-class)
(add-hook! 'exwm-init-hook #'my/exwm-init-hook)
(my/set-desktop-background)
(exwm-enable))
(use-package! exwm-config
:after exwm)
(use-package! desktop-environment
:after exwm
:config
(desktop-environment-mode))
#+end_src
2021-01-21 03:08:37 +00:00
***** Application launcher
Use counsel as an application launcher. Scans for =.desktop= files in all the
usual places.
2020-07-18 23:35:29 +00:00
#+begin_src emacs-lisp
2021-01-21 03:08:37 +00:00
(use-package! counsel
:custom (counsel-linux-app-format-function #'counsel-linux-app-format-function-name-only)
:config (counsel-mode 1))
2020-07-23 22:10:51 +00:00
#+end_src
2021-01-21 03:08:37 +00:00
** OSX
*** Editing binary-compressed plist files
From https://www.emacswiki.org/emacs/MacOSXPlist#toc1
#+begin_src emacs-lisp
;; Allow editing of binary .plist files.
(add-to-list 'jka-compr-compression-info-list
["\\.plist$"
"converting text XML to binary plist"
"plutil"
("-convert" "binary1" "-o" "-" "-")
"converting binary plist to text XML"
"plutil"
("-convert" "xml1" "-o" "-" "-")
nil nil "bplist"])
;;It is necessary to perform an update!
(jka-compr-update)
2020-07-18 23:35:29 +00:00
#+end_src
* Miscellaneous Nonsense
** BRING ON THE ...
A silly interactive method for generating horizontal and vertical text.
#+CAPTION: M-x bring-on-the RET cats RET
#+begin_example
B R I N G O N T H E C A T S
R
I
N
G
O
N
T
H
E
C
A
T
S
#+end_example
#+begin_src emacs-lisp
(defun bring-on-the (thing)
(interactive "sBring on the: ")
(let ((upthing (seq-into (s-upcase (s-concat "bring on the " thing)) 'list)))
(insert
(s-concat
(seq-into
(-interleave upthing (-repeat (length upthing) 32))
'string)
"\n"
(seq-into
(-interleave (rest upthing) (-repeat (1- (length upthing)) ?\n))
'string)))))
2020-01-09 19:41:26 +00:00
#+end_src
** OwO Mode
Make reading an open buffer an exercise in insanity.
#+begin_src emacs-lisp
(use-package! owo-mode
:commands owo-mode)
#+end_src
2022-02-07 17:05:51 +00:00
** Elcord
Emits rich presence to Discord.
#+begin_src emacs-lisp
(use-package! elcord
:config
(setq elcord-display-buffer-details nil
2022-05-13 15:22:16 +00:00
elcord-quiet t
elcord-editor-icon "emacs_material_icon"
elcord-use-major-mode-as-main-icon t)
2022-02-07 17:05:51 +00:00
(elcord-mode t))
#+end_src