commit 92638d3ed400ede5f12862845bbdfa4c9d3d2049
parent f9be091b0e6bdab6d2e0e39529176244d0ec70f1
Author: Ethan Long <me@ethandl.dev>
Date: Mon, 29 Jun 2026 20:25:52 +1000
Fixed some variable naming and other errata.
Things should now work even better :)
Diffstat:
| A | clean.sh | | | 3 | +++ |
| M | config.org | | | 125 | ++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------- |
| M | init.el | | | 20 | ++++++++++++++------ |
3 files changed, 100 insertions(+), 48 deletions(-)
diff --git a/clean.sh b/clean.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+rm -rf config.el config.el~ eln-cache/ elpaca/ tree-sitter/ platform-config/
diff --git a/config.org b/config.org
@@ -45,6 +45,7 @@ I use mostly the recommended QWERTY binds given by the Meow devs:
:meow-setup:
#+begin_src emacs-lisp
(defun ethandl/meow-setup ()
+ (require 'meow)
(setq meow-cheatsheet-layout meow-cheatsheet-layout-qwerty)
(setq meow-keypad-leader-dispatch "C-x")
(meow-motion-overwrite-define-key
@@ -136,11 +137,21 @@ I use mostly the recommended QWERTY binds given by the Meow devs:
:end:
#+begin_src emacs-lisp
- (elpaca meow
+ (elpaca 'meow
(require 'meow)
(ethandl/meow-setup)
(meow-global-mode 1))
#+end_src
+Unfortunately in daemon mode, meow's fonts are not initialized correctly. Here is a workaround (very similar to [[https://github.com/meow-edit/meow/issues/491][this one on GitHub]]):
+#+begin_src emacs-lisp
+ (defun ethandl/fix-meow-faces ()
+ "Fixes the faces for meow when emacs is running in daemon mode"
+ (add-hook 'server-after-make-frame-hook #'meow--prepare-face))
+#+end_src
+Now because we don't have any guarantee of ~meow--prepare-face~ being available until after elpaca has completed the installation of everything, we have to add this to the ~elpaca-after-init-hook~:
+#+begin_src emacs-lisp
+ (add-hook 'elpaca-after-init-hook #'ethandl/fix-meow-faces)
+#+end_src
** Window navigation
When navigating windows, I find the binding ~C-x o~ to be rather slow when you have many buffers open in different arrangements, so I have adopted a set of bindings for the ~windmove-*~ functions that are left unused in the default configuration. These binds fit in quite nicely with the ~vim~-like keybinds that I use with ~meow~.
@@ -217,20 +228,38 @@ These are the fonts used generally by the Emacs user interface, and in any buffe
I like the fonts created by Toshi Omagari, primarily Codelia and Comic code.
As a fallback, I don't mind Monaco/Monego.
#+begin_src emacs-lisp
+ (defvar ethandl/font-name nil
+ "Font name for regular Emacs fonts
+ Used in all buffers.")
+
+ (defvar ethandl/font-size nil
+ "Size for regular Emacs fonts
+ Used in all buffers.")
+
+ (defvar ethandl/default-font-size 12
+ "Default size for regular Emacs fonts
+ Used in all buffers.")
+
+ (defvar ethandl/font-string nil
+ "Fully qualified string for use with `set-frame-font'
+ Describes the font used in all regular Emacs buffers.")
+
(defun ethandl/font-exists (fname)
- "Returns nil if the font FNAME does not exist, else returns the font"
+ "Returns nil if the font FNAME does not exist, else
+ returns the font list after and including FNAME"
(member fname (font-family-list)))
- (defun ethandl/set-mono-font-vars (&optional name size)
- "Set mono-font configuration variables
+ (defun ethandl/set-font-vars (&optional name size)
+ "Set font configuration variables
- Use NAME as the font family and SIZE as the font size in points.
- If NAME is nil, select the first available font from a predefined
- list. If SIZE is nil, uses 12.
+ Use NAME as the font family and SIZE as the font size in
+ points. If NAME is nil, select the first available font
+ from a predefined list. If SIZE is nil, uses
+ `ethandl/default-font-size'.
- Sets `ethandl/mono-font-name', `ethandl/mono-font-size', and
- `ethandl/mono-font-string'."
- (setq ethandl/mono-font-name
+ Sets `ethandl/font-name', `ethandl/font-size', and
+ `ethandl/font-string'."
+ (setq ethandl/font-name
(or name
(seq-find #'ethandl/font-exists
'("Codelia Ligatures"
@@ -238,24 +267,36 @@ As a fallback, I don't mind Monaco/Monego.
"Monego"
"Monaco"
"monospace"))))
- (setq ethandl/mono-font-size
- (or size 12))
- (setq ethandl/mono-font-string
- (format "%s-%d" ethandl/mono-font-name ethandl/mono-font-size)))
+ (setq ethandl/font-size
+ (or size ethandl/default-font-size))
+ (setq ethandl/font-string
+ (format "%s-%d" ethandl/font-name ethandl/font-size)))
- (defun ethandl/set-frame-mono-font (&optional frame name size)
- "Sets the mono font for frames
+ (defun ethandl/set-frame-font (&optional frame name size)
+ "Sets the font for a frame or all frames if FRAME is not
+ specified.
Use FRAME to specify the frame to change, NAME as the font family,
and SIZE as the font size in points. If FRAME is nil, will apply to
all open frames. If NAME or SIZE are nil, follows the same
- convention as `ethandl/set-mono-font-vars'."
- (ethandl/set-mono-font-vars name size)
- (set-frame-font ethandl/mono-font-string t (if frame (list frame) t)))
-
- (ethandl/set-frame-mono-font)
- (add-hook 'after-make-frame-functions #'ethandl/set-frame-mono-font)
- (add-hook 'server-after-make-frame-hook #'ethandl/set-frame-mono-font)
+ convention as `ethandl/set-font-vars'."
+ (if (or name size)
+ (ethandl/set-font-vars name size)
+ (unless (and ethandl/font-name
+ ethandl/font-size
+ ethandl/font-string)
+ (ethandl/set-font-vars)))
+
+ (set-frame-font ethandl/font-string t (if frame (list frame) t)))
+#+end_src
+Now we ensure that these functions apply the fonts both when the config is loaded, and whenever a new frame is made.
+It is particularly important to have the ~server-after-make-frame-hook~ if you are planning on running Emacs as a daemon:
+#+begin_src emacs-lisp
+ (ethandl/set-font-vars)
+ (ethandl/set-frame-font)
+
+ (add-hook 'after-make-frame-functions #'ethandl/set-frame-font)
+ (add-hook 'server-after-make-frame-hook #'ethandl/set-frame-font)
#+end_src
*** Org fonts
Org documents are configured to start in variable pitch mode such that we have two sets of fonts: Body (variable-pitch), and verbatim (monospaced fixed-pitch):
@@ -274,7 +315,7 @@ To define our desired fonts, we create functions as we did before in [[Code font
(defvar ethandl/org-font-ht nil
"Font height in org documents")
- (defun ethandl/set-org-font-vars (&optional height var mono)
+ (defun ethandl/org-set-font-vars (&optional height var mono)
"Sets the mono font variables for Org mode
Use HEIGHT to specify the font height in px, VAR as the
@@ -307,20 +348,20 @@ To define our desired fonts, we create functions as we did before in [[Code font
Next, we define a way to easily apply these fonts.
This is not as simple as it should be, because ~variable-pitch-mode~ takes over all Org fonts.
#+begin_src emacs-lisp
- (defun ethandl/set-org-fonts (&optional height var mono)
+ (defun ethandl/org-set-fonts (&optional height var mono)
"Applies the mono fonts for org mode. Arguments are the
same as for `ethandl/set-org-font-vars'."
(if (or height var mono)
- (ethandl/set-org-font-vars height var mono)
+ (ethandl/org-set-font-vars height var mono)
(unless (and ethandl/org-mono-font-name
ethandl/org-var-font-name
ethandl/org-font-ht)
- (ethandl/set-org-font-vars)))
+ (ethandl/org-set-font-vars)))
(custom-theme-set-faces
'user
`(variable-pitch ((t (:family ,ethandl/org-var-font-name :height ,ethandl/org-font-ht))))
- `(fixed-pitch ((t (:family ,ethandl/org-mono-font-name :height ,ethandl/org-font-ht))))
+ `(fixed-pitch ((t (:family ,ethandl/org-mono-font-name :height 0.9))))
'(org-block ((t (:inherit fixed-pitch))))
'(org-code ((t (:inherit (shadow fixed-pitch)))))
@@ -339,20 +380,20 @@ This is not as simple as it should be, because ~variable-pitch-mode~ takes over
Finally, we ensure that these functions are run whenever necessary:
#+begin_src emacs-lisp
;; Evaluate available fonts when loading config
- (ethandl/set-org-font-vars)
+ (ethandl/org-set-font-vars)
;; Evaluate available fonts when making a new frame (relevant for daemon mode)
- (add-hook 'after-make-frame-functions #'ethandl/set-org-font-vars)
- (add-hook 'server-after-make-frame-hook #'ethandl/set-org-font-vars)
+ (add-hook 'after-make-frame-functions #'ethandl/org-set-font-vars)
+ (add-hook 'server-after-make-frame-hook #'ethandl/org-set-font-vars)
;; Set the fonts when loading into an org buffer
- (add-hook 'org-mode-hook #'ethandl/set-org-fonts)
+ (add-hook 'org-mode-hook #'ethandl/org-set-fonts)
#+end_src
*** Ligatures
In order to get ligatures to display in regular builds of emacs, we use ~ligature.el~:
#+begin_src emacs-lisp
(unless (eq system-type 'darwin)
- (elpaca ligature
+ (elpaca 'ligature
(ligature-set-ligatures 'prog-mode '("<---" "<--" "<<-" "<-" "->" "-->" "--->" "<->" "<-->" "<--->" "<---->" "<!--"
"<==" "<===" "<=" "=>" "=>>" "==>" "===>" ">=" "<=>" "<==>" "<===>" "<====>" "<!---"
"<~~" "<~" "~>" "~~>" "::" ":::" "==" "!=" "===" "!=="
@@ -362,14 +403,14 @@ In order to get ligatures to display in regular builds of emacs, we use ~ligatur
** Theme
I like the Catppuccin theme, but the official one kinda stinks. As such, I use the ~batppuccin~ theme:
#+begin_src emacs-lisp
- (elpaca batppuccin
+ (elpaca 'batppuccin
(require 'batppuccin)
(load-theme 'batppuccin-mocha t))
#+end_src
Another nice theme is ~gruber-darker~ by tsoding, one can use it similarly:
#+begin_src emacs-lisp :tangle no
- (elpaca gruber-darker-theme
+ (elpaca 'gruber-darker-theme
(require 'gruber-darker-theme)
(load-theme 'gruber-darker t))
#+end_src
@@ -402,7 +443,7 @@ There are a collection of variables that make scrolling behave more like that in
For smooth mouse and faster document scrolling, I use the package ~ultra-scroll~ by jdtsmith.
This works on all emacs builds to my knowledge, and is by far the best scrolling package.
#+begin_src emacs-lisp
- (elpaca ultra-scroll
+ (elpaca 'ultra-scroll
(require 'ultra-scroll)
(ultra-scroll-mode 1)
(add-hook 'ultra-scroll-hide-functions #'org-modern-mode))
@@ -440,7 +481,7 @@ The package ~async~ allows for us to run long, blocking commands in separate Ema
(defun ethandl/async-job-queue-add (form &optional inject-vars)
(push (list form inject-vars) ethandl/async-job-queue))
- (elpaca async
+ (elpaca 'async
(require 'async)
(ethandl/eval-async-job-queue)
(run-with-idle-timer 30 t 'ethandl/eval-async-job-queue))
@@ -478,7 +519,7 @@ I know that I said that I would keep things minimal...
I lied: this package is just for beauty because Org is somewhat ugly by default.
Unfortunately, this package conflicts with ~visual-wrap-prefix-mode~, so we need to explicitly disable that for org mode with a hook function.
#+begin_src emacs-lisp
- (elpaca org-modern
+ (elpaca 'org-modern
(require 'org-modern)
(add-hook 'org-mode-hook #'org-modern-mode)
(add-hook 'org-agenda-finalize-hook #'org-modern-agenda)
@@ -505,14 +546,14 @@ By default, the \(\text{\LaTeX}\) previews are displayed with PNG for speed, but
(setq org-latex-preview-process-default 'dvisvgm)
#+end_src
** Start with images
-By default, Org will wait until ~org-display-inline-images~ is run to display images. The following sets images to automatically load on file opening:
+By default, Org will wait until ~org-link-preview~ is run to display images. The following sets images to automatically load on file opening:
#+begin_src emacs-lisp
(setq org-startup-with-inline-images t)
#+end_src
If we want images generated by the output of ~org-babel~ to automatically render, we need to add the following to the hook:
#+begin_src emacs-lisp
- (add-hook 'org-babel-after-execute-hook #'org-display-inline-images)
+ (add-hook 'org-babel-after-execute-hook #'org-link-preview-region)
#+end_src
This will save a ~C-c C-x C-v~ invocation every time we want to display newly generated images.
* The programming environment
@@ -539,7 +580,7 @@ This list is then evaluated dynamically every time an Org document is opened thr
To make emacs a useful development environment, we need a good terminal.
In addition to using separate (good) terminals, we can use the cromulent ~vterm~ package:
#+begin_src emacs-lisp
- (elpaca vterm)
+ (elpaca 'vterm)
#+end_src
** Treesitter grammar async install
Treesitter grammar installation is slow and blocks up the emacs process. The following allows for asyncronous treesitter grammar installation on separate processes:
@@ -591,7 +632,7 @@ I don't like or use Powershell, but seeing as I sometimes operate on Windows (an
Due to my general distaste for all things Microslop, this may disappear if I deem it too much effort to keep around. That said, here is a mode to use when working with Powershell (the slowest shell known to mankind).
#+begin_src emacs-lisp
- (elpaca powershell)
+ (elpaca 'powershell)
#+end_src
* Tramp
We all love tramp. Tramp is great.
diff --git a/init.el b/init.el
@@ -41,14 +41,19 @@
;; End elpaca bootstrap
;; Installing the latest Org package so that we have live LaTeX previews:
-(elpaca (org :repo "https://code.tecosaur.net/tec/org-mode" :branch "dev"))
+(elpaca '(org :repo "https://code.tecosaur.net/tec/org-mode" :branch "dev"))
;; The main literate Emacs config is stored in config.org:
-(setq ethandl/config-fname (expand-file-name "config.org" user-emacs-directory))
+(defvar ethandl/config-fname
+ (expand-file-name "config.org" user-emacs-directory)
+ "Fully qualified filename of the literate org config for
+Emacs")
;; We will also generate platform-specific files in platform-config
-(setq ethandl/platform-config-dir
- (expand-file-name "platform-config/" user-emacs-directory))
+(defvar ethandl/platform-config-dir
+ (expand-file-name "platform-config/" user-emacs-directory)
+ "Fully qualified path for platform-specific config files")
+
;; Ensuring we have this folder created
(unless (file-directory-p ethandl/platform-config-dir)
(make-directory ethandl/platform-config-dir t))
@@ -69,7 +74,10 @@
(when (file-readable-p ethandl/config-fname)
(org-babel-load-file ethandl/config-fname))
-;; Custom.el file for storing automatically generated emacs vars:
-(setq ethandl/custom-file (expand-file-name "custom.el" user-emacs-directory))
+(defvar ethandl/custom-file
+ (expand-file-name "custom.el" user-emacs-directory)
+ "The filename for the custom file that stores Emacs'
+automaticaly generated vars")
+
(setq custom-file ethandl/custom-file)
(load custom-file)