feat(emacs): Spell-checking

- Uses Aspell and Jinx.
This commit is contained in:
Madeleine Sydney
2025-02-17 21:36:30 -07:00
parent 12caaa6097
commit e730599357
5 changed files with 89 additions and 36 deletions

View File

@@ -41,7 +41,7 @@ Where =configuration.nix= is the main entry point imported by the top-level flak
*** =users/= *** =users/=
Similarly to the =hosts= directory, each subdirectory =users/«USER»= is assumed to have some structure, and that =«USER»= is the precise username desired. Similarly to the =hosts= directory, each sub-directory =users/«USER»= is assumed to have some structure, and that =«USER»= is the precise username desired.
#+begin_example #+begin_example
users users
@@ -153,11 +153,11 @@ As with the rest of the config, these are largely adapted from Doom's ([cite:@li
* Hosts * Hosts
** nixos-testbed ** =nixos-testbed=
Configuration for the VM I'm currently using as a testbed, before moving to my real desktop. Configuration for the VM I'm currently using as a test-bed, before moving to my real desktop.
** deertopia ** =deertopia=
My home server. My home server.
@@ -302,9 +302,9 @@ CLOSED: [2025-01-16 Thu 18:19]
*** TODO Prose minor mode *** TODO Prose minor mode
**** TODO Grammar-checking **** HOLD Grammar-checking
**** TODO Spell-checking **** DONE Spell-checking
*** DONE Lookup handlers *** DONE Lookup handlers
CLOSED: [2025-02-01 Sat 16:56] CLOSED: [2025-02-01 Sat 16:56]
@@ -407,7 +407,7 @@ CLOSED: [2024-11-14 Thu 04:46]
**** grammar **** grammar
**** spellcheck and dictionaries **** DONE spellcheck and dictionaries
**** org-mode **** org-mode
@@ -533,7 +533,7 @@ CLOSED: [2024-12-29 Sun 01:41]
** DONE git config ** DONE git config
CLOSED: [2024-12-30 Mon 17:01] CLOSED: [2024-12-30 Mon 17:01]
** TODO niri ** TODO Niri
Or Qtile Or Qtile
@@ -639,9 +639,9 @@ List persistent files per user, and show their mount strategy.
Following is a subset of the many places I've learnt from. Most important of all are Doom Emacs and Faye's Wishsys. Following is a subset of the many places I've learnt from. Most important of all are Doom Emacs and Faye's Wishsys.
Doom Emacs was my gateway drug to Emacs, as well as continually supportive parent as I've begun to move out — of course, that's a flowerism obfuscating the more direct statement "I've stolen a great deal of their code" }:). Doom Emacs was my gateway drug to Emacs, as well as a continually supportive parent as I've begun to move out — of course, that's a flowerism obfuscating the more direct statement "I've stolen a great deal of their code" }:).
The beloved Faye's Wishsys is an incredibly impressive 3-kloc NixOS config with several hosts, users, and a beautiful level of modularity. Her system has a number of quirks that initially raise eyebrows, but the questioning turns to awe once you understand she really knows what she's doing }:). Faye and her config are entirely responsible for inspiring and motivating my effort expent here, as well as being a wonderful reference as I re-learnt Nix from the ground up. In the most nerdy moment of my life, I've genuinely /swooned/ over this damn config. The beloved Faye's Wishsys is an incredibly impressive 3-kloc NixOS config with several hosts, users, and a beautiful level of modularity. Her system has a number of quirks that initially raise eyebrows, but the questioning turns to awe once you understand she really knows what she's doing }:). Faye and her config are entirely responsible for inspiring and motivating my effort expended here, as well as being a wonderful reference as I re-learnt Nix from the ground up. In the most nerdy moment of my life, I've genuinely /swooned/ over this damn config.
- My darling dearest Faye's =wishsys= }:D - My darling dearest Faye's =wishsys= }:D
- [[https://github.com/rasendubi/dotfiles][rasendubi/dotfiles]] - [[https://github.com/rasendubi/dotfiles][rasendubi/dotfiles]]
@@ -663,3 +663,7 @@ The beloved Faye's Wishsys is an incredibly impressive 3-kloc NixOS config with
- [[https://github.com/noctuid/evil-guide][noctuid/evil-guide]] - [[https://github.com/noctuid/evil-guide][noctuid/evil-guide]]
- [[https://github.com/drym-org/symex.el][symex.el]] - [[https://github.com/drym-org/symex.el][symex.el]]
- [[https://github.com/Fuco1/smartparens][Smartparens]] - [[https://github.com/Fuco1/smartparens][Smartparens]]
# Local Variables:
# jinx-local-words: "Wishsys"
# End:

View File

@@ -33,35 +33,57 @@ let
fontPackages = [ fontPackages = [
pkgs.julia-mono pkgs.julia-mono
pkgs.nerd-fonts.victor-mono pkgs.nerd-fonts.victor-mono
# pkgs.overpass
pkgs.ibm-plex pkgs.ibm-plex
]; ];
emacsWrapper = pkgs.symlinkJoin { my-aspell = pkgs.aspellWithDicts
name = "emacs-wrapper"; (dicts: with dicts; [
paths = [ emacsPackage ]; en en-computers en-science
nativeBuildInputs = [ pkgs.makeWrapper ]; ]);
buildInputs = [
pkgs.git # Dependency of Straight.el. emacsWrapper =
]; pkgs.symlinkJoin {
postBuild = '' name = "emacs-wrapper";
# The binary called `emacs` is actually a symlink to `emacs-«version»`, so paths = [ emacsPackage ];
# we needn't wrap it. nativeBuildInputs = [ pkgs.makeWrapper ];
for i in $out/bin/emacs-*; do buildInputs = [
wrapProgram "$i" \ pkgs.git # Dependency of Straight.el.
--add-flags "--init-directory \"${emacsConfigDir}\"" \ my-aspell
--set EMACS_STRAIGHT_BASE_DIR "${straightBaseDir}" \ ];
--set EMACS_CACHE_DIR "${emacsCacheDir}" \ postBuild = ''
--set EMACS_DATA_DIR "${emacsDataDir}" \ # The binary called `emacs` is actually a symlink to `emacs-«version»`, so
--prefix PATH : "${pkgs.git}/bin" # we needn't wrap it.
done for i in $out/bin/emacs-*; do
''; wrapProgram "$i" \
}; --add-flags "--init-directory \"${emacsConfigDir}\"" \
--set EMACS_STRAIGHT_BASE_DIR "${straightBaseDir}" \
--set EMACS_CACHE_DIR "${emacsCacheDir}" \
--set EMACS_DATA_DIR "${emacsDataDir}" \
--prefix PATH : "${pkgs.git}/bin" \
--prefix PATH : "${my-aspell}/bin" \
--set ASPELL_CONF "dict-dir ${my-aspell}/lib/aspell"
done
# HACK: Prevent collision between `emacsWrapper` and the later
# `emacsWithPackages` call.
# find $out/bin -not -regex '.*/\.?emacs[^/]*' -exec rm {} \;
'';
meta = emacsPackage.meta;
version = emacsPackage.version;
};
emacsclient-or-emacs = pkgs.writeShellScriptBin "emacsclient-or-emacs" '' emacsclient-or-emacs = pkgs.writeShellScriptBin "emacsclient-or-emacs" ''
emacsclient --alternate-editor=${emacsWrapper}/bin/emacs "$@" emacsclient --alternate-editor=${emacsWrapper}/bin/emacs "$@"
''; '';
in { in {
programs.emacs = {
enable = true;
package = emacsWrapper;
extraPackages = epkgs: [
epkgs.jinx
];
};
sydnix.impermanence.cache.directories = sydnix.impermanence.cache.directories =
# Impermanence expects the path to be relative to ~. # Impermanence expects the path to be relative to ~.
map (lib.removePrefix config.home.homeDirectory) [ map (lib.removePrefix config.home.homeDirectory) [
@@ -89,7 +111,7 @@ in {
}; };
home.packages = [ home.packages = [
emacsWrapper # emacsWrapper
emacsclient-or-emacs emacsclient-or-emacs
] ++ fontPackages; ] ++ fontPackages;

View File

@@ -10,7 +10,9 @@
`(("Kagi" . "https://kagi.com/search?q=%s") `(("Kagi" . "https://kagi.com/search?q=%s")
("DuckDuckGo" . "https://duckduckgo.com/?q=%s") ("DuckDuckGo" . "https://duckduckgo.com/?q=%s")
("Nixpkgs" . "https://search.nixos.org/packages?query=%s") ("Nixpkgs" . "https://search.nixos.org/packages?query=%s")
("Hackage" . "https://hackage.haskell.org/packages/search?terms=%s")) ("Hackage" . "https://hackage.haskell.org/packages/search?terms=%s")
("The Free Dictionary" . "https://www.thefreedictionary.com/%s")
("The Free Thesaurus" . "https://www.freethesaurus.com/%s"))
"A list of pairs (NAME . BACKEND) describing the various backends "A list of pairs (NAME . BACKEND) describing the various backends
`syd-lookup-online-documentation' may delegate to. `syd-lookup-online-documentation' may delegate to.

View File

@@ -1,5 +1,7 @@
;;; syd-prose.el -*- lexical-binding: t; -*- ;;; syd-prose.el -*- lexical-binding: t; -*-
;; Soft-wrap text to not the window edge, but a constant width. Also allows for
;; centering buffer text.
(use-package visual-fill-column (use-package visual-fill-column
:defer t) :defer t)
@@ -11,12 +13,35 @@
"Sets the buffer-local value for `visual-fill-column-center-text'." "Sets the buffer-local value for `visual-fill-column-center-text'."
(setq-local visual-fill-column-center-text t)) (setq-local visual-fill-column-center-text t))
;; Jinx is a fast just-in-time spell-checker for Emacs. Jinx highlights
;; misspelled words in the text of the visible portion of the buffer. For
;; efficiency, Jinx highlights misspellings lazily, recognizes window boundaries
;; and text folding, if any. For example, when unfolding or scrolling, only the
;; newly visible part of the text is checked if it has not been checked
;; before. Each misspelling can be corrected from a list of dictionary words
;; presented as a completion menu.
(use-package jinx
;; Managed by Nix.
:straight nil
:commands (jinx-mode jinx-correct jinx-correct-word)
:init (defun syd-jinx--jinx-or-ispell ()
(interactive)
(if (bound-and-true-p jinx-mode)
(call-interactively #'jinx-correct-word)
(call-interactively #'ispell-word)))
:general (:states '(normal visual)
"z =" #'syd-jinx--jinx-or-ispell)
:config
;; Default is "en_US"; fuck that!
(jinx-languages "en" t))
(defvar syd-prose-mode-hook (defvar syd-prose-mode-hook
(list #'syd-prose-set-visual-fill-column-center (list #'syd-prose-set-visual-fill-column-center
#'visual-fill-column-mode #'visual-fill-column-mode
#'visual-line-mode #'visual-line-mode
#'variable-pitch-mode #'variable-pitch-mode
#'syd-prose-disable-display-line-numbers-mode-h) #'syd-prose-disable-display-line-numbers-mode-h
#'jinx-mode)
"Hooks run for `syd-prose-mode'.") "Hooks run for `syd-prose-mode'.")
;;;###autoload ;;;###autoload

View File

@@ -77,12 +77,12 @@ See https://lists.gnu.org/archive/html/emacs-orgmode/2019-07/msg00081.html."
(let* ((hl `(:weight bold)) (let* ((hl `(:weight bold))
(fg (lambda (c) `(:foreground ,(syd-kanagawa-get c)))) (fg (lambda (c) `(:foreground ,(syd-kanagawa-get c))))
(bg (lambda (c) `(:background ,(syd-kanagawa-get c)))) (bg (lambda (c) `(:background ,(syd-kanagawa-get c))))
(block-delim `(:foreground nil (block-delim `(:foreground unspecified
:inherit font-lock-comment-face :inherit font-lock-comment-face
:extend t :extend t
,@(funcall bg 'sumi-ink-0) ,@(funcall bg 'sumi-ink-0)
:height 0.75)) :height 0.75))
(keyword '(:background nil :foreground nil (keyword '(:background unspecified :foreground unspecified
:inherit (fixed-pitch font-lock-comment-face) :inherit (fixed-pitch font-lock-comment-face)
:height 0.9))) :height 0.9)))
(setq org-src-block-faces (setq org-src-block-faces