An approximation of my previous emacs config.

From this point on all changes should be incremental versioned commits.
This commit is contained in:
James Patrick 2023-01-30 14:47:45 -05:00
parent 1eac8e9ad0
commit a169dc29ca
7 changed files with 671 additions and 75 deletions

14
emacs/+keybinds.el Normal file
View File

@ -0,0 +1,14 @@
;;; +keybinds.el -*- lexical-binding: t; -*-
(setq doom-localleader-key ",")
(map! :leader
(:when (modulep! :lang org +roam2)
(:prefix-map ("r" . "roam")
:desc "Find node" "/" #'org-roam-node-find
:desc "Capture to node" "n" #'org-roam-capture
:desc "Capture Today" "c" #'org-roam-dailies-capture-today
:desc "Goto Today" "t" #'org-roam-dailies-goto-today
)
)
)

139
emacs/+orgmode.el Normal file
View File

@ -0,0 +1,139 @@
;;; +orgmode.el -*- lexical-binding: t; -*-
(require 'org)
(custom-set-variables '(org-directory "~/org/"))
(setq
org-download-image-dir (concat org-directory ".attach/"))
(setq
org-roam-directory (concat org-directory "Roam/"))
(setq org-agenda-files (list (concat org-directory "Todos/" )))
(defvar-local +org-capture-work-todo
(expand-file-name "Work/todo.org" org-directory))
(add-to-list 'org-capture-templates
'("w" "Work Todo" entry
(file+headline +org-capture-work-todo-file "Inbox")
"* [_] %?%i\n%a" :prepend t))
(add-hook! 'org-mode-hook #'mixed-pitch-mode)
(add-hook! 'org-mode-hook #'+org-pretty-mode)
(setq org-agenda-deadline-faces
'((1.001 . error)
(1.0 . org-warning)
(0.5 . org-upcoming-deadline)
(0.0 . org-upcoming-distant-deadline)))
(add-hook 'org-mode-hook (lambda ()
"Beautify Org Checkbox Symbol"`
(push '("[ ]" . "") prettify-symbols-alist)
(push '("[_]" . "") prettify-symbols-alist)
(push '("[X]" . "" ) prettify-symbols-alist)
(push '("[-]" . "" ) prettify-symbols-alist)
(prettify-symbols-mode)))
(setq prettify-symbols-unprettify-at-point 'right-edge)
(with-eval-after-load 'org
(defvar-local rasmus/org-at-src-begin -1
"Variable that holds whether last position was a ")
(defvar rasmus/ob-header-symbol ?☰
"Symbol used for babel headers")
(defun rasmus/org-prettify-src--update ()
(let ((case-fold-search t)
(re "^[ \t]*#\\+begin_src[ \t]+[^ \f\t\n\r\v]+[ \t]*")
found)
(save-excursion
(goto-char (point-min))
(while (re-search-forward re nil t)
(goto-char (match-end 0))
(let ((args (org-trim
(buffer-substring-no-properties (point)
(line-end-position)))))
(when (org-string-nw-p args)
(let ((new-cell (cons args rasmus/ob-header-symbol)))
(cl-pushnew new-cell prettify-symbols-alist :test #'equal)
(cl-pushnew new-cell found :test #'equal)))))
(setq prettify-symbols-alist
(cl-set-difference prettify-symbols-alist
(cl-set-difference
(cl-remove-if-not
(lambda (elm)
(eq (cdr elm) rasmus/ob-header-symbol))
prettify-symbols-alist)
found :test #'equal)))
;; Clean up old font-lock-keywords.
(font-lock-remove-keywords nil prettify-symbols--keywords)
(setq prettify-symbols--keywords (prettify-symbols--make-keywords))
(font-lock-add-keywords nil prettify-symbols--keywords)
(while (re-search-forward re nil t)
(font-lock-flush (line-beginning-position) (line-end-position))))))
(defun rasmus/org-prettify-src ()
"Hide src options via `prettify-symbols-mode'.
`prettify-symbols-mode' is used because it has uncollpasing. It's
may not be efficient."
(let* ((case-fold-search t)
(at-src-block (save-excursion
(beginning-of-line)
(looking-at "^[ \t]*#\\+begin_src[ \t]+[^ \f\t\n\r\v]+[ \t]*"))))
;; Test if we moved out of a block.
(when (or (and rasmus/org-at-src-begin
(not at-src-block))
;; File was just opened.
(eq rasmus/org-at-src-begin -1))
(rasmus/org-prettify-src--update))
;; Remove composition if at line; doesn't work properly.
;; (when at-src-block
;; (with-silent-modifications
;; (remove-text-properties (match-end 0)
;; (1+ (line-end-position))
;; '(composition))))
(setq rasmus/org-at-src-begin at-src-block)))
;; This function helps to produce a single glyph out of a
;; string. The glyph can then be used in prettify-symbols-alist.
;; This function was provided by Ihor in the org-mode mailing list.
(defun yant/str-to-glyph (str)
"Transform string into glyph, displayed correctly."
(let ((composition nil))
(dolist (char (string-to-list str)
(nreverse (cdr composition)))
(push char composition)
(push '(Br . Bl) composition))))
(defun rasmus/org-prettify-symbols ()
(mapc (apply-partially 'add-to-list 'prettify-symbols-alist)
(cl-reduce 'append
(mapcar (lambda (x) (list x (cons (upcase (car x)) (cdr x))))
`(("#+begin_src" . ?⎡) ;; ⎡ ➤ 🖝 ➟ ➤ ✎
;; multi-character strings can be used with something like this:
;; ("#+begin_src" . ,(yant/str-to-glyph "```"))
("#+end_src" . ?⎣) ;; ⎣ ✐
("#+header:" . ,rasmus/ob-header-symbol)
("#+begin_quote" . )
("#+end_quote" . )))))
(turn-on-prettify-symbols-mode)
(add-hook 'post-command-hook 'rasmus/org-prettify-src t t))
(add-hook 'org-mode-hook #'rasmus/org-prettify-symbols))
(setq org-roam-dailies-capture-templates
'(("l" "Log" entry "* %T %?"
:target (file+head+olp "%<%Y-%m-%d>.org"
"#+title: %<%Y-%m-%d>\n#+filetags: %<:%Y:%B:>\n"
("Log")))
("g" "Goal" entry "* TODO %? :mit:"
:target (file+head+olp "%<%Y-%m-%d>.org"
"#+title: %<%Y-%m-%d>\n#+filetags: %<:%Y:%B:>\n"
("Goals")))))
;(add-hook! 'org-mode-hook #'solaire-mode)
;(add-hook 'mixed-pitch-mode-hook #'solaire-mode-reset)

View File

Before

Width:  |  Height:  |  Size: 327 KiB

After

Width:  |  Height:  |  Size: 327 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

View File

@ -1 +1,32 @@
;;; config.el -*- lexical-binding: t; -*-
(setq which-key-idle-delay 0.1)
(setq doom-fallback-buffer-name "Doom"
+doom-dashboard-name "Doom Dashboard")
(setq frame-title-format
'(""
(:eval
(if (s-contains-p org-roam-directory (or buffer-file-name ""))
(replace-regexp-in-string
".*/[0-9]*-?" ""
(subst-char-in-string ?_ ? buffer-file-name))
"%b"))
(:eval
(let ((project-name (projectile-project-name)))
(unless (string= "-" project-name)
(format (if (buffer-modified-p) " ♢ %s" " ♦ %s") project-name))))))
(setq doom-font (font-spec :family "Hasklig" :size 14 :height 1)
doom-variable-pitch-font (font-spec :family "Alegreya" :height 1.3)
doom-big-font (font-spec :family "Hasklig" :size 18))
(setq fancy-splash-image (concat doom-user-dir "./.resources/doom.png"))
(setq ispell-dictionary "en"
ispell-personal-dictionary "~/org/.ispell.en.pws")
(load! "+keybinds")
(load! "+orgmode")

View File

@ -1,17 +1,17 @@
#+title: Doom Emacs Configuration
I'll fill out the how and why of this all as I figure out what the hell I'm doing. My current Emacs Configuration is a mess of copy and pasted snippet loosely grouped together. There's a fair number of work around, to transient configuration issues that now no longer exist, and more of stuff cribbed off StackOverflow & held together with string & bubble gum. While not yet calling Configuration Bankrupty, I am going to try to see if I can restructure this technical debt.
I'll fill out the how and why of this all as I figure out what the hell I'm doing. My current Emacs Configuration is a mess of copy and pasted snippet loosely grouped together. There's a fair number of work around, to transient configuration issues that now no longer exist, and more of stuff cribbed off StackOverflow & held together with string & bubble gum. While not yet calling Configuration Bankrupt's, I am going to try to see if I can restructure this technical debt.
This Emacs configuration is written using the [[https://en.wikipedia.org/wiki/Literate_programming][Literate Programming]] (sort of) paradigm (well sort of) proposed by [[https://en.wikipedia.org/wiki/Donald_Knuth][Donald Knuth]] in 1984, and uses Hlissner's awesome [[https://github.com/doomemacs/doomemacs][Doom Emacs]] configuration framework.
While I like Literate Programming, I kind of think that literate configuration is largely a mixed bag. Literate Programming produces often more words then code. For even medium size configurations discoveribility & readability of what is happening can be bogged down in the weight of prose explaining the backstory, current thought, moral ponderings, pros & cons, and deciding thoughts. This extra cruft potentially makes understanding more through, but at cost of readiblity & readability is king. As a compromise I'm going to version both to the verbose =config.org= file and all of the produced configuration files. As an example about that verbosity mentioned prior this entire paragram could have been skipped.
While I like Literate Programming, I kind of think that literate configuration is largely a mixed bag. Literate Programming produces often more words then code. For even medium size configurations discoverability & readability of what is happening can be bogged down in the weight of prose explaining the backstory, current thought, moral pondering, pros & cons, and deciding thoughts. This extra cruft potentially makes understanding more through, but at cost of readability & readability is king. As a compromise I'm going to version both to the verbose =config.org= file and all of the produced configuration files. As an example about that verbosity mentioned prior this entire paragraph could have been skipped.
* Document Structure
This section will be the what & how of things. There will no directly tangled code in this section.
** Doom Emacs
This is built on top of Hlissner's awesome [[https://github.com/doomemacs/doomemacs][Doom Emacs]] configuration frameworks. Configuraiton is divided into 150 modules, & fair number of convience functions. Rather than detailing stuff about I'll say to go read [[https://github.com/doomemacs/doomemacs/blob/master/docs/faq.org][FAQs]] & [[https://github.com/doomemacs/doomemacs/blob/master/docs/index.org][Index]].
This is built on top of Hlissner's awesome [[https://github.com/doomemacs/doomemacs][Doom Emacs]] configuration frameworks. Configuration is divided into 150 modules, & fair number of convenience functions. Rather than detailing stuff about I'll say to go read [[https://github.com/doomemacs/doomemacs/blob/master/docs/faq.org][FAQs]] & [[https://github.com/doomemacs/doomemacs/blob/master/docs/index.org][Index]].
Configuration is located in the ~DOOMDIR~ directory. This is default value is located is the ~$HOME/.doom.d~ directory. Typically this directory contains:
@ -60,8 +60,8 @@ will produce
NOTE: unless you explicitly turn off the named code block will be tangled into =config.el=. Use the no tangle option if you want to disable this.
* Doom Configuration
** Misc
*** Lexical Bindings.
** Configuration
*** Lexical Bindings
There [[https://nullprogram.com/blog/2016/12/22/][minor but non-zero start time benefits]] for using Lexical Bindings comments. All files created should start with
#+BEGIN_SRC emacs-lisp
@ -70,8 +70,45 @@ There [[https://nullprogram.com/blog/2016/12/22/][minor but non-zero start time
replace =config.el= with the filename being loaded.
** Modules
The configuration is below is pulled from the template init.example.el provided by doom. This one is based off commit [[https://github.com/doomemacs/doomemacs/blob/e96624926d724aff98e862221422cd7124a99c19/templates/init.example.el][e966249]].
*** Speedup =whichkey= response
=whichkey= is slow to respond, lets make it a bit faster.
#+begin_src emacs-lisp
(setq which-key-idle-delay 0.1)
#+end_src
*** Window Titlebar
The titlebar display string will display =♢= if there exist unsaved buffer modifications & =♦= otherwise.
#+begin_src emacs-lisp
(setq doom-fallback-buffer-name "Doom"
+doom-dashboard-name "Doom Dashboard")
(setq frame-title-format
'(""
(:eval
(if (s-contains-p org-roam-directory (or buffer-file-name ""))
(replace-regexp-in-string
".*/[0-9]*-?" "☰ "
(subst-char-in-string ?_ ? buffer-file-name))
"%b"))
(:eval
(let ((project-name (projectile-project-name)))
(unless (string= "-" project-name)
(format (if (buffer-modified-p) " ♢ %s" " ♦ %s") project-name))))))
#+end_src
*** Fonts
I use the [[https://www.nerdfonts.com/][nerdfont]]'s [[https://github.com/i-tu/Hasklig][Hasklig]] for my monospace font & Huerta Tipografica's [[https://www.huertatipografica.com/en/fonts/alegreya-ht-pro][ Alegreya]] serif font.
#+begin_src emacs-lisp
(setq doom-font (font-spec :family "Hasklig" :size 14 :height 1)
doom-variable-pitch-font (font-spec :family "Alegreya" :height 1.3)
doom-big-font (font-spec :family "Hasklig" :size 18))
#+end_src
** Doom Modules
The configuration is below is pulled from the template =init.example.el= provided by doom. This one is based off commit [[https://github.com/doomemacs/doomemacs/blob/e96624926d724aff98e862221422cd7124a99c19/templates/init.example.el][e966249]].
#+name: init.el
#+attr_html: :collapsed t
@ -130,22 +167,26 @@ The configuration is below is pulled from the template init.example.el provided
)
#+end_src
The code of these can be found in the [[https://github.com/doomemacs/doomemacs/tree/master/modules][modeules directory]], the readme for each module will list any additional configuration options.
The code of these can be found in the [[https://github.com/doomemacs/doomemacs/tree/master/modules][modeules directory]], the read me for each module will list any additional configuration options.
*** Completion
https://github.com/doomemacs/doomemacs/tree/master/modules/completion
#+name:doom-completion
#+begin_src emacs-lisp :tangle no
company ; the ultimate code completion backend
;;helm ; the *other* search engine for love and life
(company ; the ultimate code completion backend
+childframe ; not quite a window & not quite a frame
; +tng ; Use tab instead of ctrl+space
)
;;helm ; the *other* search engine for love and lifes
;;ido ; the other *other* search engine...
;;ivy ; a search engine for love and life
vertico ; the search engine of the future
(vertico ; the search engine of the future
+icons ; make a little prettier
)
#+end_src
=+childframe= exist for both company & vertico, ux is a bit jarring to use with vertico so I'm not using that.
=+childframe= exists for both company & vertico, but looks a little weird with Vertico. We have for gone it for the time being.
*** UI
https://github.com/doomemacs/doomemacs/tree/master/modules/ui
@ -155,7 +196,7 @@ https://github.com/doomemacs/doomemacs/tree/master/modules/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
doom-quit ; DOOM quit-message prompts when you quit Emacs
;;(emoji +unicode) ; 🙂
hl-todo ; highlight TODO/FIXME/NOTE/DEPRECATED/HACK/REVIEW
;;hydra
@ -163,20 +204,30 @@ hl-todo ; highlight TODO/FIXME/NOTE/DEPRECATED/HACK/REVIEW
;;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
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
(treemacs ; a project drawer, like neotree but cooler
+lsp)
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
zen ; distraction-free coding or writing
#+end_src
**** Fancy Welcome Image
Rather than the boring ascii doom logo. Lets some the one off the box art. This is enabled by the =doom-dashboard= module.
#+CAPTION:Doom Welcome Icon
[[./.resources/doom.png]]
#+begin_src emacs-lisp
(setq fancy-splash-image (concat doom-user-dir "./.resources/doom.png"))
#+end_src
*** Editor
https://github.com/doomemacs/doomemacs/tree/master/modules/editor
@ -185,26 +236,25 @@ https://github.com/doomemacs/doomemacs/tree/master/modules/editor
(evil +everywhere); come to the dark side, we have cookies
file-templates ; auto-snippets for empty files
fold ; (nigh) universal code folding
;;(format +onsave) ; automated prettiness
(format +onsave) ; 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
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
#+end_src
*** Emacs
https://github.com/doomemacs/doomemacs/tree/master/modules/emacs
#+name:doom-emacs
#+begin_src emacs-lisp :tangle no
dired ; making dired pretty [functional]
electric ; smarter, keyword-based electric-indent
;;ibuffer ; interactive buffer management
undo ; persistent, smarter undo for your inevitable mistakes
(undo +tree) ; persistent, smarter undo for your inevitable mistakes
vc ; version-control and Emacs, sitting in a tree
#+end_src
@ -216,19 +266,28 @@ https://github.com/doomemacs/doomemacs/tree/master/modules/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
vterm ; the best terminal emulation in Emacs
#+end_src
Vterm is great. It does require some additional configuration to work properly. See [[https://github.com/doomemacs/doomemacs/tree/master/modules/term/vterm][relavant doc]] for more.
*** Checker
https://github.com/doomemacs/doomemacs/tree/master/modules/checker
#+name:doom-checker
#+begin_src emacs-lisp :tangle no
syntax ; tasing you for every semicolon you forget
;;(spell +flyspell) ; tasing you for misspelling mispelling
;;grammar ; tasing grammar mistake every you make
(syntax +childframe) ; tasing you for every semicolon you forget
(spell ; tasing you for misspelling mispelling
+aspell
+everywhere)
grammar ; tasing grammar mistake every you make
#+end_src
**** Custom Dictionary
#+begin_src emacs-lisp
(setq ispell-dictionary "en"
ispell-personal-dictionary "~/org/.ispell.en.pws")
#+end_src
*** Tools
https://github.com/doomemacs/doomemacs/tree/master/modules/tools
@ -236,28 +295,32 @@ https://github.com/doomemacs/doomemacs/tree/master/modules/tools
#+begin_src emacs-lisp :tangle no
;;ansible
;;biblio ; Writes a PhD for you (citation needed)
;;debugger ; FIXME stepping through code, to help you add bugs
(debugger +lsp) ; 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 ; navigate your code and its documentation
;;lsp ; M-x vscode
(lookup ; navigate your code and its documentation
+dictionary
+docset
+offline)
(lsp +peek) ; 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
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...
tree-sitter ; syntax and parsing, sitting in a tree...
;;upload ; map local to remote projects via ssh/ftp
#+end_src
NOTE: =:leader r= is currently being used by roam. See [[id:f9ffe9df-a417-45c4-8bf2-6ee655140648][Roam Keybinds]]. This conflicts with the =upload= module. If you wish to use this module in the future you will need to updated one of the keybinds to not conflict.
*** Language
https://github.com/doomemacs/doomemacs/tree/master/modules/lang
@ -271,7 +334,7 @@ https://github.com/doomemacs/doomemacs/tree/master/modules/lang
;;coq ; proofs-as-programs
;;crystal ; ruby at the speed of c
;;csharp ; unity, .NET, and mono shenanigans
;;data ; config/data formats
data ; config/data formats
;;(dart +flutter) ; paint ui and not much else
;;dhall
;;elixir ; erlang done right
@ -285,14 +348,20 @@ emacs-lisp ; drown in parentheses
;;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
(go ; the hipster dialect
+lsp
+tree-sitter)
;;(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
(json ; At least it ain't XML
+lsp
+tree-sitter)
;;(java +lsp) ; the poster child for carpal tunnel syndrome
;;javascript ; all(hope(abandon(ye(who(enter(here))))))
(javascript ; all(hope(abandon(ye(who(enter(here))))))
+lsp
+tree-sitter)
;;julia ; a better, faster MATLAB
;;kotlin ; a better, slicker Java(Script)
;;latex ; writing papers in Emacs has never been so fun
@ -301,13 +370,23 @@ emacs-lisp ; drown in parentheses
;;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!"
(nix ; I hereby declare "nix geht mehr!"
+tree-sitter)
;;ocaml ; an objective camel
org ; organize your plain life in plain text
(org ; organize your plain life in plain text
+dragndrop
+journal
+pandoc
+pomodoro
+pretty
+roam2)
;;php ; perl's insecure younger brother
;;plantuml ; diagrams for confusing people more
;;purescript ; javascript, but functional
;;python ; beautiful is better than ugly
(python ; beautiful is better than ugly
+lsp
+poetry
+tree-sitter)
;;qt ; the 'cutest' gui framework ever
;;racket ; a DSL for DSLs
;;raku ; the artist formerly known as perl6
@ -317,13 +396,17 @@ org ; organize your plain life in plain text
;;(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
(sh ; she sells {ba,z,fi}sh shells on the C xor
+lsp
+tree-sitter)
;;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
(web ; the tubes
+lsp
+tree-sitter)
(yaml +lsp) ; JSON, but readable
;;zig ; C, but simpler
#+end_src
@ -355,13 +438,311 @@ https://github.com/doomemacs/doomemacs/tree/master/modules/config
#+name:doom-config
#+begin_src emacs-lisp :tangle no
;literate
literate
(default +bindings +smartparens)
#+end_src
** Additional Keybinds
Keybinds custom keybinds can be located at =$DOOMDIR/+keybinds.el=.
#+begin_src emacs-lisp
(load! "+keybinds")
#+end_src
Doom comes with some good keybind macros (see [[https://github.com/doomemacs/doomemacs/blob/master/docs/faq.org#bind-my-own-keys-or-change-existing-ones][here]] for why). Documentation for this can be found [[https://github.com/doomemacs/doomemacs/blob/master/docs/faq.org#bind-my-own-keys-or-change-existing-ones][here]], but in broad strokes:
1. Start with a =map!= macro. You can use
2. When possible use =:when= to limit scope.
3. Use =:prefix= and =:prefix-map= where possible.
4. Always use =:desc= to describe what is being done.
Below is a sample snippet from Rameez Khan's [[https://rameezkhan.me/posts/2020/2020-07-03--adding-keybindings-to-doom-emacs/][blog]] (first hit on "doom emacs keybind" using [[https://duckduckgo.com/][DDG]]):
#+begin_src emacs-lisp :tangle no
(map! :leader
(:prefix-map ("a" . "applications")
(:prefix ("j" . "journal")
:desc "New journal entry" "j" #'org-journal-new-entry
:desc "Search journal entry" "s" #'org-journal-search)))
#+end_src
*** Add the lexical bindings magic comment
#+begin_src emacs-lisp :tangle "+keybinds.el" :noweb no-export :comments no
;;; +keybinds.el -*- lexical-binding: t; -*-
#+end_src
*** Local Leader
Lets set the local leader to =,=. We may want to remap this to =;= later. Both of these seem to have issues with potential key conflicts with evil-snipe. This seems to primarily exists with regards to org-mode. Github issue can be found [[https://github.com/doomemacs/doomemacs/issues/4242][here]].
#+begin_src emacs-lisp :tangle "+keybinds.el" :noweb no-export :comments no
(setq doom-localleader-key ",")
#+end_src
*** Roam Keybinds
:PROPERTIES:
:ID: f9ffe9df-a417-45c4-8bf2-6ee655140648
:END:
The standard keybind for getting to Roam's daily capture is pretty long. To capture a Log entry I have to type =SPC n r d T l=. I want to capture as many logs and goals as possible, so lets shorten this up some.
#+begin_src emacs-lisp :tangle "+keybinds.el" :noweb no-export :comments no
(map! :leader
(:when (modulep! :lang org +roam2)
(:prefix-map ("r" . "roam")
:desc "Find node" "/" #'org-roam-node-find
:desc "Capture to node" "n" #'org-roam-capture
:desc "Capture Today" "c" #'org-roam-dailies-capture-today
:desc "Goto Today" "t" #'org-roam-dailies-goto-today
)
)
)
#+end_src
=:leader r= is used by =:tools upload= for "remote", but since I'm not using this lets just not care about that.
** Orgmode
This file will be needed for emacs batch automations, where its not reasonable to start up my entire working env. This file can be located at =$DOOMDIR/+orgmode.el=.
#+begin_src emacs-lisp
(load! "+orgmode")
#+end_src
*** Lexical bindings
#+begin_src emacs-lisp :tangle "+orgmode.el" :noweb no-export :comments no
;;; +orgmode.el -*- lexical-binding: t; -*-
#+end_src
*** Importing org
This file may get consumed via emacs batch scripting, so we need ot make sure the orgmode is actually loaded.
#+begin_src emacs-lisp :tangle "+orgmode.el" :noweb no-export :comments no
(require 'org)
#+end_src
*** Directories
My notes are stored via [[https://nextcloud.com/][NextCloud]] to sync multiple machines. The Nextcloud directory can be located in a couple different location based off the OS that the machine is running, but
Where the NextCloud general sync directory may vary based on machine but notes should always be stored at =$HOME/org=.
#+begin_src emacs-lisp :tangle "+orgmode.el" :noweb no-export :comments no
(custom-set-variables '(org-directory "~/org/"))
#+end_src
I've tried to organize things based on purpose & this will likely change in the future. The current directory looks like this
#+begin_example :tangle no
~/org
├── .archive
├── .attach
├── Projects
├── Roam
├── Todo
└── Work
#+end_example
**** =.archive=
Where old files go. See =org-archive-subtree= for more.
**** =.attach=
Stuff that is not an orgmode document.
#+begin_src emacs-lisp :tangle "+orgmode.el" :noweb no-export :comments no
(setq
org-download-image-dir (concat org-directory ".attach/"))
#+end_src
**** =Projects=
I keep a =todo.org= at the root of each project. These are symlinked into the Projects directory. Nextcloud does not sync symlinked documents.
**** =Roam=
All roam docs go here. This is my default note taking system.
#+begin_src emacs-lisp :tangle "+orgmode.el" :noweb no-export :comments no
(setq
org-roam-directory (concat org-directory "Roam/"))
#+end_src
**** =Todo=
Another symlink dir. This is used to populate org agenda files.
#+begin_src emacs-lisp :tangle "+orgmode.el" :noweb no-export :comments no
(setq org-agenda-files (list (concat org-directory "Todos/" )))
#+end_src
**** =Work=
On my work machine I'll symlink this into my =Todo=
#+begin_src bash :tangle no
ln -s $HOME/org/Work/todo.org $HOME/org/Todo/work.org
#+end_src
I still want to capture work related notes where ever I am though.
#+begin_src emacs-lisp :tangle "+orgmode.el" :noweb no-export :comments no
(defvar-local +org-capture-work-todo
(expand-file-name "Work/todo.org" org-directory))
(add-to-list 'org-capture-templates
'("w" "Work Todo" entry
(file+headline +org-capture-work-todo-file "Inbox")
"* [_] %?%i\n%a" :prepend t))
#+end_src
*** A Prettier Orgmode
**** Use a serif variable font
This uses =doom-variable-pitch-font= as defined in the font section.
#+begin_src emacs-lisp :tangle "+orgmode.el" :noweb no-export :comments no
(add-hook! 'org-mode-hook #'mixed-pitch-mode)
#+end_src
**** Pretty mode
#+begin_src emacs-lisp :tangle "+orgmode.el" :noweb no-export :comments no
(add-hook! 'org-mode-hook #'+org-pretty-mode)
#+end_src
**** Agenda faces
#+begin_src emacs-lisp :tangle "+orgmode.el" :noweb no-export :comments no
(setq org-agenda-deadline-faces
'((1.001 . error)
(1.0 . org-warning)
(0.5 . org-upcoming-deadline)
(0.0 . org-upcoming-distant-deadline)))
#+end_src
**** Prettify Symbols
There is a few of these built into the =orgmode='s =+pretty= module. Checkboxes are not included so lets include it.
#+begin_src emacs-lisp :tangle "+orgmode.el" :noweb no-export :comments no
(add-hook 'org-mode-hook (lambda ()
"Beautify Org Checkbox Symbol"`
(push '("[ ]" . "☐") prettify-symbols-alist)
(push '("[_]" . "☐") prettify-symbols-alist)
(push '("[X]" . "☑" ) prettify-symbols-alist)
(push '("[-]" . "⊟" ) prettify-symbols-alist)
(prettify-symbols-mode)))
#+end_src
And when you hover over it, disable it.
#+begin_src emacs-lisp :tangle "+orgmode.el" :noweb no-export :comments no
(setq prettify-symbols-unprettify-at-point 'right-edge)
#+end_src
**** Fancy Source Blocks
This was grabbed from Rasmus Pank's [[https://pank.eu/blog/pretty-babel-src-blocks.html][blog]].
this makes the beginning / ending of both source and quote blocks, & headers for that display a little cleaner.
#+begin_quote
[[./.resources/fancy_blocks.png]]
#+end_quote
#+begin_src emacs-lisp :tangle "+orgmode.el" :noweb no-export :comments no
(with-eval-after-load 'org
(defvar-local rasmus/org-at-src-begin -1
"Variable that holds whether last position was a ")
(defvar rasmus/ob-header-symbol ?☰
"Symbol used for babel headers")
(defun rasmus/org-prettify-src--update ()
(let ((case-fold-search t)
(re "^[ \t]*#\\+begin_src[ \t]+[^ \f\t\n\r\v]+[ \t]*")
found)
(save-excursion
(goto-char (point-min))
(while (re-search-forward re nil t)
(goto-char (match-end 0))
(let ((args (org-trim
(buffer-substring-no-properties (point)
(line-end-position)))))
(when (org-string-nw-p args)
(let ((new-cell (cons args rasmus/ob-header-symbol)))
(cl-pushnew new-cell prettify-symbols-alist :test #'equal)
(cl-pushnew new-cell found :test #'equal)))))
(setq prettify-symbols-alist
(cl-set-difference prettify-symbols-alist
(cl-set-difference
(cl-remove-if-not
(lambda (elm)
(eq (cdr elm) rasmus/ob-header-symbol))
prettify-symbols-alist)
found :test #'equal)))
;; Clean up old font-lock-keywords.
(font-lock-remove-keywords nil prettify-symbols--keywords)
(setq prettify-symbols--keywords (prettify-symbols--make-keywords))
(font-lock-add-keywords nil prettify-symbols--keywords)
(while (re-search-forward re nil t)
(font-lock-flush (line-beginning-position) (line-end-position))))))
(defun rasmus/org-prettify-src ()
"Hide src options via `prettify-symbols-mode'.
`prettify-symbols-mode' is used because it has uncollpasing. It's
may not be efficient."
(let* ((case-fold-search t)
(at-src-block (save-excursion
(beginning-of-line)
(looking-at "^[ \t]*#\\+begin_src[ \t]+[^ \f\t\n\r\v]+[ \t]*"))))
;; Test if we moved out of a block.
(when (or (and rasmus/org-at-src-begin
(not at-src-block))
;; File was just opened.
(eq rasmus/org-at-src-begin -1))
(rasmus/org-prettify-src--update))
;; Remove composition if at line; doesn't work properly.
;; (when at-src-block
;; (with-silent-modifications
;; (remove-text-properties (match-end 0)
;; (1+ (line-end-position))
;; '(composition))))
(setq rasmus/org-at-src-begin at-src-block)))
;; This function helps to produce a single glyph out of a
;; string. The glyph can then be used in prettify-symbols-alist.
;; This function was provided by Ihor in the org-mode mailing list.
(defun yant/str-to-glyph (str)
"Transform string into glyph, displayed correctly."
(let ((composition nil))
(dolist (char (string-to-list str)
(nreverse (cdr composition)))
(push char composition)
(push '(Br . Bl) composition))))
(defun rasmus/org-prettify-symbols ()
(mapc (apply-partially 'add-to-list 'prettify-symbols-alist)
(cl-reduce 'append
(mapcar (lambda (x) (list x (cons (upcase (car x)) (cdr x))))
`(("#+begin_src" . ?⎡) ;; ⎡ ➤ 🖝 ➟ ➤ ✎
;; multi-character strings can be used with something like this:
;; ("#+begin_src" . ,(yant/str-to-glyph "```"))
("#+end_src" . ?⎣) ;; ⎣ ✐
("#+header:" . ,rasmus/ob-header-symbol)
("#+begin_quote" . ?«)
("#+end_quote" . ?»)))))
(turn-on-prettify-symbols-mode)
(add-hook 'post-command-hook 'rasmus/org-prettify-src t t))
(add-hook 'org-mode-hook #'rasmus/org-prettify-symbols))
#+end_src
*** Roam
I use =org-roam= v2 for most of my note taking. TODO expand this section.
**** Dailies Templates
#+begin_src emacs-lisp :tangle "+orgmode.el" :noweb no-export :comments no
(setq org-roam-dailies-capture-templates
'(("l" "Log" entry "* %T %?"
:target (file+head+olp "%<%Y-%m-%d>.org"
"#+title: %<%Y-%m-%d>\n#+filetags: %<:%Y:%B:>\n"
("Log")))
("g" "Goal" entry "* TODO %? :mit:"
:target (file+head+olp "%<%Y-%m-%d>.org"
"#+title: %<%Y-%m-%d>\n#+filetags: %<:%Y:%B:>\n"
("Goals")))))
#+end_src
We'll
**** Keybinds
These were declared in [[id:f9ffe9df-a417-45c4-8bf2-6ee655140648][Roam Keybinds]] section above. See there for more details.
*** Solaire
#+begin_src emacs-lisp :tangle "+orgmode.el" :noweb no-export :comments no
;(add-hook! 'org-mode-hook #'solaire-mode)
;(add-hook 'mixed-pitch-mode-hook #'solaire-mode-reset)
#+end_src
* Content Stolen From
A large amount of the details listed here have been lifted from [[https://tecosaur.github.io/emacs-config/][tecosaur's literate configuration]].
https://zzamboni.org/post/my-emacs-configuration-with-commentary/
* Footnotes
[fn:1] See [[https://github.com/doomemacs/doomemacs/tree/master/modules/config/literate#change-where-src-blocks-are-tangled-or-prevent-it-entirely][Doom FAQ on this for more.]]

View File

@ -15,17 +15,22 @@
;; directory (for easy access to its source code).
(doom! :completion
company ; the ultimate code completion backend
;;helm ; the *other* search engine for love and life
(company ; the ultimate code completion backend
+childframe ; not quite a window & not quite a frame
; +tng ; Use tab instead of ctrl+space
)
;;helm ; the *other* search engine for love and lifes
;;ido ; the other *other* search engine...
;;ivy ; a search engine for love and life
vertico ; the search engine of the future
(vertico ; the search engine of the future
+icons ; make a little prettier
)
: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
doom-quit ; DOOM quit-message prompts when you quit Emacs
;;(emoji +unicode) ; 🙂
hl-todo ; highlight TODO/FIXME/NOTE/DEPRECATED/HACK/REVIEW
;;hydra
@ -33,30 +38,31 @@
;;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
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
(treemacs ; a project drawer, like neotree but cooler
+lsp)
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
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 +onsave) ; automated prettiness
(format +onsave) ; 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
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
@ -64,42 +70,47 @@
dired ; making dired pretty [functional]
electric ; smarter, keyword-based electric-indent
;;ibuffer ; interactive buffer management
undo ; persistent, smarter undo for your inevitable mistakes
(undo +tree) ; 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
vterm ; the best terminal emulation in Emacs
:checkers
syntax ; tasing you for every semicolon you forget
;;(spell +flyspell) ; tasing you for misspelling mispelling
;;grammar ; tasing grammar mistake every you make
(syntax +childframe) ; tasing you for every semicolon you forget
(spell ; tasing you for misspelling mispelling
+aspell
+everywhere)
grammar ; tasing grammar mistake every you make
:tools
;;ansible
;;biblio ; Writes a PhD for you (citation needed)
;;debugger ; FIXME stepping through code, to help you add bugs
(debugger +lsp) ; 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 ; navigate your code and its documentation
;;lsp ; M-x vscode
(lookup ; navigate your code and its documentation
+dictionary
+docset
+offline)
(lsp +peek) ; 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
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...
tree-sitter ; syntax and parsing, sitting in a tree...
;;upload ; map local to remote projects via ssh/ftp
:os
@ -114,7 +125,7 @@
;;coq ; proofs-as-programs
;;crystal ; ruby at the speed of c
;;csharp ; unity, .NET, and mono shenanigans
;;data ; config/data formats
data ; config/data formats
;;(dart +flutter) ; paint ui and not much else
;;dhall
;;elixir ; erlang done right
@ -128,14 +139,20 @@
;;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
(go ; the hipster dialect
+lsp
+tree-sitter)
;;(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
(json ; At least it ain't XML
+lsp
+tree-sitter)
;;(java +lsp) ; the poster child for carpal tunnel syndrome
;;javascript ; all(hope(abandon(ye(who(enter(here))))))
(javascript ; all(hope(abandon(ye(who(enter(here))))))
+lsp
+tree-sitter)
;;julia ; a better, faster MATLAB
;;kotlin ; a better, slicker Java(Script)
;;latex ; writing papers in Emacs has never been so fun
@ -144,13 +161,23 @@
;;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!"
(nix ; I hereby declare "nix geht mehr!"
+tree-sitter)
;;ocaml ; an objective camel
org ; organize your plain life in plain text
(org ; organize your plain life in plain text
+dragndrop
+journal
+pandoc
+pomodoro
+pretty
+roam2)
;;php ; perl's insecure younger brother
;;plantuml ; diagrams for confusing people more
;;purescript ; javascript, but functional
;;python ; beautiful is better than ugly
(python ; beautiful is better than ugly
+lsp
+poetry
+tree-sitter)
;;qt ; the 'cutest' gui framework ever
;;racket ; a DSL for DSLs
;;raku ; the artist formerly known as perl6
@ -160,13 +187,17 @@
;;(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
(sh ; she sells {ba,z,fi}sh shells on the C xor
+lsp
+tree-sitter)
;;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
(web ; the tubes
+lsp
+tree-sitter)
(yaml +lsp) ; JSON, but readable
;;zig ; C, but simpler
:email
@ -183,6 +214,6 @@
;;twitter ; twitter client https://twitter.com/vnought
:config
;literate
literate
(default +bindings +smartparens)
)