summary refs log tree commit diff stats
path: root/lisp/+ispell.el
diff options
context:
space:
mode:
authorCase Duckworth2022-01-27 19:26:33 -0600
committerCase Duckworth2022-01-27 19:26:33 -0600
commit1e5c351253784ca3bd05c9e0db1e9dc53ab9a1e1 (patch)
tree20802d017c3e25dd9c39ee2eb3c24b789f2afbc9 /lisp/+ispell.el
parentAdd bmp to images (diff)
downloademacs-1e5c351253784ca3bd05c9e0db1e9dc53ab9a1e1.tar.gz
emacs-1e5c351253784ca3bd05c9e0db1e9dc53ab9a1e1.zip
Whose birthday is it?
Diffstat (limited to 'lisp/+ispell.el')
-rw-r--r--lisp/+ispell.el34
1 files changed, 22 insertions, 12 deletions
diff --git a/lisp/+ispell.el b/lisp/+ispell.el index e35b2f1..c3ee417 100644 --- a/lisp/+ispell.el +++ b/lisp/+ispell.el
@@ -49,26 +49,31 @@ before the LISTS."
49 (push string words)))))) 49 (push string words))))))
50 words)) 50 words))
51 51
52(defun +ispell-move-buffer-words-to-dir-locals () 52;;;###autoload
53 (interactive) 53(defun +ispell-move-buffer-words-to-dir-locals (&optional arg)
54 "Move the current buffer-local words to .dir-locals.el.
55This function prompts the user to save .dir-locals.el, unless
56prefix ARG is non-nil; then it just saves them."
57 (interactive "P")
54 (unless (buffer-file-name) 58 (unless (buffer-file-name)
55 (user-error "Buffer not attached to file")) 59 (user-error "Buffer not attached to file"))
56 (hack-dir-local-variables) 60 (hack-dir-local-variables)
57 (let ((words (+ispell-buffer-local-words-list)) 61 (when-let ((new-words (+ispell-append-removing-duplicates
58 (dir-local-words (+ispell-append-removing-duplicates 62 :test #'string=
59 (alist-get 'ispell-buffer-session-localwords 63 ispell-buffer-session-localwords
60 dir-local-variables-alist) 64 (alist-get 'ispell-buffer-session-localwords
61 (alist-get 'ispell-buffer-session-localwords 65 dir-local-variables-alist)
62 file-local-variables-alist)))) 66 (alist-get 'ispell-buffer-session-localwords
67 file-local-variables-alist)
68 (+ispell-buffer-local-words-list))))
63 (save-excursion 69 (save-excursion
64 (add-dir-local-variable 70 (add-dir-local-variable
65 major-mode 71 major-mode
66 'ispell-buffer-session-localwords 72 'ispell-buffer-session-localwords
67 (setq ispell-buffer-session-localwords 73 (setq ispell-buffer-session-localwords
68 (+ispell-append-removing-duplicates 74 new-words))
69 :test #'string= 75 (when (or arg
70 dir-local-words ispell-buffer-session-localwords words))) 76 (y-or-n-p "Save .dir-locals.el?"))
71 (when (y-or-n-p "Save .dir-locals.el?")
72 (save-buffer)) 77 (save-buffer))
73 (bury-buffer)) 78 (bury-buffer))
74 (or ispell-buffer-local-name 79 (or ispell-buffer-local-name
@@ -78,5 +83,10 @@ before the LISTS."
78 (while (search-forward ispell-words-keyword nil t) 83 (while (search-forward ispell-words-keyword nil t)
79 (delete-region (point-at-bol) (1+ (point-at-eol))))))) 84 (delete-region (point-at-bol) (1+ (point-at-eol)))))))
80 85
86;;;###autoload
87(defun +ispell-move-buffer-words-to-dir-locals-hook ()
88 "Convenience function for binding to a hook."
89 (+ispell-move-buffer-words-to-dir-locals t))
90
81(provide '+ispell) 91(provide '+ispell)
82;;; +ispell.el ends here 92;;; +ispell.el ends here