;;; Saves and reloads the current per-session ispell word list ;;; Last edited on 2025-07-23 21:01:05 by stolfi (defun stolfi-ispell-save-buffer-dict (arg) "Writes the current per-buffer accepted word list to a file '{fname}.dict' [stolfi]" (interactive "P") (let* ( ( fname (buffer-file-name) ) ( dname (concat fname ".dict") ) ( words ispell-buffer-session-localwords ) ) (message "%d words" (length words)) (with-temp-file dname (dolist (w words) (insert w "\n")) ) ) ) (defun stolfi-ispell-load-buffer-dict (arg) "Loads the current per-buffer accepted word list from a file '{fname}.dict'. If {arg} is not {nil}, asks for the dictionary's file name. [stolfi]" (interactive "P") (let* ( ( cur-words ispell-buffer-session-localwords) ( dname (stolfi-ispell-get-dict-name arg) ) ( dict-txt (with-temp-buffer (insert-file-contents dname) (buffer-substring-no-properties (point-min) (point-max) ) ) ) ( new-words (split-string dict-txt "[ ]*[\n]" t)) ) (message "%d words read" (length new-words)) (setq ispell-buffer-session-localwords (seq-uniq (append cur-words new-words)) ) (message "%d total words " (length ispell-buffer-session-localwords) ) ) ) (defun stolfi-ispell-get-dict-name (arg) "If {arg} is {nil}, returns the current buffer's file name with '.dict' appended. If {arg} i s not {nil}, asks for a file name. [stolfi]" (if (null arg) (let* ( ( fname (buffer-file-name) ) ) (concat fname ".dict") ) (read-file-name "dictionary file:") ) )