From a5cf5c46890dde2b2cd9e1769ad29915d54d73a7 Mon Sep 17 00:00:00 2001 From: J S Date: Mon, 13 Nov 2023 14:53:57 -0500 Subject: [PATCH] feat[packages]: Moved init.el and packages.el I moved packages.el and init.el into config.org. This makes my config.org a completely flexible file, any doom emacs installation will use it. Style: Changed capital #+BEGIN_SRC and #+END_SRC to lowercase. Changed theme to simple black-and-white Packages: Distributed `package!` statements throughout the config, to exist near the relevant configuration. org-plot: Stole tecosaur's plot theme configuration to autoconfigure org-plot themes. --- config.org | 945 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 671 insertions(+), 274 deletions(-) diff --git a/config.org b/config.org index 6cff3f6..2c732c6 100644 --- a/config.org +++ b/config.org @@ -6,64 +6,75 @@ Welcome to my configuration! I hope you enjoy your time here :) It's not all very well documented, but I have done my best to split everything into a logical order. Perhaps in 10 years I will still be using it, but who knows. + * Task List ** TODO Reorganize into use-cases rather than packages * Setting Basics -#+BEGIN_SRC emacs-lisp +** Packages +#+begin_src emacs-lisp :tangle "packages.el" +;; -*- no-byte-compile: t; -*- +#+end_src + +** Set name, org-roam-directory, etc. +Some basic settings for Emacs +#+begin_src emacs-lisp (setq tab-always-indent t) (setq org-roam-directory "~/org/") (setq user-full-name "Judah Sotomayor" user-mail-address "") -#+END_SRC +#+end_src +#+begin_src emacs-lisp :tangle "packages.el" +(package! noCtrlC + :recipe (:host nil :type git :repo "https://git.freedomland.xyz/judahsotomayor/noctrlc")) +#+end_src + * Theme and Font Set the theme. /Use something dark/ +I also prefer relative line numbers because of *evil* mode+ Relative line numbers don't work, because of foling in Org-mode. -#+BEGIN_SRC emacs-lisp -(setq doom-theme 'doom-dark+) +#+begin_src emacs-lisp +(setq doom-theme 'doom-homage-black) (setq doom-font (font-spec :family "Hack Nerd Font Mono" :size 16 :weight 'medium)) (setq auto-save-default nil) ;I don't like autosaving. Let me do it myself. -#+END_SRC - +#+end_src ** Doom splash screen I really don't like the widgets, and I think it takes longer to load so I get rid of them -#+BEGIN_SRC emacs-lisp +#+begin_src emacs-lisp (remove-hook '+doom-dashboard-functions #'doom-dashboard-widget-shortmenu) (remove-hook '+doom-dashboard-functions #'doom-dashboard-widget-footer) -#+END_SRC +#+end_src Set a sweet splash image -#+BEGIN_SRC emacs-lisp +#+begin_src emacs-lisp (setq fancy-splash-image (concat doom-private-dir "emacs.png")) -#+END_SRC - +#+end_src * Evil configuration I want a non-ESC way to get back to normal mode: -#+BEGIN_SRC emacs-lisp +#+begin_src emacs-lisp (map! :desc "Switch to normal mode" :i "C-c" #'evil-normal-state) -#+END_SRC +#+end_src * Terminal setup I like to just use bash: -#+BEGIN_SRC emacs-lisp +#+begin_src emacs-lisp (defun bash () (interactive) (term "/bin/bash")) (map! :desc "Start a bash shell" "" #'bash) -#+END_SRC +#+end_src I don't like the modeline in the terminal. -#+BEGIN_SRC emacs-lisp +#+begin_src emacs-lisp (add-hook 'term-mode-hook 'hide-mode-line-mode) -#+END_SRC +#+end_src * Sage-math -#+BEGIN_SRC emacs-lisp +#+begin_src emacs-lisp (use-package! sage-shell-mode :defer) @@ -74,53 +85,29 @@ I don't like the modeline in the terminal. ;; C-c c for asynchronous evaluating (only for SageMath code blocks). (with-eval-after-load "org" (define-key org-mode-map (kbd "C-c c") 'ob-sagemath-execute-async)) -#+END_SRC +#+end_src I like to have a shortcut for calc as well, for simpler calculations -#+BEGIN_SRC emacs-lisp +#+begin_src emacs-lisp (map! :leader :desc "The Emacs Calculator" "C" #'calc) -#+END_SRC +#+end_src * Beancount ** FavaGTK :outdated: I want to launch favagtk more easily. Let's do that here: -#+BEGIN_SRC emacs-lisp +#+begin_src emacs-lisp (defun fava () (interactive) (async-shell-command "flatpak run org.gnome.gitlab.johannesjh.favagtk")) (map! :leader :desc "Start favagtk" "r b" #'fava) -#+END_SRC -* Graphing Applications -** Mermaid.js -Mermaid.js requires the mmcli executable from npm. -Mermaid is a tool that allows you to graph many kinds of entities: -- Relationship diagrams -- Flowcharts -- Gantt diagrams -There's other kinds too. -The package on ELPA is perfect. Needs no config, fits right in with Babel. -#+BEGIN_SRC emacs-lisp -(use-package! ob-mermaid) -#+END_SRC - -** SVGBob -SVGBob is an ASCII art renderer. It can do all kinds of nifty things with just a few basic .------./\ -#+BEGIN_SRC emacs-lisp -(use-package! ob-svgbob) -(setq org-svgbob-executable "svgbob_cli") - -(setq org-babel-svgbob--parameters - '(:background transparent - )) -#+END_SRC -* Fun Stuff +#+end_src * Useful Functions ** Get the date from the shell I want to grab the current date and put it in the buffer. Because I sometimes use Fish or another shell, it's good to make sure bash is running the command using the src_bash{`-c`} flag. -#+BEGIN_SRC emacs-lisp +#+begin_src emacs-lisp (defun current-date () (interactive) (shell-command-to-string " bash -c 'echo -n $(date +%Y-%m-%d)'")) (defun insert-current-date () (interactive) @@ -129,13 +116,17 @@ Because I sometimes use Fish or another shell, it's good to make sure bash is ru (map! :leader :desc "Insert the current date into the buffer" "i d" #'insert-current-date) -#+END_SRC +#+end_src * Creating Diagrams and graphs ** TODO set default values using org-babel's features for that. * Securing Sensitive Files ** Age.el -#+BEGIN_SRC emacs-lisp +#+begin_src emacs-lisp :tangle "packages.el" +(package! age) +#+end_src +*** Config +#+begin_src emacs-lisp (use-package! age :ensure t :demand t @@ -145,31 +136,36 @@ Because I sometimes use Fish or another shell, it's good to make sure bash is ru (age-default-recipient "~/.age/personal.pub") :config (age-file-enable)) -#+END_SRC +#+end_src ** Org-mode security settings These mostly concern limiting evaluation of code-blocks without confirmation. The final two lines concern local variables, which may try to evaluate code. Emacs has better default values now, so it will ask to evaluate local variables. -#+BEGIN_SRC emacs-lisp +#+begin_src emacs-lisp (setq org-confirm-babel-evaluate t) (setq org-link-shell-confirm-function t) (setq org-link-elisp-confirm-function t) (setq enable-local-variables t) (setq enable-local-eval 'maybe) -#+END_SRC +#+end_src +#+begin_src emacs-lisp + (setq templates/post-capture-props "#+date: [%<%Y-%m-%d %a>]\n#+lastmod:\n#+categories[]:\n#+tags[]:\n#+images[]: ") + (setq templates/post-capture-title "#+TITLE: ${title}\n") + (setq templates/post-capture-template (concat templates/post-capture-title templates/post-capture-props)) +#+end_src * Org-mode for a great todo list ** Making the Agenda features more efficient -#+BEGIN_SRC emacs-lisp :tangle no +#+begin_src emacs-lisp :tangle no (dolist (file (org-roam-list-files)) - (message "processing %s" file) - (with-current-buffer (or (find-buffer-visiting file) - (find-file-noselect file)) - (vulpea-project-update-tag) - (save-buffer))) -#+END_SRC +(message "processing %s" file) +(with-current-buffer (or (find-buffer-visiting file) + (find-file-noselect file)) +(vulpea-project-update-tag) +(save-buffer))) +#+end_src #+RESULTS: @@ -180,64 +176,64 @@ This section is contributed from [[https://gist.github.com/d12frosted/a60e8ccb9a I ripped out the essentials because I don't want all the other stuff in that package. -#+BEGIN_SRC emacs-lisp +#+begin_src emacs-lisp (after! org-roam (defun vulpea-project-p () - "Return non-nil if current buffer has any todo entry. +"Return non-nil if current buffer has any todo entry. TODO entries marked as done are ignored, meaning the this function returns nil if current buffer contains only completed tasks." - (seq-find ; (3) - (lambda (type) - (eq type 'todo)) - (org-element-map ; (2) - (org-element-parse-buffer 'headline) ; (1) - 'headline - (lambda (h) - (org-element-property :todo-type h))))) +(seq-find ; (3) +(lambda (type) +(eq type 'todo)) +(org-element-map ; (2) +(org-element-parse-buffer 'headline) ; (1) +'headline +(lambda (h) +(org-element-property :todo-type h))))) (defun vulpea-project-update-tag () - "Update PROJECT tag in the current buffer." - (when (and (not (active-minibuffer-window)) - (vulpea-buffer-p)) - (save-excursion - (goto-char (point-min)) - (let* ((tags (vulpea-buffer-tags-get)) - (original-tags tags)) - (if (vulpea-project-p) - (setq tags (cons "hastodos" tags)) - (setq tags (remove "hastodos" tags))) +"Update PROJECT tag in the current buffer." +(when (and (not (active-minibuffer-window)) + (vulpea-buffer-p)) +(save-excursion +(goto-char (point-min)) +(let* ((tags (vulpea-buffer-tags-get)) + (original-tags tags)) + (if (vulpea-project-p) + (setq tags (cons "hastodos" tags)) + (setq tags (remove "hastodos" tags))) - ;; cleanup duplicates - (setq tags (seq-uniq tags)) + ;; cleanup duplicates + (setq tags (seq-uniq tags)) - ;; update tags if changed - (when (or (seq-difference tags original-tags) - (seq-difference original-tags tags)) - (apply #'vulpea-buffer-tags-set tags)))))) + ;; update tags if changed + (when (or (seq-difference tags original-tags) + (seq-difference original-tags tags)) + (apply #'vulpea-buffer-tags-set tags)))))) (defun vulpea-buffer-p () - "Return non-nil if the currently visited buffer is a note." - (and buffer-file-name - (string-prefix-p - (expand-file-name (file-name-as-directory org-roam-directory)) - (file-name-directory buffer-file-name)))) +"Return non-nil if the currently visited buffer is a note." +(and buffer-file-name +(string-prefix-p +(expand-file-name (file-name-as-directory org-roam-directory)) +(file-name-directory buffer-file-name)))) (defun vulpea-project-files () - "Return a list of note files containing 'hastodos' tag." ; - (seq-uniq - (seq-map - #'car - (org-roam-db-query - [:select [nodes:file] - :from tags - :left-join nodes - :on (= tags:node-id nodes:id) - :where (like tag (quote "%\"hastodos\"%"))])))) +"Return a list of note files containing 'hastodos' tag." ; +(seq-uniq +(seq-map +#'car +(org-roam-db-query +[:select [nodes:file] +:from tags +:left-join nodes +:on (= tags:node-id nodes:id) +:where (like tag (quote "%\"hastodos\"%"))])))) (defun vulpea-agenda-files-update (&rest _) - "Update the value of `org-agenda-files'." - (setq org-agenda-files (vulpea-project-files))) +"Update the value of `org-agenda-files'." +(setq org-agenda-files (vulpea-project-files))) (add-hook 'find-file-hook #'vulpea-project-update-tag) (add-hook 'before-save-hook #'vulpea-project-update-tag) @@ -249,50 +245,50 @@ tasks." ;; https://github.com/d12frosted/vulpea/blob/6a735c34f1f64e1f70da77989e9ce8da7864e5ff/vulpea-buffer.el (defun vulpea-buffer-tags-get () - "Return filetags value in current buffer." - (vulpea-buffer-prop-get-list "filetags" "[ :]")) +"Return filetags value in current buffer." +(vulpea-buffer-prop-get-list "filetags" "[ :]")) (defun vulpea-buffer-tags-set (&rest tags) - "Set TAGS in current buffer. +"Set TAGS in current buffer. If filetags value is already set, replace it." - (if tags - (vulpea-buffer-prop-set - "filetags" (concat ":" (string-join tags ":") ":")) - (vulpea-buffer-prop-remove "filetags"))) +(if tags +(vulpea-buffer-prop-set +"filetags" (concat ":" (string-join tags ":") ":")) +(vulpea-buffer-prop-remove "filetags"))) (defun vulpea-buffer-tags-add (tag) - "Add a TAG to filetags in current buffer." - (let* ((tags (vulpea-buffer-tags-get)) - (tags (append tags (list tag)))) - (apply #'vulpea-buffer-tags-set tags))) +"Add a TAG to filetags in current buffer." +(let* ((tags (vulpea-buffer-tags-get)) + (tags (append tags (list tag)))) +(apply #'vulpea-buffer-tags-set tags))) (defun vulpea-buffer-tags-remove (tag) - "Remove a TAG from filetags in current buffer." - (let* ((tags (vulpea-buffer-tags-get)) - (tags (delete tag tags))) - (apply #'vulpea-buffer-tags-set tags))) +"Remove a TAG from filetags in current buffer." +(let* ((tags (vulpea-buffer-tags-get)) + (tags (delete tag tags))) +(apply #'vulpea-buffer-tags-set tags))) (defun vulpea-buffer-prop-set (name value) - "Set a file property called NAME to VALUE in buffer file. +"Set a file property called NAME to VALUE in buffer file. If the property is already set, replace its value." - (setq name (downcase name)) - (org-with-point-at 1 - (let ((case-fold-search t)) - (if (re-search-forward (concat "^#\\+" name ":\\(.*\\)") - (point-max) t) - (replace-match (concat "#+" name ": " value) 'fixedcase) - (while (and (not (eobp)) - (looking-at "^[#:]")) - (if (save-excursion (end-of-line) (eobp)) - (progn - (end-of-line) - (insert "\n")) - (forward-line) - (beginning-of-line))) - (insert "#+" name ": " value "\n"))))) +(setq name (downcase name)) +(org-with-point-at 1 +(let ((case-fold-search t)) +(if (re-search-forward (concat "^#\\+" name ":\\(.*\\)") + (point-max) t) + (replace-match (concat "#+" name ": " value) 'fixedcase) +(while (and (not (eobp)) + (looking-at "^[#:]")) + (if (save-excursion (end-of-line) (eobp)) + (progn + (end-of-line) + (insert "\n")) + (forward-line) + (beginning-of-line))) +(insert "#+" name ": " value "\n"))))) (defun vulpea-buffer-prop-set-list (name values &optional separators) - "Set a file property called NAME to VALUES in current buffer. +"Set a file property called NAME to VALUES in current buffer. VALUES are quoted and combined into single string using `combine-and-quote-strings'. If SEPARATORS is non-nil, it should be a regular expression @@ -300,131 +296,151 @@ matching text that separates, but is not part of, the substrings. If nil it defaults to `split-string-default-separators', normally \"[ \f\t\n\r\v]+\", and OMIT-NULLS is forced to t. If the property is already set, replace its value." - (vulpea-buffer-prop-set - name (combine-and-quote-strings values separators))) +(vulpea-buffer-prop-set +name (combine-and-quote-strings values separators))) (defun vulpea-buffer-prop-get (name) - "Get a buffer property called NAME as a string." - (org-with-point-at 1 - (when (re-search-forward (concat "^#\\+" name ": \\(.*\\)") - (point-max) t) - (buffer-substring-no-properties - (match-beginning 1) - (match-end 1))))) +"Get a buffer property called NAME as a string." +(org-with-point-at 1 +(when (re-search-forward (concat "^#\\+" name ": \\(.*\\)") + (point-max) t) +(buffer-substring-no-properties +(match-beginning 1) +(match-end 1))))) (defun vulpea-buffer-prop-get-list (name &optional separators) - "Get a buffer property NAME as a list using SEPARATORS. +"Get a buffer property NAME as a list using SEPARATORS. If SEPARATORS is non-nil, it should be a regular expression matching text that separates, but is not part of, the substrings. If nil it defaults to `split-string-default-separators', normally \"[ \f\t\n\r\v]+\", and OMIT-NULLS is forced to t." - (let ((value (vulpea-buffer-prop-get name))) - (when (and value (not (string-empty-p value))) - (split-string-and-unquote value separators)))) +(let ((value (vulpea-buffer-prop-get name))) +(when (and value (not (string-empty-p value))) +(split-string-and-unquote value separators)))) (defun vulpea-buffer-prop-remove (name) - "Remove a buffer property called NAME." - (org-with-point-at 1 - (when (re-search-forward (concat "\\(^#\\+" name ":.*\n?\\)") - (point-max) t) - (replace-match "")))) +"Remove a buffer property called NAME." +(org-with-point-at 1 +(when (re-search-forward (concat "\\(^#\\+" name ":.*\n?\\)") + (point-max) t) +(replace-match "")))) - (setq org-agenda-files (vulpea-project-files))) - #+END_SRC +(setq org-agenda-files (vulpea-project-files))) +#+end_src ** Basic settings -#+BEGIN_SRC emacs-lisp - (setq org-log-done 'time) - (after! org-mode - (setq org-log-done 'time) - (add-to-list 'org-tags-exclude-from-inheritance "hastodos") - (setq org-hide-emphasis-markers nil)) +#+begin_src emacs-lisp +(setq org-log-done 'time) +(after! org-mode +(setq org-log-done 'time) +(add-to-list 'org-tags-exclude-from-inheritance "hastodos") +(setq org-hide-emphasis-markers nil)) +(setq org-directory "~/org/") +(setq org-roam-directory org-directory) - (setq org-directory "~/org/") - (setq org-roam-directory org-directory) - -#+END_SRC +#+end_src ** Appearances *** Deprecated: TODO Keywords I like to have a few different todo keywords for different sorts of activities. Purchasing todos: -#+BEGIN_SRC emacs-lisp :tangle no +#+begin_src emacs-lisp :tangle no (setq org-todo-keywords - '((sequence "PROJ(p)" "|" "COMPLETE") - (type "TICKLE") - (type "DELE") - (type "WAIT") - (sequence "TODO(t)" "|" "DONE") - (sequence "DELEGATED" "VERIFY" "|" "DONE") - (sequence "BUY(b)" "|" "BOUGHT") - )) +'((sequence "PROJ(p)" "|" "COMPLETE") +(type "TICKLE") +(type "DELE") +(type "WAIT") +(sequence "TODO(t)" "|" "DONE") +(sequence "DELEGATED" "VERIFY" "|" "DONE") +(sequence "BUY(b)" "|" "BOUGHT") +)) (setq org-todo-keyword-faces - '(("TODO" . "salmon1") - ("START" . "spring green" ) - ("DELE" . "gold") - ("TICKLE" . "magenta") - ("WAIT" . "gold") - ("PROJ" . "deep sky blue"))) -#+END_SRC +'(("TODO" . "salmon1") +("START" . "spring green" ) +("DELE" . "gold") +("TICKLE" . "magenta") +("WAIT" . "gold") +("PROJ" . "deep sky blue"))) +#+end_src These settings aren't very useful for me, as I like default colors and keywords. *** Deprecated: Settings for org-modern -#+BEGIN_SRC emacs-lisp :tangle no +#+begin_src emacs-lisp :tangle no (setq org-modern-todo-faces - '(("START" :background "spring green" :foreground "black") - ("DELE" :background "gold" :foreground "black") - ("WAIT" :background "gold" :foreground "black") - ("PROJ" :background "deep sky blue" :foreground "black") - ("TICKLE" :background "magenta" :foreground "black"))) +'(("START" :background "spring green" :foreground "black") +("DELE" :background "gold" :foreground "black") +("WAIT" :background "gold" :foreground "black") +("PROJ" :background "deep sky blue" :foreground "black") +("TICKLE" :background "magenta" :foreground "black"))) (setq org-modern-priority-faces - '((?A :background "salmon1" :foreground "black") - (?B :background "gold" :foreground "black") - (?C :background "spring green" :foreground "black"))) -#+END_SRC +'((?A :background "salmon1" :foreground "black") +(?B :background "gold" :foreground "black") +(?C :background "spring green" :foreground "black"))) +#+end_src I currently have org-modern stripped out of my config. I probably won't need this again, but in case I do I want all my preferences to be there. *** Images Preferences We want to show images when loading a file, and also after evaluating code blocks. -#+BEGIN_SRC emacs-lisp +#+begin_src emacs-lisp (setq org-startup-with-inline-images t) ;; Show images after evaluating code blocks. (add-hook 'org-babel-after-execute-hook 'org-display-inline-images) -#+END_SRC +#+end_src +*** Org-agenda deadlines +I don't like agenda nagging me about upcoming events. +It causes a lot of duplication! +#+begin_src emacs-lisp +(setq org-deadline-warning-days 0) +#+end_src +Turn it off with this snippet. ** Org-drill Set some good keybinds for quick access: -#+BEGIN_SRC emacs-lisp +#+begin_src emacs-lisp (use-package! org-drill - :defer nil - ) +:defer nil +) - (map! :leader - :desc "Start org-drill" - "d d" #'org-drill-directory) +(map! :leader +:desc "Start org-drill" +"d d" #'org-drill-directory) - (map! :leader - :desc "Start org-drill in cram mode" - "d c" #'org-drill-cram) -#+END_SRC +(map! :leader +:desc "Start org-drill in cram mode" +"d c" #'org-drill-cram) +#+end_src ** ob-lilypond -#+BEGIN_SRC emacs-lisp +*** package +#+begin_src emacs-lisp :tangle "packages.el" +(package! ob-lilypond + :recipe (:host github :type git :repo "mjago/ob-lilypond")) +#+end_src +*** config +#+begin_src emacs-lisp (use-package! ob-lilypond) (setq ly-arrange-mode t) -#+END_SRC +#+end_src ** org-edna +#+begin_src emacs-lisp :tangle "packages.el" +(package! org-edna) +#+end_src Edna allows better dependency handling for todos and the like. -#+BEGIN_SRC emacs-lisp +#+begin_src emacs-lisp (use-package! org-edna) (org-edna-mode) -#+END_SRC +#+end_src ** Org-habit -#+BEGIN_SRC emacs-lisp +#+begin_src emacs-lisp :tangle "packages.el" +(package! org-heatmap + :recipe (:host github :type git :repo "aspiers/org-heatmap")) +#+end_src + +#+begin_src emacs-lisp (use-package org-habit :custom @@ -437,39 +453,56 @@ Edna allows better dependency handling for todos and the like. :after (org) :config (org-heatmap-mode)) -#+END_SRC +#+end_src + ** Org-archive with structure Many thanks to Mark Edigmar's [[https://gist.github.com/edgimar/072d99d8650abe81a9fe7c8687c0c993][Gist]] *** Keymaps -#+BEGIN_SRC emacs-lisp +#+begin_src emacs-lisp (map! :leader :desc "Archive subtree" :n "m A" #'org-archive-subtree-default) -#+END_SRC +#+end_src +** Anki editing in org-mode +#+begin_src emacs-lisp :tangle packages.el +(package! anki-editor) +#+end_src +** calfw Calendar View +#+begin_src emacs-lisp :tangle "packages.el" +(package! calfw + :recipe (:host github :type git :repo "haji-ali/emacs-calfw")) +#+end_src * Website ** Capture template -#+BEGIN_SRC emacs-lisp +#+begin_src emacs-lisp (setq templates/post-capture-props "#+date: [%<%Y-%m-%d %a>]\n#+lastmod:\n#+categories[]:\n#+tags[]:\n#+images[]: ") (setq templates/post-capture-title "#+TITLE: ${title}\n") (setq templates/post-capture-template (concat templates/post-capture-title templates/post-capture-props)) -#+END_SRC -** Images -#+BEGIN_SRC emacs-lisp -(setq org-preview-latex-image-directory (concat org-directory (file-name-as-directory "images/latexsnip"))) -#+END_SRC +#+end_src + + +#+begin_src emacs-lisp +(add-to-list 'org-roam-capture-templates + '("m" "Markdown" plain "" :target + (file+head "training-resources/content/${title}.md" +"---\ntitle: ${title}\nid: %<%Y-%m-%dT%H%M%S>\ncategory: \n---\n") + :unnarrowed t)) +#+end_src + + ** Hugo base directory -#+BEGIN_SRC emacs-lisp +#+begin_src emacs-lisp (setq org-hugo-base-dir (concat org-directory (file-name-as-directory "website"))) (setq org-hugo-default-section-directory "posts") -#+END_SRC +#+end_src * Crafting a Writing Environment For writing I like to automate as much as possible. This means creating an environment that does citations and such /for/ me. ** Export settings *** Ox-latex -#+BEGIN_SRC emacs-lisp +#+begin_src emacs-lisp (after! org ;; Import ox-latex to get org-latex-classes and other funcitonality ;; for exporting to LaTeX from org @@ -484,24 +517,24 @@ This means creating an environment that does citations and such /for/ me. (unless (boundp 'org-latex-classes) (setq org-latex-classes nil)))) -#+END_SRC +#+end_src *** Lualatex as PDF Processor I've found that lualatex does a good job processing PDFs. $hi$ -#+BEGIN_SRC emacs-lisp +#+begin_src emacs-lisp (after! ox-latex (setq org-latex-pdf-process '("lualatex --output-directory=/home/user/Documents -shell-escape -interaction nonstopmode %f" "lualatex --output-directory=/home/user/Documents -shell-escape -interaction nonstopmode %f")) ) -#+END_SRC +#+end_src $x + 1 = 3$ #+RESULTS: : luamagick -#+BEGIN_SRC emacs-lisp +#+begin_src emacs-lisp (setq-default org-html-with-latex `dvisvgm) @@ -592,13 +625,13 @@ $x + 1 = 3$ ("\\section{%s}" . "\\section*{%s}") ("\\subsection{%s}" . "\\subsection*{%s}"))) -#+END_SRC +#+end_src #+RESULTS: | mcdowellcv | \documentclass[]{mcdowellcv} | *** Fixing dvipng image handling -#+BEGIN_SRC emacs-lisp +#+begin_src emacs-lisp (defun +org-refresh-latex-images-previews-h () (dolist (buffer (doom-buffers-in-mode 'org-mode (buffer-list))) @@ -609,9 +642,9 @@ $x + 1 = 3$ (org--latex-preview-region (point-min) (point-max)))))) (add-hook 'doom-load-theme-hook #'+org-refresh-latex-images-previews-h) -#+END_SRC +#+end_src *** Export Function -#+BEGIN_SRC emacs-lisp +#+begin_src emacs-lisp (defun eww-open-this-file () (set 'directory (file-name-directory buffer-file-name)) (set 'filename (file-name-sans-extension buffer-file-name)) @@ -631,14 +664,14 @@ $x + 1 = 3$ (message "Failed") ) ) -#+END_SRC +#+end_src We'll want a handy shortcut for this. -#+BEGIN_SRC emacs-lisp +#+begin_src emacs-lisp (map! :leader :desc "Export to html and diplay with eww" "r E" #'org-export-and-open-eww) -#+END_SRC +#+end_src #+RESULTS: : /home/user/.config/doom/ @@ -648,7 +681,7 @@ We want a general [[file:~/org/references.bib][bibliography file]], a [[file:~/Z and a default set of styles. *** Citar setup First of all, we must configure citar. -#+BEGIN_SRC emacs-lisp +#+begin_src emacs-lisp (use-package! citar :ensure t :demand t @@ -666,10 +699,10 @@ First of all, we must configure citar. (LaTeX-mode . citar-capf-setup) (org-mode . citar-capf-setup)) (citar-org-roam-mode) -#+END_SRC +#+end_src *** Icons for some prettification -#+BEGIN_SRC emacs-lisp +#+begin_src emacs-lisp (after! citar (setq citar-indicator-files-icons (citar-indicator-create @@ -715,13 +748,12 @@ First of all, we must configure citar. citar-indicator-links-icons citar-indicator-notes-icons citar-indicator-cited-icons))) -#+END_SRC - +#+end_src ** Scholarly Writing Environment with Org-mode I like to keep formatting simple. Let's use a package or two to set a decent document class: -#+BEGIN_SRC emacs-lisp +#+begin_src emacs-lisp (add-to-list 'org-latex-classes '("student-apa7" "\\documentclass[stu]{apa7} @@ -738,6 +770,7 @@ Let's use a package or two to set a decent document class: (add-to-list 'org-latex-classes '("student-turabian" "\\documentclass{turabian-researchpaper} +\\usepackage{times} [NO-DEFAULT-PACKAGES] [NO-PACKAGES]" ("\\section{%s}" . "\\section*{%s}") @@ -759,23 +792,27 @@ Let's use a package or two to set a decent document class: ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))) ;; org-latex-compilers = ("pdflatex" "xelatex" "lualatex"), which are the possible values for %latex -#+END_SRC +#+end_src *** Engraving Faces Ever wonder why code export sucks with \LaTeX ? Me neither! Let's fix it! -#+BEGIN_SRC emacs-lisp +#+begin_src emacs-lisp :tangle "packages.el" +(package! engrave-faces) +#+end_src +#+begin_src emacs-lisp (use-package! engrave-faces) (setq org-latex-listings 'engraved) -#+END_SRC +#+end_src ** Zettelkasten environment with org-roam Org-roam enables features essential to a Zettelkasten such as inter-ID linking. -#+BEGIN_SRC emacs-lisp + +#+begin_src emacs-lisp (use-package! org-roam :after md-roam :init (setq org-roam-directory "~/org/")) :custom -#+END_SRC +#+end_src -#+BEGIN_SRC emacs-lisp +#+begin_src emacs-lisp (after! org-roam :ensure t :custom @@ -805,13 +842,13 @@ Org-roam enables features essential to a Zettelkasten such as inter-ID linking. "#+TITLE: ${title}\n#+FILETAGS: :secure:noexport:\n#+HTML_HEAD: \n\n\n* No Export Below This Line") :unnarrowed t)))) -#+END_SRC +#+end_src *** Keybinds Org-roam has many commands, of which I have bound the most important below. This entails creating a local leader. I use =r= for this purpose. It is close and goes well with *roam*. -#+BEGIN_SRC emacs-lisp +#+begin_src emacs-lisp (after! org-roam (map! :leader (:prefix ("r" . "roam") :desc "Search for a node in org-roam files" @@ -841,9 +878,14 @@ I use =r= for this purpose. It is close and goes well with *roam*. (map! :desc "Alternative keybind to insert a roam link while in insert mode" :i "M-[" #'org-roam-node-insert)) -#+END_SRC +#+end_src *** Nice UI to access Zettelkasten notes with Org-roam ui -#+BEGIN_SRC emacs-lisp + +**** Package +#+begin_src emacs-lisp :tangle packages.el +(package! org-roam-ui) +#+end_src +#+begin_src emacs-lisp (use-package! websocket :after org-roam) @@ -861,26 +903,26 @@ I use =r= for this purpose. It is close and goes well with *roam*. (after! org-roam-ui (map! :leader (:prefix ("r" . "roam") (:prefix ("u" . "roam-ui") - :desc "Focus the current node in org-roam-ui view" + :desc "focus the current node in org-roam-ui view" "f" #'org-roam-ui-node-zoom - :desc "Focus the current node's local graph in org-roam-ui view" + :desc "focus the current node's local graph in org-roam-ui view" "l" #'org-roam-ui-node-local - :desc "Begin org-roam ui mode" + :desc "begin org-roam ui mode" "u" #'open-org-roam-ui )))) #+END_SRC **** Function to pull up org-roam ui -#+BEGIN_SRC emacs-lisp +#+begin_src emacs-lisp (defun open-org-roam-ui () (interactive) (org-roam-ui-mode) (async-shell-command "surf http://localhost:35901/")) -#+END_SRC +#+end_src *** Default Browser for Export -#+BEGIN_SRC emacs-lisp +#+begin_src emacs-lisp (setq browse-url-browser-function 'browse-url-generic browse-url-generic-program "surf") @@ -891,20 +933,20 @@ I use =r= for this purpose. It is close and goes well with *roam*. ("\\.x?html?\\'" . "surf %s") ("\\.pdf\\'" . default)))) -#+END_SRC +#+end_src ** Journal Environment with org-roam -#+BEGIN_SRC emacs-lisp +#+begin_src emacs-lisp (after! org-roam (setq org-roam-dailies-capture-templates `(("d" "default" entry "* %?" :target (file+head "%<%Y-%m-%d>.sec.org.age" "#+title: %<%Y-%m-%d>\n"))))) -#+END_SRC +#+end_src *** Property getters and setters These are to fulfill my need to get property values for generating my [[id:6672f401-32a1-49ef-8004-ac77ece67f5b][journal index]]. -#+BEGIN_SRC emacs-lisp +#+begin_src emacs-lisp (require 'cl-lib) (defun org-global-props-key-re (key) @@ -932,18 +974,18 @@ Adding up values for one key is supported." val))) ret)) -#+END_SRC +#+end_src ** Resume setup for a stellar CV *** ox-extra for ":ignore:" tags I want to be able to ignore headings on export. -#+BEGIN_SRC emacs-lisp +#+begin_src emacs-lisp (after! org (use-package! ox-extra :config (ox-extras-activate '(latex-header-blocks ignore-headlines)))) -#+END_SRC +#+end_src *** Resume template -#+BEGIN_SRC emacs-lisp +#+begin_src emacs-lisp (add-to-list 'org-latex-classes '("altacv" "\\documentclass[10pt,a4paper,ragged2e,withhyper]{altacv} \\usepackage[rm]{roboto} @@ -987,10 +1029,10 @@ I want to be able to ignore headings on export. ("\\cvsection{%s}" . "\\cvsection*{%s}") ("\\cvevent{%s}" . "\\cvevent*{%s}"))) -#+END_SRC +#+end_src *** McDowell Resume Template This template is supposed to be the standard. -#+BEGIN_SRC emacs-lisp +#+begin_src emacs-lisp (add-to-list 'org-latex-classes '("mcdowellcv" "\\documentclass[]{mcdowellcv} @@ -1006,37 +1048,49 @@ This template is supposed to be the standard. ("\\cvsection{%s}" . "\\cvsection*{%s}") ("\\cvevent{%s}" . "\\cvevent*{%s}"))) -#+END_SRC +#+end_src ** Better EViL keybinds *** Remapping =g-j/k= -#+BEGIN_SRC emacs-lisp +#+begin_src emacs-lisp (map! :n "g j" #'evil-next-visual-line) (map! :n "g k" #'evil-previous-visual-line) -#+END_SRC +#+end_src * Company-mode for great autocompletes I don't really want company-mode to run on timeouts. I want VIM-like autocompletion, where =C-x o= and friends gives me my autocompletion. -#+BEGIN_SRC emacs-lisp +#+begin_src emacs-lisp (after! company-mode (setq company-idle-delay nil)) (setq company-idle-delay nil) -#+END_SRC +#+end_src * Initializing shell environment variables -#+BEGIN_SRC emacs-lisp +** Package +#+begin_src emacs-lisp :tangle "packages.el" +(package! exec-path-from-shell) +#+end_src +** Config +We need to bring in the correct SSH agent values, so that Emacs is aware of where it is running. +#+begin_src emacs-lisp (use-package! exec-path-from-shell) (after! exec-path-from-shell (dolist (var '("SSH_AUTH_SOCK" "SSH_AGENT_PID" "GPG_AGENT_INFO")) (add-to-list 'exec-path-from-shell-variables var)) (exec-path-from-shell-initialize) ) -#+END_SRC +#+end_src * Md-roam -#+BEGIN_SRC emacs-lisp +** Packages +#+begin_src emacs-lisp :tangle "packages.el" +(package! md-roam + :recipe (:host github :repo "nobiot/md-roam")) +#+end_src +** Config +#+begin_src emacs-lisp ;; file-truename is optional; it seems required when you use symbolic ;; links, which Org-roam does not resolve (use-package! md-roam @@ -1047,12 +1101,355 @@ I want VIM-like autocompletion, where =C-x o= and friends gives me my autocomple (setq md-roam-use-org-extract-ref nil) (org-roam-db-autosync-mode 1)) -#+END_SRC +#+end_src ** COMMENT Capture template for documentation -#+BEGIN_SRC emacs-lisp +#+begin_src emacs-lisp (add-to-list 'org-roam-capture-templates '("m" "Markdown" plain "" :target (file+head "training-resources/content/${title}.md" "---\ntitle: ${title}\nid: %<%Y-%m-%dT%H%M%S>\ncategory: \n---\n") :unnarrowed t)) -#+END_SRC +#+end_src + +* Funny Stuff +** Spray +#+begin_src emacs-lisp +(use-package! spray + :commands spray-mode) +#+end_src + +#+begin_src emacs-lisp +(add-to-list 'org-tags-exclude-from-inheritance "hastodos") +#+end_src + + +* Graphics in org-mode +** Org Plot[fn:1] +Org-plot can be enabled by a flag in the init file. +We can use some of the variables in =org-plot= to use the current doom theme +colours. +#+begin_src emacs-lisp +(defvar +org-plot-term-size '(1050 . 650) + "The size of the GNUPlot terminal, in the form (WIDTH . HEIGHT).") + +(after! org-plot + (defun +org-plot-generate-theme (_type) + "Use the current Doom theme colours to generate a GnuPlot preamble." + (format " +fgt = \"textcolor rgb '%s'\" # foreground text +fgat = \"textcolor rgb '%s'\" # foreground alt text +fgl = \"linecolor rgb '%s'\" # foreground line +fgal = \"linecolor rgb '%s'\" # foreground alt line + +# foreground colors +set border lc rgb '%s' +# change text colors of tics +set xtics @fgt +set ytics @fgt +# change text colors of labels +set title @fgt +set xlabel @fgt +set ylabel @fgt +# change a text color of key +set key @fgt + +# line styles +set linetype 1 lw 2 lc rgb '%s' # red +set linetype 2 lw 2 lc rgb '%s' # blue +set linetype 3 lw 2 lc rgb '%s' # green +set linetype 4 lw 2 lc rgb '%s' # magenta +set linetype 5 lw 2 lc rgb '%s' # orange +set linetype 6 lw 2 lc rgb '%s' # yellow +set linetype 7 lw 2 lc rgb '%s' # teal +set linetype 8 lw 2 lc rgb '%s' # violet + +# border styles +set tics out nomirror +set border 3 + +# palette +set palette maxcolors 8 +set palette defined ( 0 '%s',\ +1 '%s',\ +2 '%s',\ +3 '%s',\ +4 '%s',\ +5 '%s',\ +6 '%s',\ +7 '%s' ) +" + (doom-color 'fg) + (doom-color 'fg-alt) + (doom-color 'fg) + (doom-color 'fg-alt) + (doom-color 'fg) + ;; colours + (doom-color 'red) + (doom-color 'blue) + (doom-color 'green) + (doom-color 'magenta) + (doom-color 'orange) + (doom-color 'yellow) + (doom-color 'teal) + (doom-color 'violet) + ;; duplicated + (doom-color 'red) + (doom-color 'blue) + (doom-color 'green) + (doom-color 'magenta) + (doom-color 'orange) + (doom-color 'yellow) + (doom-color 'teal) + (doom-color 'violet))) + + (defun +org-plot-gnuplot-term-properties (_type) + (format "background rgb '%s' size %s,%s" + (doom-color 'bg) (car +org-plot-term-size) (cdr +org-plot-term-size))) +#+end_src + +Now use the preamble we created: +#+begin_src emacs-lisp + (setq org-plot/gnuplot-script-preamble #'+org-plot-generate-theme) + (setq org-plot/gnuplot-term-extra #'+org-plot-gnuplot-term-properties)) +#+end_src + +** Mermaid.js +Mermaid.js requires the mmcli executable from npm. +Mermaid is a tool that allows you to graph many kinds of entities: +- Relationship diagrams +- Flowcharts +- Gantt diagrams +There's other kinds too. +The package on ELPA is perfect. Needs no config, fits right in with Babel. +*** Package +#+begin_src emacs-lisp :tangle "packages.el" +(package! ob-mermaid) +#+end_src +*** Config +#+begin_src emacs-lisp +(use-package! ob-mermaid) +#+end_src + +** SVGBob +SVGBob is an ASCII art renderer. It can do all kinds of nifty things with just a few basic .------./\ +*** Package +#+begin_src emacs-lisp :tangle "packages.el" +(package! ob-svgbob + :recipe (:host nil :type git :repo "https://git.tecosaur.net/tec/ob-svgbob")) +#+end_src + +*** Configuration +#+begin_src emacs-lisp +(use-package! ob-svgbob) +(setq org-svgbob-executable "svgbob_cli") + +(setq org-babel-svgbob--parameters + '(:background transparent)) +#+end_src + + + + +* Init.el +I like to have all my config in one place. +#+begin_src emacs-lisp :tangle "init.el" +;;; init.el -*- lexical-binding: t; -*- + +;; This file controls what Doom modules are enabled and what order they load +;; in. Remember to run 'doom sync' after modifying it! + +;; NOTE Press 'SPC h d h' (or 'C-h d h' for non-vim users) to access Doom's +;; documentation. There you'll find a link to Doom's Module Index where all +;; of our modules are listed, including what flags they support. + +;; NOTE Move your cursor over a module's name (or its flags) and press 'K' (or +;; 'C-c c k' for non-vim users) to view its documentation. This works on +;; flags as well (those symbols that start with a plus). +;; +;; Alternatively, press 'gd' (or 'C-c c d') on a module to browse its +;; directory (for easy access to its source code). + +(doom! :input + ;;bidi ; (tfel ot) thgir etirw uoy gnipleh + ;;chinese + ;;japanese + ;;layout ; auie,ctsrnm is the superior home row + + :completion + company ; the ultimate code completion backend + ;;helm + ;;ido + ;;ivy + vertico ; the search engine of the future + + :ui + ;;deft ; notational velocity for Emacs + doom ; what makes DOOM look the way it does + doom-dashboard ; a nifty splash screen for Emacs + ;;doom-quit ; DOOM quit-message prompts when you quit Emacs + ;;(emoji +unicode) ; 🙂 + hl-todo ; highlight TODO/FIXME/NOTE/DEPRECATED/HACK/REVIEW + ;;hydra + indent-guides ; highlighted indent columns + ligatures ; ligatures and symbols to make your code pretty again + ;;minimap ; show a map of the code on the side + modeline ; snazzy, Atom-inspired modeline, plus API + nav-flash ; blink cursor line after big motions + ;;neotree ; a project drawer, like NERDTree for vim + ophints ; highlight the region an operation acts on + (popup +defaults) ; tame sudden yet inevitable temporary windows + ;;tabs ; a tab bar for Emacs + treemacs ; a project drawer, like neotree but cooler + ;;unicode ; extended unicode support for various languages + (vc-gutter +pretty) ; vcs diff in the fringe + vi-tilde-fringe ; fringe tildes to mark beyond EOB + window-select ; visually switch windows + ;;workspaces ; tab emulation, persistence & separate workspaces + zen ; distraction-free coding or writing + + :editor + (evil +everywhere); come to the dark side, we have cookies + file-templates ; auto-snippets for empty files + fold ; (nigh) universal code folding + (format ) ; automated prettiness + ;;god ; run Emacs commands without modifier keys + ;;lispy ; vim for lisp, for people who don't like vim + ;;multiple-cursors ; editing in many places at once + ;;objed ; text object editing for the innocent + ;;parinfer ; turn lisp into python, sort of + ;;rotate-text ; cycle region at point between text candidates + snippets ; my elves. They type so I don't have to + word-wrap ; soft wrapping with language-aware indent + + :emacs + (dired +icons) ; making dired pretty [functional] + electric ; smarter, keyword-based electric-indent + ibuffer ; interactive buffer management + undo ; persistent, smarter undo for your inevitable mistakes + vc ; version-control and Emacs, sitting in a tree + + :term + ;;eshell ; the elisp shell that works everywhere + ;;shell ; simple shell REPL for Emacs + term ; basic terminal emulator for Emacs + ;;vterm ; the best terminal emulation in Emacs + + :checkers + (syntax +flymake ) ; tasing you for every semicolon you forget + (spell +flyspell +everywhere) ; tasing you for misspelling mispelling + grammar ; tasing grammar mistake every you make + + :tools + ;;ansible + (biblio +icons) ; Writes a PhD for you (citation needed) + ;;debugger ; FIXME stepping through code, to help you add bugs + ;;direnv + ;;docker + editorconfig ; let someone else argue about tabs vs spaces + ;;ein ; tame Jupyter notebooks with emacs + (eval +overlay) ; run code, run (also, repls) + ;;gist ; interacting with github gists + (lookup +dictionary +offline) ; navigate your code and its documentation + lsp ; M-x vscode + magit ; a git porcelain for Emacs + ;;make ; run make tasks from Emacs + ;;pass ; password manager for nerds + pdf ; pdf enhancements + ;;prodigy ; FIXME managing external services & code builders + ;;rgb ; creating color strings + ;;taskrunner ; taskrunner for all your projects + ;;terraform ; infrastructure as code + ;;tmux ; an API for interacting with tmux + ;;tree-sitter ; syntax and parsing, sitting in a tree... + ;;upload ; map local to remote projects via ssh/ftp + + :os + ;;(:if IS-MAC macos) ; improve compatibility with macOS + ;;tty ; improve the terminal Emacs experience + + :lang + ;;agda ; types of types of types of types... + (beancount +lsp) ; mind the GAAP + (cc +lsp) ; C > C++ == 1 + ;;clojure ; java with a lisp + ;;common-lisp ; if you've seen one lisp, you've seen them all + ;;coq ; proofs-as-programs + ;;crystal ; ruby at the speed of c + ;;csharp ; unity, .NET, and mono shenanigans + data ; config/data formats + ;;(dart +flutter) ; paint ui and not much else + ;;dhall + ;;elixir ; erlang done right + ;;elm ; care for a cup of TEA? + emacs-lisp ; drown in parentheses + ;;erlang ; an elegant language for a more civilized age + ;;ess ; emacs speaks statistics + ;;factor + ;;faust ; dsp, but you get to keep your soul + ;;fortran ; in FORTRAN, GOD is REAL (unless declared INTEGER) + ;;fsharp ; ML stands for Microsoft's Language + ;;fstar ; (dependent) types and (monadic) effects and Z3 + ;;gdscript ; the language you waited for + ;;(go +lsp) ; the hipster dialect + ;;(graphql +lsp) ; Give queries a REST + ;;(haskell +lsp) ; a language that's lazier than I am + ;;hy ; readability of scheme w/ speed of python + ;;idris ; a language you can depend on + ;;json ; At least it ain't XML + ;;(java +lsp) ; the poster child for carpal tunnel syndrome + ;;javascript ; all(hope(abandon(ye(who(enter(here)))))) + ;;julia ; a better, faster MATLAB + ;;kotlin ; a better, slicker Java(Script) + (latex +lsp +cdlatex +fold) ; writing papers in Emacs has never been so fun + ;;lean ; for folks with too much to prove + ;;ledger ; be audit you can be + lua ; one-based indices? one-based indices + markdown ; writing docs for people to ignore + ;;nim ; python + lisp at the speed of c + ;;nix ; I hereby declare "nix geht mehr!" + ;;ocaml ; an objective camel + (org +roam2 +gnuplot +hugo +pomodoro +noter +present +pretty) ; organize your plain life in plain text + ;;php ; perl's insecure younger brother + ;;plantuml ; diagrams for confusing people more + ;;purescript ; javascript, but functional + python ; beautiful is better than ugly + ;;qt ; the 'cutest' gui framework ever + ;;racket ; a DSL for DSLs + ;;raku ; the artist formerly known as perl6 + ;;rest ; Emacs as a REST client + ;;rst ; ReST in peace + ;;(ruby +rails) ; 1.step {|i| p "Ruby is #{i.even? ? 'love' : 'life'}"} + (rust +lsp) ; Fe2O3.unwrap().unwrap().unwrap().unwrap() + ;;scala ; java, but good + ;;(scheme +guile) ; a fully conniving family of lisps + sh ; she sells {ba,z,fi}sh shells on the C xor + ;;sml + ;;solidity ; do you need a blockchain? No. + ;;swift ; who asked for emoji variables? + ;;terra ; Earth and Moon in alignment for performance. + web ; the tubes + ;;yaml ; JSON, but readable + ;zig ; C, but simpler + + :email + ;;(mu4e +org +gmail) + ;;notmuch + ;;(wanderlust +gmail) + + :app + calendar + ;;emmgs + ;;everywhere ; *leave* Emacs!? You must be joking + ;;irc ; how neckbeards socialize + ;;(rss +org) ; emacs as an RSS reader + ;;twitter ; twitter client https://twitter.com/vnought + + :config + literate + (default +bindings +smartparens) + +) +#+end_src + +* Footnotes +[fn:1] Stolen from Tecosaur's [[https://git.tecosaur.net/tec/emacs-config][config]]