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

@@ -33,35 +33,57 @@ let
fontPackages = [
pkgs.julia-mono
pkgs.nerd-fonts.victor-mono
# pkgs.overpass
pkgs.ibm-plex
];
emacsWrapper = pkgs.symlinkJoin {
name = "emacs-wrapper";
paths = [ emacsPackage ];
nativeBuildInputs = [ pkgs.makeWrapper ];
buildInputs = [
pkgs.git # Dependency of Straight.el.
];
postBuild = ''
# The binary called `emacs` is actually a symlink to `emacs-«version»`, so
# we needn't wrap it.
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"
done
'';
};
my-aspell = pkgs.aspellWithDicts
(dicts: with dicts; [
en en-computers en-science
]);
emacsWrapper =
pkgs.symlinkJoin {
name = "emacs-wrapper";
paths = [ emacsPackage ];
nativeBuildInputs = [ pkgs.makeWrapper ];
buildInputs = [
pkgs.git # Dependency of Straight.el.
my-aspell
];
postBuild = ''
# The binary called `emacs` is actually a symlink to `emacs-«version»`, so
# we needn't wrap it.
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 --alternate-editor=${emacsWrapper}/bin/emacs "$@"
'';
in {
programs.emacs = {
enable = true;
package = emacsWrapper;
extraPackages = epkgs: [
epkgs.jinx
];
};
sydnix.impermanence.cache.directories =
# Impermanence expects the path to be relative to ~.
map (lib.removePrefix config.home.homeDirectory) [
@@ -89,7 +111,7 @@ in {
};
home.packages = [
emacsWrapper
# emacsWrapper
emacsclient-or-emacs
] ++ fontPackages;

View File

@@ -10,7 +10,9 @@
`(("Kagi" . "https://kagi.com/search?q=%s")
("DuckDuckGo" . "https://duckduckgo.com/?q=%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
`syd-lookup-online-documentation' may delegate to.

View File

@@ -1,5 +1,7 @@
;;; 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
:defer t)
@@ -11,12 +13,35 @@
"Sets the buffer-local value for `visual-fill-column-center-text'."
(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
(list #'syd-prose-set-visual-fill-column-center
#'visual-fill-column-mode
#'visual-line-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'.")
;;;###autoload

View File

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