Link:
Intro to emacs
I am reluctantly returning to Emacs again, as I don't currently have time to rebuild org-mode and org-roam. I am also interested in the functional programming paradigm offered by org-babel
Personal Information
I am copying the configuration from Daniel Mai as found here: https://github.com/danielmai/.emacs.d/
(setq user-full-name "Roerick Sweeney"
user-mail-address "sweeney@roerick.me")Theme
Convenient theme functions
(defun switch-theme (theme)
"Disables any currently active themes and loads THEME."
;; This interactive call is taken from `load-theme'
(interactive
(list
(intern (completing-read "Load custom theme: "
(mapc 'symbol-name
(custom-available-themes))))))
(let ((enabled-themes custom-enabled-themes))
(mapc #'disable-theme custom-enabled-themes)
(load-theme theme t)))
(defun disable-active-themes ()
"Disables any currently active themes listed in `custom-enabled-themes'."
(interactive)
(mapc #'disable-theme custom-enabled-themes))
(bind-key "s-<f12>" 'switch-theme)
(bind-key "s-<f11>" 'disable-active-themes)
Doom theme
(use-package doom-themes
:ensure t
:config
(customize-set-variable 'doom-molokai-brighter-comments t)
(switch-theme 'doom-molokai))Cyberpunk theme
I tend to switch themes more often than normal. For example, switching
to a lighter theme (such as the default) or to a different theme
depending on the time of day or my mood. Normally, switching themes is
a multi-step process with disable-theme and load-theme. The
switch-theme function will do that in one swoop. I just choose which
theme I want to go to.
The cyberpunk theme is dark and colorful. However, I don't like the boxes around the mode line. (use-package cyberpunk-theme :if (window-system) :ensure t :init (progn (load-theme 'cyberpunk t) (set-face-attribute `mode-line nil :box nil) (set-face-attribute `mode-line-inactive nil :box nil))) #+end_src
Solarized theme
Here's some configuration for bbatsov's solarized themes.
(use-package solarized-theme
:ensure t
:init
(setq solarized-use-variable-pitch nil)
:config
(switch-theme 'solarized-dark))Monokai theme
(use-package monokai-theme
:if (window-system)
:ensure t
:init
(setq monokai-use-variable-pitch nil)
(switch-theme 'monokai))Waher theme
(use-package waher-theme
if (window-system)
:ensure t
:init
(load-theme 'waher))Sane defaults
Let's start with some sane defaults, shall we?
Sources for this section include Magnars Sveen and Sacha Chua.
;; These functions are useful. Activate them.
(put 'downcase-region 'disabled nil)
(put 'upcase-region 'disabled nil)
(put 'narrow-to-region 'disabled nil)
(put 'dired-find-alternate-file 'disabled nil)
;; Answering just 'y' or 'n' will do
(defalias 'yes-or-no-p 'y-or-n-p)
;; Keep all backup and auto-save files in one directory
(setq backup-directory-alist '(("." . "~/.emacs.d/backups")))
(setq auto-save-file-name-transforms '((".*" "~/.emacs.d/auto-save-list/" t)))
;; UTF-8 please
(setq locale-coding-system 'utf-8) ; pretty
(set-terminal-coding-system 'utf-8) ; pretty
(set-keyboard-coding-system 'utf-8) ; pretty
(set-selection-coding-system 'utf-8) ; please
(prefer-coding-system 'utf-8) ; with sugar on top
;; Turn off the blinking cursor
(blink-cursor-mode -1)
(setq-default indent-tabs-mode nil)
(setq-default indicate-empty-lines t)
;; Don't count two spaces after a period as the end of a sentence.
;; Just one space is needed.
(setq sentence-end-double-space nil)
;; delete the region when typing, just like as we expect nowadays.
(delete-selection-mode t)
(show-paren-mode t)
(column-number-mode t)
(global-visual-line-mode)
(diminish 'visual-line-mode)
(setq uniquify-buffer-name-style 'forward)
;; -i gets alias definitions from .bash_profile
(setq shell-command-switch "-ic")
;; Don't beep at me
(setq visible-bell nil)
(setq ring-bell-function (lambda () nil))Evil mode
I tried to use Emacs without Evil mode before. I am switching to evil mode now.
;; Download Evil
(unless (package-installed-p 'evil)
(package-install 'evil))
;; Enable Evil
(require 'evil)
(evil-mode 1)Calendar
Hebrew Calendar
(require 'calendar)
(setq calendar-hebrew t)Org Mode
Intro
This is a big part of why I am returning to emacs. Ultimately, I feel like Org mode should be recreated using external, unix type tools, but this is not the case and it may never be the case, so here we are.
Things I like about org
Outlining
Outlining in org is amazing. Really, there's not much like it. Buildling out the outlining features of org alone would be a colossal project
org agenda
We import both our regular todo file here as well as our lunar phases file.
(add-to-list 'org-agenda-files "~/org/todo.org" "~/org/moon.org")Org Babel
Org has a feature called org babel which lets you execute code blocks from inside of an org file. Previously, I haven't used this much. I mainly used org for zettlekasten work. However, after diving into some of the work by Lutheran Harlot Donald Knuth, I am developing an appreciation for Literate Programming, as he calls it. Because I come from a background of python data analytics, I used to use Jupyter Notebooks. I found this was a super useful way to write code and even communication with non programmers.
Org Roam
(use-package org-roam
:ensure t
:custom
(org-roam-directory (file-truename "/home/roerick/org/roam"))
:bind (("C-c n l" . org-roam-buffer-toggle)
("C-c n f" . org-roam-node-find)
("C-c n g" . org-roam-graph)
("C-c n i" . org-roam-node-insert)
("C-c n c" . org-roam-capture)
;; Dailies
("C-c n j" . org-roam-dailies-capture-today))
:config
;; If you're using a vertical completion framework, you might want a more informative completion interface
(setq org-roam-node-display-template (concat "${title:*} " (propertize "${tags:10}" 'face 'org-tag)))
(org-roam-db-autosync-mode)
;; If using org-roam-protocol
(require 'org-roam-protocol))
Dabar Mode
(add-to-list 'load-path "~/dev/dabar/")
(require 'dabar-mode)
(add-hook 'find-file-hook 'activate-dabar-mode-in-directory)Dabar mode is a bible reader app with org-roam functionality.
It currently resides here: https://github.com/sroerick/dabar/ It offers the ability to read chapters of the bible, insert bible verses into org documents, create bible: links which org-roam can track and follow, show backlinks on pages which have stuff linked to them, and more.
Ultimately, I should probably factor out the bible reader from the roam functionality in order to publish this in MELPA
I would also like to add concordance features into this.
Enable org mode
(global-set-key (kbd "C-c l") #'org-store-link)
(global-set-key (kbd "C-c a") #'org-agenda)
(global-set-key (kbd "C-c c") #'org-capture)Aesthetic Changes
Org bullets
TODO I couldn't get org bullets to load
Titles and headlines
Org-Publish
My goal here is to use Org- publish in order to publish an org-roam Zettelkasten. https://www.asterhu.com/post/20240220-publish-org-roam-with-quartz-oxhugo/ I like this workflow which uses ox-hugo and Quartz. Quartz is an interesting too that I had not heard of before.
Require ox-hugo
(use-package ox-hugo
:ensure t ;Auto-install the package from Melpa
:pin melpa ;`package-archives' should already have ("melpa" . "https://melpa.org/packages/")
:after ox
)
(setq org-hugo-base-dir "/home/roerick/dev/quartz")Modify Capture Templates for org-roam
(setq org-roam-capture-templates
'(("o" "moc" plain
"\n*Link*: %?\n\n"
:if-new (file+head "${slug}.org" "#+title: ${title}\n#+filetags: :moc:\n#+hugo_section: braindump\n#+date: %u\n#+hugo_lastmod: %u\n#+hugo_tags: noexport\n")
:immediate-finish t
:unnarrowed t
:empty-lines-after 1)))Modify timestamp on org file after safe
Update last modified date for ox-hugo export
(defun my-org-time-stamp-setup ()
(setq time-stamp-active t
time-stamp-start "#\\+hugo_lastmod:[ \t]*"
time-stamp-end "$"
time-stamp-format "$$%Y-%m-%d$$")
(when (eq major-mode 'org-mode)
(time-stamp)))
(add-hook 'before-save-hook 'my-org-time-stamp-setup)
Language config
Tresitter
(setq treesit-font-lock-level 4)Ocaml
(use-package tuareg
:ensure t
:mode (("\\.ocamlinit\\'" . tuareg-mode)))
(use-package eglot
:ensure t)
(use-package ocaml-eglot
:ensure t
:after tuareg
:hook
(tuareg-mode . ocaml-eglot)
(ocaml-eglot . eglot-ensure)
(ocaml-eglot . (lambda () (add-hook #'before-save-hook #'eglot-format nil t)))
:config
(setq ocaml-eglot-syntax-checker 'flymake))
;; Additional modes configuration
(use-package dune
:ensure t)
(use-package opam-switch-mode
:ensure t
:hook
(tuareg-mode . opam-switch-mode))
(use-package ocp-indent
:ensure t
:config
(add-hook 'ocaml-eglot-hook 'ocp-setup-indent))Wishlist
Treemacs - File Explorer
Shortcut for inserting templated code blocks in org
https://orgmode.org/manual/Structure-Templates.html https://github.com/RyanMatlock/Emacs-literate-config/blob/main/core-config.org -- search for org tempo
Completions
I don't know how to set up completions so I'm going to put all the options here.
https://github.com/RyanMatlock/Emacs-literate-config/blob/main/core-config.org
Vertico
;; Enable Vertico.
(use-package vertico
:ensure t
:custom
(vertico-scroll-margin 0) ;; Different scroll margin
(vertico-count 20) ;; Show more candidates
(vertico-resize t) ;; Grow and shrink the Vertico minibuffer
(vertico-cycle t) ;; Enable cycling for `vertico-next/previous'
:init
(vertico-mode))
;; Persist history over Emacs restarts. Vertico sorts by history position.
(use-package savehist
:ensure t
:init
(savehist-mode))
;; Emacs minibuffer configurations.
(use-package emacs
:custom
;; Enable context menu. `vertico-multiform-mode' adds a menu in the minibuffer
;; to switch display modes.
(context-menu-mode t)
;; Support opening new minibuffers from inside existing minibuffers.
(enable-recursive-minibuffers t)
;; Hide commands in M-x which do not work in the current mode. Vertico
;; commands are hidden in normal buffers. This setting is useful beyond
;; Vertico.
(read-extended-command-predicate #'command-completion-default-include-p)
;; Do not allow the cursor in the minibuffer prompt
(minibuffer-prompt-properties
'(read-only t cursor-intangible t face minibuffer-prompt)))
;; Optionally use the `orderless' completion style.
(use-package orderless
:ensure t
:custom
;; Configure a custom style dispatcher (see the Consult wiki)
;; (orderless-style-dispatchers '(+orderless-consult-dispatch orderless-affix-dispatch))
;; (orderless-component-separator #'orderless-escapable-split-on-space)
(completion-styles '(orderless basic))
(completion-category-overrides '((file (styles partial-completion))))
(completion-category-defaults nil) ;; Disable defaults, use our settings
(completion-pcm-leading-wildcard t)) ;; Emacs 31: partial-completion behaves like substring
VERTical Interactive COmpletion
Vertico provides a performant and minimalistic vertical completion UI based on the default completion system. The focus of Vertico is to provide a UI which behaves correctly under all circumstances. By reusing the built-in facilities system, Vertico achieves full compatibility with built-in Emacs completion commands and completion tables. Vertico only provides the completion UI but aims to be highly flexible, extendable and modular. Additional enhancements are available as extensions or complementary packages. The code base is small and maintainable. The main vertico.el package is only about 600 lines of code without white space and comments.
Ido
Ido is built in already. I guess it does string matching and some other stuff. I don't really know what it's for
Ivy
Corfu
(use-package corfu
:ensure t
;; Optional customizations
:custom
(corfu-cycle t) ;; Enable cycling for `corfu-next/previous'
;; (corfu-quit-at-boundary nil) ;; Never quit at completion boundary
;; (corfu-quit-no-match nil) ;; Never quit, even if there is no match
;; (corfu-preview-current nil) ;; Disable current candidate preview
;; (corfu-preselect 'prompt) ;; Preselect the prompt
;; (corfu-on-exact-match 'insert) ;; Configure handling of exact matches
;; Enable Corfu only for certain modes. See also `global-corfu-modes'.
;; :hook ((prog-mode . corfu-mode)
;; (shell-mode . corfu-mode)
;; (eshell-mode . corfu-mode))
:init
;; Recommended: Enable Corfu globally. Recommended since many modes provide
;; Capfs and Dabbrev can be used globally (M-/). See also the customization
;; variable `global-corfu-modes' to exclude certain modes.
(global-corfu-mode)
;; Enable optional extension modes:
;; (corfu-history-mode)
;; (corfu-popupinfo-mode)
)
;; A few more useful configurations...
(use-package emacs
:custom
;; TAB cycle if there are only few candidates
;; (completion-cycle-threshold 3)
;; Enable indentation+completion using the TAB key.
;; `completion-at-point' is often bound to M-TAB.
(tab-always-indent 'complete)
;; Emacs 30 and newer: Disable Ispell completion function.
;; Try `cape-dict' as an alternative.
(text-mode-ispell-word-completion nil)
;; Hide commands in M-x which do not apply to the current mode. Corfu
;; commands are hidden, since they are not used via M-x. This setting is
;; useful beyond Corfu.
(read-extended-command-predicate #'command-completion-default-include-p))