2023-01-28 19:22:13 +00:00
#+title : Doom Emacs Configuration
2024-02-04 02:14:41 +00:00
#+AUTHOR : James Patrick
2024-01-29 04:54:32 +00:00
#+SETUPFILE : ./dist/setup.org
2023-01-28 19:22:13 +00:00
2023-01-30 19:47:45 +00:00
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.
2023-01-28 19:22:13 +00:00
2024-07-16 15:46:24 +00:00
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, literate configuration can be a mixed bag. Literate Programming produces more prose than code. Discoverability & readability can be drowned out under the prose about the current thoughts, pros & cons, backstory, deciding thoughts, & moral pondering. While this verbosity[fn: 4 ] aids documentation and understanding, its often at the cost of readability. As a compromise I'm going to version both to the verbose =config.org= file and all the produced configuration files; this will allow us to =git blame= both this file and the generated files.
2023-01-28 19:22:13 +00:00
* Document Structure
** Doom Emacs
2024-02-03 23:41:43 +00:00
I'm utilizing Hlissner's [[https://github.com/doomemacs/doomemacs ][Doom Emacs ]] frameworks. Doom Emac's 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 ]].
2023-01-28 19:22:13 +00:00
2024-02-03 23:41:43 +00:00
Configuration is located in the ~$DOOMDIR~ directory; this can be located either[fn: 3 ] at =~/.doom.d= or =$XDG_CONFIG_HOME/doom= .
2023-01-28 19:22:13 +00:00
** Tangle
2024-07-16 15:46:24 +00:00
This org-mode document works by using [[https://orgmode.org/manual/Extracting-Source-Code.html ][tangles ]]. By default, Doom's literate config mode adds any ~#+begin_src~ blocks into the =config.el= file[fn: 1 ] . If you want to tangle to a specific file you pass in a file name.
2023-01-28 19:22:13 +00:00
2024-02-03 23:41:43 +00:00
#+begin_src org :tangle no
2023-01-28 19:22:13 +00:00
#+begin_src emacs-lisp :tangle "example.el"
#+end_src
2024-07-16 15:46:24 +00:00
or to disable it tangling for a code block set the =:tangle= property in code block header to =no= .
2023-01-28 19:22:13 +00:00
2024-02-03 23:41:43 +00:00
#+begin_src org :tangle no
2023-01-28 19:22:13 +00:00
#+begin_src orgmode :tangle no
#+end_src
*** Noweb Reference
2024-07-16 15:46:24 +00:00
This document uses [[https://orgmode.org/manual/Noweb-Reference-Syntax.html ][noweb reference syntax ]]. This allows us to extract bits of configuration into named code blocks, which can be interpolated into another code block's variable. For example:
2023-01-28 19:22:13 +00:00
#+begin_example :tangle no
#+NAME : initialization
#+BEGIN_SRC emacs-lisp
(setq sentence "Never a foot too far, even.")
#+END_SRC
#+BEGIN_SRC emacs-lisp :noweb yes
2024-02-03 23:41:43 +00:00
<<initialization >>
2023-01-28 19:22:13 +00:00
(reverse sentence)
#+END_SRC
#+end_example
will produce
#+begin_example
#+BEGIN_SRC emacs-lisp :noweb yes
(setq sentence "Never a foot too far, even.")
(reverse sentence)
#+END_SRC
#+end_example
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.
2024-02-03 23:41:43 +00:00
** Files tree
There's a fair number of files located in ~$DOOMDIR~ . Some are configuration, some are additional tooling not use directly by emacs.
#+begin_src bash :tangle no :exports result :results output verbatim
tree $DOOMDIR -L 2
#+end_src
#+RESULTS :
#+begin_example
.
├── +keybinds.el
├── +orgmode.el
├── config.el
├── config.html
├── config.org
├── dist
│ ├── bundle.js
│ ├── code.css
│ ├── custom.css
│ ├── setup.org
│ └── tufte.css
├── init.el
├── makefile
├── packages.el
└── snippets
└── org-mode
4 directories, 13 files
#+end_example
*** Emacs Configuration Files
Doom will automatically load the following files.
+ =init.el= :: Enabled Doom Modules
2024-07-16 15:46:24 +00:00
+ =package.el= :: Packages to fetch from MELPA, GitHub, etc.
2024-02-03 23:41:43 +00:00
+ =config.el= :: General Emacs configuration
Any additional files should follow the pattern of =+name.el= and should be scoped to that individual purpose.
This should be loaded by the =config.el= file by using the =load!= macro[fn: 7 ] e.g.
#+begin_src emacs-lisp :tangle no
(load! "+name")
#+end_src
2024-07-16 15:46:24 +00:00
Currently, this includes
2024-02-03 23:41:43 +00:00
- =+orgmode.el= :: Additional configuration for Orgmode. Considering this is one of the primary modes I use emacs in there's a fair bit of configuration there.
2024-07-16 15:46:24 +00:00
- =+keybinds.el= :: A relatively new and not fully utilized file. The plan is to use this as a centralized location for all custom key binds.
2024-02-03 23:41:43 +00:00
*** Other files
There are several other files here not directly used by emacs but are related to it.
- =makefile= :: Install script using make[fn: 6 ] .
- =dist/*= :: These are files used by the output of [[https://github.com/ox-tufte/ox-tufte ][ox-tufte ]].[fn:5]
- =config.html= :: This org file exported from [[https://github.com/ox-tufte/ox-tufte ][ox-tufte ]]. This is not versioned.
- =snippets/[major mode]/*= :: These are [[https://github.com/joaotavora/yasnippet ][YASnippets ]]. These are manage by this document. See [[*Snippets ][Snippets ]] for more.
Everything else should be emacs configuration.
** Emacs file prefixing
2023-01-30 19:47:45 +00:00
*** Lexical Bindings
2023-01-28 19:22:13 +00:00
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
2024-02-03 23:41:43 +00:00
#+name :lexical-binding
#+BEGIN_SRC emacs-lisp
;;; -*- lexical-binding: t; -* -
2023-02-12 22:53:15 +00:00
#+END_SRC
2023-08-09 17:28:19 +00:00
*** Warn user not to modify =*.el= files directly.
2024-07-16 15:46:24 +00:00
As mentioned above, we are versioning the generated emacs lisp configuration. We shouldn't modify these files as they'll be clobbered anytime the org-tangle is run. Let's include a warning to this effect.
2023-01-30 19:58:25 +00:00
#+name :modification-warning
#+begin_src emacs-lisp
;;; This file is generated via tangles from the config.org file. Do not modify this file.
;;; Any modifications here will be clobbered and versioned over. Seriously just don't.
#+end_src
2024-02-03 23:41:43 +00:00
*** Applying to all files
2024-07-16 15:46:24 +00:00
We need to apply this to all the following files.
2024-02-03 23:41:43 +00:00
#+begin_src bash :tangle no :exports result :results output verbatim
find ~/.doom.d/ * -iname '*.el' | sed "s/.* \///"
2023-01-30 19:47:45 +00:00
#+end_src
2024-02-03 23:41:43 +00:00
#+RESULTS :
: +keybinds.el
: +orgmode.el
: config.el
: init.el
: packages.el
2023-01-30 19:47:45 +00:00
2024-07-16 15:46:24 +00:00
Since we've used a named these blocks we can use [[*Noweb Reference ][Noweb Reference ]] for all the files.
2024-02-04 00:52:30 +00:00
2024-02-03 23:41:43 +00:00
=+keybinds.el=
#+begin_src emacs-lisp :tangle "+keybinds.el" :noweb no-export :comments no
<<lexical-binding >>
<<modification-warning >>
#+END_SRC
2023-01-30 19:47:45 +00:00
2024-02-03 23:41:43 +00:00
=+orgmode.el=
#+begin_src emacs-lisp :tangle "+orgmode.el" :noweb no-export :comments no
<<lexical-binding >>
<<modification-warning >>
#+END_SRC
2023-01-30 19:47:45 +00:00
2024-02-03 23:41:43 +00:00
=config.el=
#+begin_src emacs-lisp :tangle "config.el" :noweb no-export :comments no
<<lexical-binding >>
<<modification-warning >>
#+END_SRC
=init.el=
#+begin_src emacs-lisp :tangle "init.el" :noweb no-export :comments no
<<lexical-binding >>
<<modification-warning >>
#+END_SRC
=packages.el=
#+begin_src emacs-lisp :tangle "packages.el" :noweb no-export :comments no
<<lexical-binding >>
<<modification-warning >>
#+END_SRC
2023-01-30 19:47:45 +00:00
2023-02-01 03:33:03 +00:00
2024-02-03 23:41:43 +00:00
* Doom Modules
2023-01-30 19:47:45 +00:00
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 ]].
2023-01-28 19:22:13 +00:00
#+name : init.el
#+attr_html : :collapsed t
#+begin_src emacs-lisp :tangle "init.el" :noweb no-export :comments no
;; 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! :completion
<<doom-completion >>
:ui
<<doom-ui >>
:editor
<<doom-editor >>
:emacs
<<doom-emacs >>
:term
<<doom-term >>
:checkers
<<doom-checker >>
:tools
<<doom-tools >>
:os
(:if IS-MAC macos) ; improve compatibility with macOS
:lang
<<doom-lang >>
:email
<<doom-email >>
:app
<<doom-app >>
:config
<<doom-config >>
)
#+end_src
2023-01-30 19:47:45 +00:00
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.
2023-01-28 19:22:13 +00:00
2024-02-03 23:41:43 +00:00
** Completion
2023-01-28 19:22:13 +00:00
https://github.com/doomemacs/doomemacs/tree/master/modules/completion
#+name :doom-completion
#+begin_src emacs-lisp :tangle no
2024-06-18 20:48:58 +00:00
;; (company ; the ultimate code completion backend
;; +childframe ; not quite a window & not quite a frame
;; ; +tng ; Use tab instead of ctrl+space
;; )
(corfu
+icons
+orderless
2023-01-30 19:47:45 +00:00
)
;;helm ; the *other* search engine for love and lifes
2023-01-28 19:22:13 +00:00
;;ido ; the other *other* search engine...
;;ivy ; a search engine for love and life
2023-01-30 19:47:45 +00:00
(vertico ; the search engine of the future
+icons ; make a little prettier
)
2023-01-28 19:22:13 +00:00
#+end_src
2023-01-30 19:47:45 +00:00
=+childframe= exists for both company & vertico, but looks a little weird with Vertico. We have for gone it for the time being.
2023-01-28 19:22:13 +00:00
2024-02-03 23:41:43 +00:00
** UI
2023-01-28 19:22:13 +00:00
https://github.com/doomemacs/doomemacs/tree/master/modules/ui
#+name :doom-ui
#+begin_src emacs-lisp :tangle no
;;deft ; notational velocity for Emacs
doom ; what makes DOOM look the way it does
doom-dashboard ; a nifty splash screen for Emacs
2023-01-30 19:47:45 +00:00
doom-quit ; DOOM quit-message prompts when you quit Emacs
2023-08-09 17:38:08 +00:00
(emoji +unicode) ; 🙂
2023-01-28 19:22:13 +00:00
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
2023-01-30 19:47:45 +00:00
nav-flash ; blink cursor line after big motions
neotree ; a project drawer, like NERDTree for vim
2023-01-28 19:22:13 +00:00
ophints ; highlight the region an operation acts on
(popup +defaults) ; tame sudden yet inevitable temporary windows
;;tabs ; a tab bar for Emacs
2023-01-30 19:47:45 +00:00
(treemacs ; a project drawer, like neotree but cooler
+lsp)
2023-08-09 17:06:04 +00:00
;;unicode ; extended unicode support for various languages
2023-01-28 19:22:13 +00:00
(vc-gutter +pretty) ; vcs diff in the fringe
vi-tilde-fringe ; fringe tildes to mark beyond EOB
2023-08-09 17:38:08 +00:00
(window-select ; visually switch windows
+numbers) ; c-w N
2023-01-28 19:22:13 +00:00
workspaces ; tab emulation, persistence & separate workspaces
2023-01-30 19:47:45 +00:00
zen ; distraction-free coding or writing
2023-01-28 19:22:13 +00:00
#+end_src
2024-02-03 23:41:43 +00:00
*** Fancy Welcome Image
2023-01-30 19:47:45 +00:00
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 ]]
2024-05-07 05:28:50 +00:00
#+begin_src emacs-lisp :tangle "config.el" :noweb no-export :comments no
2023-01-30 19:47:45 +00:00
(setq fancy-splash-image (concat doom-user-dir "./.resources/doom.png"))
#+end_src
2024-02-03 23:41:43 +00:00
** Editor
2023-01-28 19:22:13 +00:00
https://github.com/doomemacs/doomemacs/tree/master/modules/editor
#+name :doom-editor
#+begin_src emacs-lisp :tangle no
(evil +everywhere); come to the dark side, we have cookies
file-templates ; auto-snippets for empty files
fold ; (nigh) universal code folding
2023-01-30 19:47:45 +00:00
(format +onsave) ; automated prettiness
2023-01-28 19:22:13 +00:00
;;god ; run Emacs commands without modifier keys
;;lispy ; vim for lisp, for people who don't like vim
2023-08-09 17:38:08 +00:00
;;multiple-cursors ; editing in many places at once
2023-01-28 19:22:13 +00:00
;;objed ; text object editing for the innocent
;;parinfer ; turn lisp into python, sort of
2023-01-30 19:47:45 +00:00
rotate-text ; cycle region at point between text candidates
2023-01-28 19:22:13 +00:00
snippets ; my elves. They type so I don't have to
;;word-wrap ; soft wrapping with language-aware indent
#+end_src
2024-06-18 20:52:58 +00:00
*** Custom Formatter
Doom uses [[https://github.com/lassik/emacs-format-all-the-code ][emacs-format-all-the-code ]] for its formatting. It's a great package, but I use different formatters for a couple language. At this time I'm only going to update =sql-mode= to use [[https://github.com/darold/pgFormatter ][pgformatter ]]. It's supported, but instead used by default.
#+begin_src emacs-lisp
(setq-hook! 'sql-mode-hook +format-with 'pgformatter)
#+end_src
2024-02-03 23:41:43 +00:00
** Emacs
2023-01-28 19:22:13 +00:00
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
2023-02-18 21:21:48 +00:00
(ibuffer +icons) ; interactive buffer management
2023-01-30 19:47:45 +00:00
(undo +tree) ; persistent, smarter undo for your inevitable mistakes
2023-01-28 19:22:13 +00:00
vc ; version-control and Emacs, sitting in a tree
#+end_src
2024-02-03 23:41:43 +00:00
** Term
2023-01-28 19:22:13 +00:00
https://github.com/doomemacs/doomemacs/tree/master/modules/term
#+name :doom-term
#+begin_src emacs-lisp :tangle no
;;eshell ; the elisp shell that works everywhere
;;shell ; simple shell REPL for Emacs
;;term ; basic terminal emulator for Emacs
2023-01-30 19:47:45 +00:00
vterm ; the best terminal emulation in Emacs
2023-01-28 19:22:13 +00:00
#+end_src
2023-01-30 19:47:45 +00:00
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.
2024-02-03 23:41:43 +00:00
** Checker
2023-01-28 19:22:13 +00:00
https://github.com/doomemacs/doomemacs/tree/master/modules/checker
#+name :doom-checker
#+begin_src emacs-lisp :tangle no
2024-07-16 15:46:24 +00:00
(syntax +childframe ; tasing you for every semicolon you forget
+icons
+flymake)
2023-01-30 19:47:45 +00:00
(spell ; tasing you for misspelling mispelling
+aspell
+everywhere)
grammar ; tasing grammar mistake every you make
2023-01-28 19:22:13 +00:00
#+end_src
2024-02-03 23:41:43 +00:00
*** Custom Dictionary
2024-05-07 05:28:50 +00:00
#+begin_src emacs-lisp :tangle "config.el" :noweb no-export :comments no
2023-01-30 19:47:45 +00:00
(setq ispell-dictionary "en"
ispell-personal-dictionary "~/org/ .ispell.en.pws")
#+end_src
2024-02-03 23:41:43 +00:00
** Tools
2023-01-28 19:22:13 +00:00
https://github.com/doomemacs/doomemacs/tree/master/modules/tools
#+name :doom-tools
#+begin_src emacs-lisp :tangle no
2024-08-09 01:56:46 +00:00
ansible
2023-01-28 19:22:13 +00:00
;;biblio ; Writes a PhD for you (citation needed)
2023-08-09 17:38:29 +00:00
;;collab ; buffers with friends
2023-01-30 19:47:45 +00:00
(debugger +lsp) ; FIXME stepping through code, to help you add bugs
2023-01-28 19:22:13 +00:00
;;direnv
;;docker
2024-06-18 20:48:58 +00:00
editorconfig ; let someone else argue about tabs vs spaces
2023-01-28 19:22:13 +00:00
;;ein ; tame Jupyter notebooks with emacs
(eval +overlay) ; run code, run (also, repls)
;;gist ; interacting with github gists
2023-01-30 19:47:45 +00:00
(lookup ; navigate your code and its documentation
+dictionary
+docset
+offline)
(lsp +peek) ; M-x vscode
2023-06-07 14:17:37 +00:00
(magit +forge) ; a git porcelain for Emacs
2023-08-09 17:38:08 +00:00
make ; run make tasks from Emacs
2023-01-28 19:22:13 +00:00
;;pass ; password manager for nerds
;;pdf ; pdf enhancements
;;prodigy ; FIXME managing external services & code builders
;;rgb ; creating color strings
2024-06-18 20:48:58 +00:00
(terraform ; infrastructure as code
+lsp)
2023-01-28 19:22:13 +00:00
;;tmux ; an API for interacting with tmux
2023-01-30 19:47:45 +00:00
tree-sitter ; syntax and parsing, sitting in a tree...
2023-01-28 19:22:13 +00:00
;;upload ; map local to remote projects via ssh/ftp
#+end_src
2024-02-04 02:14:41 +00:00
NOTE: =:leader r= is currently being used by roam. See [[*Keybinds ][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.
2023-06-07 14:17:37 +00:00
2024-02-03 23:41:43 +00:00
*** Magit Forge Support
2023-06-07 14:17:37 +00:00
For use with Github this requires the creation of a Github Token (see [[https://github.com/settings/tokens ][here ]]). This will need to be appended to your =~/.authinfo.gpg= file using the format below[fn: 2 ] .
#+begin_src authinfo :tangle no
machine api.github.com login yourlogin^code-review password MYTOKENGOESHERE
#+end_src
For more on Forge see [[https://magit.vc/manual/forge.html ][Magit's Forge documentation ]].
2024-02-03 23:41:43 +00:00
** Language
2023-01-28 19:22:13 +00:00
https://github.com/doomemacs/doomemacs/tree/master/modules/lang
#+name :doom-lang
#+begin_src emacs-lisp :tangle no
;;agda ; types of types of types of types...
;;beancount ; 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
2023-01-30 19:47:45 +00:00
data ; config/data formats
2023-01-28 19:22:13 +00:00
;;(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
2023-01-30 19:47:45 +00:00
(go ; the hipster dialect
+lsp
+tree-sitter)
2023-01-28 19:22:13 +00:00
;;(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
2023-01-30 19:47:45 +00:00
(json ; At least it ain't XML
+lsp
+tree-sitter)
2023-01-28 19:22:13 +00:00
;;(java +lsp) ; the poster child for carpal tunnel syndrome
2023-01-30 19:47:45 +00:00
(javascript ; all(hope(abandon(ye(who(enter(here))))))
+lsp
+tree-sitter)
2023-01-28 19:22:13 +00:00
;;julia ; a better, faster MATLAB
;;kotlin ; a better, slicker Java(Script)
;;latex ; 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
2023-01-30 19:47:45 +00:00
(nix ; I hereby declare "nix geht mehr!"
+tree-sitter)
2023-01-28 19:22:13 +00:00
;;ocaml ; an objective camel
2023-01-30 19:47:45 +00:00
(org ; organize your plain life in plain text
+dragndrop
+journal
+pandoc
+pomodoro
+pretty
+roam2)
2023-01-28 19:22:13 +00:00
;;php ; perl's insecure younger brother
;;plantuml ; diagrams for confusing people more
;;purescript ; javascript, but functional
2023-01-30 19:47:45 +00:00
(python ; beautiful is better than ugly
+lsp
+poetry
2024-07-10 15:18:56 +00:00
+pyright
2023-01-30 19:47:45 +00:00
+tree-sitter)
2023-01-28 19:22:13 +00:00
;;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
2024-01-19 18:43:31 +00:00
(ruby ;;+rails ; 1.step {|i| p "Ruby is #{i.even? ? 'love' : 'life'}"}
+rbenv
+lsp
+tree-sitting)
2023-01-28 19:22:13 +00:00
;;(rust +lsp) ; Fe2O3.unwrap().unwrap().unwrap().unwrap()
;;scala ; java, but good
;;(scheme +guile) ; a fully conniving family of lisps
2023-01-30 19:47:45 +00:00
(sh ; she sells {ba,z,fi}sh shells on the C xor
+lsp
+tree-sitter)
2023-01-28 19:22:13 +00:00
;;sml
;;solidity ; do you need a blockchain? No.
;;swift ; who asked for emoji variables?
;;terra ; Earth and Moon in alignment for performance.
2023-01-30 19:47:45 +00:00
(web ; the tubes
+lsp
+tree-sitter)
(yaml +lsp) ; JSON, but readable
2023-01-28 19:22:13 +00:00
;;zig ; C, but simpler
#+end_src
2024-02-03 23:41:43 +00:00
** Emails
2023-01-28 19:22:13 +00:00
https://github.com/doomemacs/doomemacs/tree/master/modules/email
#+name :doom-email
#+begin_src emacs-lisp :tangle no
2023-04-23 21:00:23 +00:00
(mu4e +org)
2023-01-28 19:22:13 +00:00
;;notmuch
;;(wanderlust +gmail)
#+end_src
2024-02-03 23:41:43 +00:00
** App
2023-01-28 19:22:13 +00:00
https://github.com/doomemacs/doomemacs/tree/master/modules/app
#+name :doom-app
#+begin_src emacs-lisp :tangle no
;;calendar
;;emms
;;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
#+end_src
2024-02-03 23:41:43 +00:00
** Config
2023-01-28 19:22:13 +00:00
https://github.com/doomemacs/doomemacs/tree/master/modules/config
#+name :doom-config
#+begin_src emacs-lisp :tangle no
2023-01-30 19:47:45 +00:00
literate
2023-01-28 19:22:13 +00:00
(default +bindings +smartparens)
#+end_src
2024-02-03 23:41:43 +00:00
2024-07-16 15:46:24 +00:00
* General UI Tweaks
** Window Title bar
The title bar display string will display =♢= if there exist unsaved buffer modifications & =♦= otherwise.
2024-02-03 23:41:43 +00:00
2024-05-07 05:28:50 +00:00
#+begin_src emacs-lisp :tangle "config.el" :noweb no-export :comments no
2024-02-03 23:41:43 +00:00
(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
2024-02-04 00:52:30 +00:00
** Fonts
2024-07-16 15:46:24 +00:00
I use the [[https://www.nerdfonts.com/ ][nerdfont ]]'s [[https://github.com/i-tu/Hasklig ][Hasklig ]] for my monospaced font & Huerta Tipografica's [[https://www.huertatipografica.com/en/fonts/alegreya-ht-pro ][ Alegreya ]] serif font.
2024-02-03 23:41:43 +00:00
2024-05-07 05:28:50 +00:00
#+begin_src emacs-lisp :tangle "config.el" :noweb no-export :comments no
2024-02-03 23:41:43 +00:00
(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
2024-02-04 00:52:30 +00:00
* Keys
2024-07-16 15:46:24 +00:00
Key binds should be centralized in =$DOOMDIR/+keybinds.el= . This is loaded from =$DOOMDIR/config.el= file via
2023-01-30 19:47:45 +00:00
2024-05-07 05:28:50 +00:00
#+begin_src emacs-lisp :tangle "config.el" :noweb no-export :comments no
2023-01-30 19:47:45 +00:00
(load! "+keybinds")
#+end_src
2024-02-04 00:52:30 +00:00
2024-07-16 15:46:24 +00:00
Doom comes with some good key bind 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:
2023-01-30 19:47:45 +00:00
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.
2024-07-16 15:46:24 +00:00
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 key bind" using [[https://duckduckgo.com/ ][DDG ]]):
2023-01-30 19:47:45 +00:00
#+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
2024-07-16 15:46:24 +00:00
Note: Key binds should be defined with in the context that they are being used, not here
2023-01-30 19:47:45 +00:00
2024-02-04 00:52:30 +00:00
** Local Leader
2024-07-16 15:46:24 +00:00
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 in regard to org-mode. GitHub issue can be found [[https://github.com/doomemacs/doomemacs/issues/4242 ][here ]].
2023-01-30 19:47:45 +00:00
#+begin_src emacs-lisp :tangle "+keybinds.el" :noweb no-export :comments no
(setq doom-localleader-key ",")
#+end_src
2024-02-04 00:52:30 +00:00
** Speedup =whichkey= response
=whichkey= is slow to respond, lets make it a bit faster.
2024-05-07 05:28:50 +00:00
#+begin_src emacs-lisp :tangle "config.el" :noweb no-export :comments no
2024-02-04 00:52:30 +00:00
(setq which-key-idle-delay 0.1)
#+end_src
2023-01-30 19:47:45 +00:00
2024-02-04 02:14:41 +00:00
* Auto-Mode Alist
Some files we'll need to set the major-mode for manually. Either based on where the file is located, or its extension. To do this add the value to the =auto-mode-alist= and specify the major mode.
2023-01-30 19:47:45 +00:00
2024-02-04 02:14:41 +00:00
#+begin_src emacs-lisp :tangle no
(add-to-list 'auto-mode-alist '("/path/to/file/ .*\\.file" . markdown-mode))
#+end_src
** Tridactyl
2024-07-16 15:46:24 +00:00
I am currently using Firefox with [[https://github.com/tridactyl/tridactyl ][Tridactyl ]]. The =editorcmd= creates a temporary file & opens it with the editor of choice. The domain is included in the temporary file name, but it's a fair assumption that it will markdown. We can use this to set the syntax of the file in question. This likely just be markdown.
2024-05-07 05:28:50 +00:00
#+begin_src emacs-lisp :tangle "config.el" :noweb no-export :comments no
2024-02-04 02:14:41 +00:00
(add-to-list 'auto-mode-alist '("/\\(tmp\\|private/var\\)/ .*/tmp_.* \\.txt" . markdown-mode))
2023-01-30 19:47:45 +00:00
#+end_src
2024-02-04 02:14:41 +00:00
* Orgmode
2024-07-16 15:46:24 +00:00
This file will be needed for emacs batch automation, where it's not reasonable to start up my entire working env. This file can be located at =$DOOMDIR/+orgmode.el= .
2023-01-30 19:47:45 +00:00
2024-05-07 05:28:50 +00:00
#+begin_src emacs-lisp :tangle "config.el" :noweb no-export :comments no
2024-02-04 00:52:30 +00:00
(load! "+orgmode")
2023-01-30 19:58:25 +00:00
#+end_src
2024-07-12 03:22:09 +00:00
2024-07-16 15:46:24 +00:00
This file may get consumed via emacs batch scripting, so we need to make sure the orgmode is actually loaded.
2023-01-30 19:47:45 +00:00
#+begin_src emacs-lisp :tangle "+orgmode.el" :noweb no-export :comments no
(require 'org)
#+end_src
2024-02-04 02:14:41 +00:00
** Directories
2024-07-12 03:22:09 +00:00
Notes are stored in the =$HOME/org= directory, and are synced to GitHub. See [[*Syncing ][Syncing ]] for more on this.
2023-01-30 19:47:45 +00:00
#+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
2024-07-12 03:22:09 +00:00
├── README.org
├── _logseq
├── journals
├── projects
├── roam
└── work
2023-01-30 19:47:45 +00:00
#+end_example
2024-02-04 02:14:41 +00:00
*** =.archive=
2023-01-30 19:47:45 +00:00
Where old files go. See =org-archive-subtree= for more.
2024-02-04 02:14:41 +00:00
*** =.attach=
2024-07-12 03:22:09 +00:00
This is things that aren't orgmode files, but should be included in an orgmode file. Tangled scripts, images, etc.
2023-01-30 19:47:45 +00:00
#+begin_src emacs-lisp :tangle "+orgmode.el" :noweb no-export :comments no
2024-02-05 14:59:38 +00:00
(setq org-download-image-dir (concat org-directory ".attach/"))
2023-01-30 19:47:45 +00:00
#+end_src
2024-02-04 02:14:41 +00:00
*** =Projects=
2023-01-30 19:47:45 +00:00
I keep a =todo.org= at the root of each project. These are symlinked into the Projects directory. Nextcloud does not sync symlinked documents.
2024-07-12 03:22:09 +00:00
*** =roam=
[[https://www.orgroam.com/ ][org-roam ]] is a great Zettelkasten toolkit with back link graphing. I'll try to store as much of my written notes in this format.
2023-01-30 19:47:45 +00:00
#+begin_src emacs-lisp :tangle "+orgmode.el" :noweb no-export :comments no
2024-07-12 03:22:09 +00:00
(setq org-roam-directory (concat org-directory "roam"))
2023-01-30 19:47:45 +00:00
#+end_src
2024-07-12 03:22:09 +00:00
*** =todo=
Incomplete list of todo files as there is always more.
2023-01-30 19:47:45 +00:00
#+begin_src emacs-lisp :tangle "+orgmode.el" :noweb no-export :comments no
2024-07-12 03:22:09 +00:00
(setq org-agenda-files (list (concat org-directory "todo" )))
2023-01-30 19:47:45 +00:00
#+end_src
2024-07-12 03:22:09 +00:00
*** Journals
Dailies. This is also handled by Org-roam.
#+begin_src emacs-lisp :tangle "+orgmode.el" :noweb no-export :comments no
(setq org-roam-dailies-directory (concat org-directory "journals/"))
2023-01-30 19:47:45 +00:00
#+end_src
2024-07-12 03:22:09 +00:00
*** =Work=
2023-01-30 19:47:45 +00:00
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
2024-01-19 18:42:40 +00:00
(defvar-local +org-capture-work-todo-file
2024-02-05 14:59:38 +00:00
(expand-file-name "Work/todo.org" org-directory))
2023-01-30 19:47:45 +00:00
(add-to-list 'org-capture-templates
'("w" "Work Todo" entry
(file+headline +org-capture-work-todo-file "Inbox")
2024-01-22 19:33:15 +00:00
"* [_] %i%?\n%a - %u" :prepend t))
2023-01-30 19:47:45 +00:00
#+end_src
2024-07-12 03:22:09 +00:00
** Syncing
Syncing of the ~org-directory~ is done via git with remote of https://github.com/jamesepatrick/notes. Changes are auto-committed & pushed using [[https:/ /github.com/ryuslash/git-auto-commit-mode][git-auto-commit-mode]] in Emacs & [[https:/ /workingcopy.app/ ][Working Copy]] with iOS Shortcuts on iOS.
Grab the package from MELPA
#+begin_src emacs-lisp :tangle "packages.el" :noweb no-export :comments no :results output silent
(package! git-auto-commit-mode)
#+end_src
For configuring it we'll want the following settings:
- =gac-automatically-push-p= :: Automatically push new changes.
- =gac-automatically-add-new-files-p= :: Automatically add new files.
2024-07-16 15:46:24 +00:00
Additionally, we'll also want to add a big of additional logic so that we will automatically pull changes as well. It may be worth setting up a crontab to automate the pull in the future.
2024-07-12 03:22:09 +00:00
This snippet below is from siatwe's comment [[https://github.com/ryuslash/git-auto-commit-mode/pull/40#issuecomment-1772237807 ][here ]].
#+begin_src emacs-lisp :tangle "+orgmode.el" :noweb no-export :comments no
(use-package! git-auto-commit-mode
:config
(setq-default gac-automatically-push-p t)
(setq-default gac-automatically-add-new-files-p t)
(defun gac-pull-before-push (&rest _args)
(let ((current-file (buffer-file-name)))
(shell-command "git pull")
(when current-file
(with-current-buffer (find-buffer-visiting current-file)
(revert-buffer t t t)))))
(advice-add 'gac-push :before #'gac-pull-before-push))
#+end_src
Configuring should be done at the at the [[https://www.gnu.org/software/emacs/manual/html_node/emacs/Directory-Variables.html#Directory-Variables ][per directory level ]]. The following snippet should be placed at =$HOME/org/.dir-locals.el= .
#+begin_src emacs-lisp :tangle no :comments no :results output silent
((nil . ((eval git-auto-commit-mode 1)
(gac-automatically-push-p t)
(gac-automatically-add-new-files-p t))))
#+end_src
2024-02-04 02:14:41 +00:00
** A Prettier Orgmode
*** Use a serif variable font
2023-01-30 19:47:45 +00:00
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
2024-02-04 02:14:41 +00:00
*** Pretty mode
2023-01-30 19:47:45 +00:00
#+begin_src emacs-lisp :tangle "+orgmode.el" :noweb no-export :comments no
(add-hook! 'org-mode-hook #'+org-pretty-mode)
#+end_src
2024-02-04 02:14:41 +00:00
*** Agenda faces
2023-01-30 19:47:45 +00:00
#+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
2024-02-04 02:14:41 +00:00
*** Prettify Symbols
2023-01-30 19:47:45 +00:00
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 ()
2024-02-05 14:59:38 +00:00
"Beautify Org Checkbox Symbol"`
(push '("[ ]" . "☐") prettify-symbols-alist)
(push '("[_]" . "☐") prettify-symbols-alist)
(push '("[X]" . "☑" ) prettify-symbols-alist)
(push '("[-]" . "⊟" ) prettify-symbols-alist)
(prettify-symbols-mode)))
2023-01-30 19:47:45 +00:00
#+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
2024-02-04 02:14:41 +00:00
*** Fancy Source Blocks
2023-01-30 19:47:45 +00:00
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" . ?⎣) ;; ⎣ ✐
2024-02-03 20:40:18 +00:00
(":LOGBOOK:" . ?) ;;
2023-01-30 19:47:45 +00:00
("#+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
2024-02-04 02:14:41 +00:00
** Drawers
2023-02-18 21:21:11 +00:00
https://orgmode.org/manual/Drawers.html
2024-02-04 02:14:41 +00:00
*** State Change Log
2023-02-18 21:21:11 +00:00
Logs updates can bleed into the notes. Sticking them in a drawer works as a better escape then indentations.
#+begin_src emacs-lisp :tangle "+orgmode.el" :noweb no-export :comments no
(setq org-log-into-drawer t)
#+end_src
2024-02-04 02:14:41 +00:00
*** Clock drawers
2023-02-18 21:21:11 +00:00
#+begin_src emacs-lisp :tangle "+orgmode.el" :noweb no-export :comments no
(setq org-clock-into-drawer t)
#+end_src
2024-02-04 02:14:41 +00:00
** Roam
2023-01-30 19:47:45 +00:00
I use =org-roam= v2 for most of my note taking. TODO expand this section.
2024-02-04 02:14:41 +00:00
*** Dailies Templates
2023-02-06 01:21:41 +00:00
#+begin_src emacs-lisp :tangle "+orgmode.el" :noweb no-export :comments no :results output silent
2023-01-30 19:47:45 +00:00
(setq org-roam-dailies-capture-templates
2023-02-06 01:21:41 +00:00
'(("l" "Log" entry "* %T %?"
2023-01-30 19:47:45 +00:00
:target (file+head+olp "%<%Y-%m-%d >.org"
2023-02-06 01:21:41 +00:00
"#+title: %<%Y-%m-%d >\n#+filetags: %<:%Y:%B:daily: >\n\n* Goals\n* Logs"
("Logs")))
("g" "Goal" entry "* TODO %?"
2023-01-30 19:47:45 +00:00
:target (file+head+olp "%<%Y-%m-%d >.org"
2023-02-06 01:21:41 +00:00
"#+title: %<%Y-%m-%d >\n#+filetags: %<:%Y:%B::daily >\n\n* Goals\n* Logs"
2023-01-30 19:47:45 +00:00
("Goals")))))
#+end_src
2024-02-04 02:14:41 +00:00
*** Keybinds
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.
** Mermaid
2023-02-12 22:53:15 +00:00
[[https://mermaid.js.org/ ][MermaidJS ]] is a diagramming and charting tool similar to Dot/Graphviz, but significantly prettier with less boilerplate. We'll likely only ever want to modify it in the context of =org-mode= so we'll want [[https:/ /github.com/arnm/ob-mermaid][ob-mermaid]].
Add the following the =packages.el=
#+begin_src emacs-lisp :tangle "packages.el" :noweb no-export :comments no :results output silent
(package! ob-mermaid)
#+end_src
2024-02-04 02:14:41 +00:00
** Babel stuff
2023-02-01 03:15:44 +00:00
Babel execute can be tweaked per the syntax see orgmode docs [[https://orgmode.org/manual/Evaluating-Code-Blocks.html ][here ]].
2024-02-04 02:14:41 +00:00
*** Src blocks
2023-02-18 21:21:33 +00:00
These are grabbed from [[https://www.gtrun.org/custom/config ][gtrun ]]'s configuration.'
#+begin_src emacs-lisp :tangle "+orgmode.el" :noweb no-export :comments no :results output silent
(setq org-src-fontify-natively t
org-src-preserve-indentation t
org-src-tab-acts-natively t
org-src-window-setup 'current-window)
#+end_src
2024-02-04 02:14:41 +00:00
*** Diff
2023-02-01 03:15:44 +00:00
The snippet below is largely pulled from John Kitchin [[https://emacs.stackexchange.com/questions/63517/org-mode-evaluate-diff-code-block/63520#63520 ][Stackexchange Post ]].
#+begin_src emacs-lisp :tangle "+orgmode.el" :noweb no-export :comments no
(defun org-babel-execute:diff (body params)
"Applies diff patches. Use with care.
See https://emacs.stackexchange.com/questions/63517/org-mode-evaluate-diff-code-block"
(with-temp-buffer
(insert body "\n")
(shell-command-on-region (point-min) (point-max) "patch --strip=1" "*patch* ")
(prog1
(with-current-buffer "*patch* " (buffer-string))
(kill-buffer "*patch* "))))
#+end_src
As an sample:
#+begin_example
#+BEGIN_SRC org :tangle a.org
1
2
#+END_SRC
#+BEGIN_SRC org :tangle b.org
1
3
#+END_SRC
#+begin_src diff
--- a.org 2021-02-21 20:20:27.000000000 -0500
+++ b.org 2021-02-21 20:20:27.000000000 -0500
@@ -1,2 +1,2 @@
1
-2
+3
#+end_src
#+RESULTS :
: patching file a.org
#+BEGIN_SRC sh
cat a.org
#+END_SRC
#+RESULTS :
| 1 |
| 3 |
#+end_example
2024-02-04 02:14:41 +00:00
** Export to Tufte
2024-01-29 04:54:32 +00:00
Rather than using =org-export-dispatch= 's html export, we'll want to use [[https://github.com/ox-tufte/ox-tufte ][ox-tufte ]]. The HTML output is a more reasonable than the HTML format.
#+BEGIN_SRC emacs-lisp :tangle "packages.el"
(package! ox-tufte)
#+END_SRC
Just load the require to setup the dependency.
#+begin_src emacs-lisp :tangle "+orgmode.el" :noweb no-export :comments no
2024-02-05 14:52:49 +00:00
(use-package! ox-tufte)
2024-01-29 04:54:32 +00:00
#+end_src
By default the =org-export-dispatch= , includes some basic styling. This causes issues with our HTML. We'll need to turn off these.
#+begin_src emacs-lisp :tangle "+orgmode.el" :noweb no-export :comments no
2024-02-05 14:52:49 +00:00
(after! org
(setq org-html-head ""
org-html-head-extra ""))
2024-01-29 04:54:32 +00:00
#+end_src
The syntax highlighting for html is done inline in the by default. We don't want to do that; we're using CSS. See the file in [[file:dist/code.css ][code.css ]] file for more.
#+begin_src emacs-lisp :tangle "+orgmode.el" :noweb no-export :comments no
2024-02-05 14:52:49 +00:00
(after! org
(setq org-html-htmlize-output-type "css"))
2024-01-29 04:54:32 +00:00
#+end_src
To use this you will need to include the setup file. This will load the required css & js files. See [[https://orgmode.org/manual/In_002dbuffer-Settings.html ][here ]] for more.
#+begin_src org :tangle no
#+SETUPFILE : ~/.dotfiles/emacs/dist/setup.org
#+end_src
This will load the CSS and JS files located in the =dotfiles/emacs/dist/= directory.
2024-01-22 19:34:31 +00:00
** Capture
The default =+org-capture/open-frame= is a little small. Let's modify the parameters to make it a little larger
2023-04-24 02:28:17 +00:00
2024-01-22 19:34:31 +00:00
#+begin_src emacs-lisp :tangle "+orgmode.el" :noweb no-export :comments no
(setq +org-capture-frame-parameters '((name . "doom-capture")
(width . 100)
(height . 20)
(transient . t)
))
#+end_src
2024-02-05 14:52:49 +00:00
2024-02-04 02:14:41 +00:00
* GPT
2024-06-18 21:46:26 +00:00
GPT is more useful than I thought. Its incredibly helpful for writing prose which I can struggle with due to mild dysgraphia.
** ChatGPT
We will be using the [[https://github.com/karthink/gptel ][karthink/gptel ]] package.
2023-04-24 02:28:17 +00:00
#+BEGIN_SRC emacs-lisp :tangle "packages.el"
2024-01-27 05:02:32 +00:00
(package! gptel)
2023-04-24 02:28:17 +00:00
#+END_SRC
2024-05-07 05:28:50 +00:00
#+begin_src emacs-lisp :tangle "config.el" :noweb no-export :comments no
2024-01-27 05:02:32 +00:00
(use-package! gptel)
2023-04-24 02:28:17 +00:00
#+end_src
2024-01-27 05:02:32 +00:00
This package supports multiple LLM backends. I'm going to be using the OpenAI ChatGPT backend by default. We'll need to set the API key. There are a couple ways this can be done, but we're going to set this using =~/.authinfo.gpg= . This will need to be decrypted before use, but this is pretty minor.
2023-04-24 02:28:17 +00:00
2024-01-27 05:02:32 +00:00
#+begin_src authinfo :tangle no
machine api.openai.com login apikey password TOKEN
2023-04-24 02:28:17 +00:00
#+end_src
2024-06-18 21:46:26 +00:00
** TRAIL_RUN CoPilot
I'm presently using GitHub copilot for work. It can best be summarized as having a intern periodically writing code for you. The code quality is so-so, and often buggy or incorrect. You will often spend as long debugging some of the code as you would have saved writing it yourself. But it is useful for the rote drudgery that occurs with some coding.
For this I'm going to use [[https://github.com/copilot-emacs/copilot.el ][copilot-emacs/copilot.el ]].
First install the package
#+BEGIN_SRC emacs-lisp :tangle "packages.el"
(package! copilot
:recipe (:host github :repo "copilot-emacs/copilot.el" :files ("*.el")))
#+END_SRC
Then configure this
#+begin_src emacs-lisp
(use-package! copilot
:hook (prog-mode . copilot-mode)
:bind (:map copilot-completion-map
("<tab >" . 'copilot-accept-completion)
("TAB" . 'copilot-accept-completion)
("C-TAB" . 'copilot-accept-completion-by-word)
("C-<tab >" . 'copilot-accept-completion-by-word)))
#+end_src
This does bind to company, which I've currently removed. See [[*Completion ][Completion ]] for specifics.
2024-02-04 02:14:41 +00:00
** Keybinds
| Keybind | Command |
|---------+---------------------|
| =SPC A a= | =gptel-menu= |
| =SPC A c= | =gptel-system-prompt= |
| =SPC A m= | =gptel-menu= |
| =SPC A o= | =gptel= |
| =SPC A r= | =gptel-rewrite-menu= |
| =SPC A s= | =gptel-send= |
| =SPC A t= | =gptel-set-topic= |
2024-01-27 05:02:32 +00:00
#+begin_src emacs-lisp :tangle "+keybinds.el" :noweb no-export :comments no
(map! :leader
(:prefix-map ("A" . "GPT")
:desc "Menu" "m" #'gptel-menu
:desc "Menu" "a" #'gptel-menu
:desc "Send" "s" #'gptel-send
:desc "Open Session" "o" #'gptel
:desc "Set Topic" "t" #'gptel-set-topic
:desc "Rewrite" "r" #'gptel-rewrite-menu
:desc "Change Prompt" "c" #'gptel-system-prompt
)
)
2023-04-24 02:28:17 +00:00
#+end_src
2024-02-04 02:14:41 +00:00
* Snippets
2024-01-27 05:24:25 +00:00
We've enabled the [[doom-module:editor snippets ][snippets module ]] [[*Editor ][earlier ]]. This will give us use of the [[https://github.com/doomemacs/snippets ][Doom Snippets package ]], but we'll want to add our own as well. Custom snippets are added under =$DOOMDIR/snippets/= directory. Documentation on how to write snippets can be found at [[http://joaotavora.github.io/yasnippet/snippet-development.html ][yas-snippet/documentation ]] and [[https://github.com/doomemacs/snippets ][doom-snippets github page ]].
While we'll want to store these snippets in this orgmode document, using the =+snippets/create= & =snippets/edit= may be useful for creating these.
2024-02-04 02:14:41 +00:00
** Orgmode
2024-01-27 05:24:25 +00:00
In my work todo and my roam notes I've been using a list elements with nerd-fonts icons under my section header to provide quick links for the context. Below are a few that I've been using.
- [[github:github/example ][github/example ]]
#+begin_src snippet :tangle "snippets/org-mode/gh"
# -*- mode: snippet -*-
# name: Github Element
# uuid: gh
# key: gh
# --
- ${1:repo}
#+end_src
2024-05-07 14:13:21 +00:00
- [[https://example.com ][example.com ]]
2024-01-27 05:24:25 +00:00
#+begin_src snippet :tangle "snippets/org-mode/lk"
# -*- mode: snippet -*-
# name: Link Elment
# uuid: lk
# key: lk
# --
2024-05-07 14:13:21 +00:00
- ${1:link}
2024-01-27 05:24:25 +00:00
#+end_src
- [[https://example.com ][Jira-12929 ]]
#+begin_src snippet :tangle "snippets/org-mode/ticket"
# -*- mode: snippet -*-
# name: Ticker Elment
# uuid: ticket
# key: ticket
# --
- ${1:link}
#+end_src
2023-01-28 19:22:13 +00:00
* Content Stolen From
2023-02-12 22:50:26 +00:00
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/
- https://www.gtrun.org/custom/config.htm
2023-01-28 19:22:13 +00:00
* Footnotes
2024-02-03 23:41:43 +00:00
[fn:7]Documentation [[https://github.com/doomemacs/doomemacs/blob/d38787edf48f4c08bdf7ea8b3b54fcbc268f13b5/docs/getting_started.org#additional-files ][here ]].
[fn:6]Yes, I'm aware make is a terrible task runner.
[fn:5] this is documented in [[*Export to Tufte ][Export to Tufte ]]
[fn:4] for example this entire paragraph could have been skipped.
[fn:3]See documentation [[https://github.com/doomemacs/doomemacs/blob/d38787edf48f4c08bdf7ea8b3b54fcbc268f13b5/docs/getting_started.org#configure ][here ]].
2023-06-07 14:17:37 +00:00
[fn:2] See [[https://github.com/doomemacs/doomemacs/tree/master/modules/tools/magit#i-recently-updated-and-now-i-get-deferred-error--wrong-type-argument-sequencep-code-reviewauth-token-set-whenever-i-try-to-review ][Doom Magit documentation. ]]
2023-01-28 19:22:13 +00:00
[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. ]]