From a51be66d303ac1e0928282c2240947575f3355e8 Mon Sep 17 00:00:00 2001 From: Ian Wahbe Date: Sun, 6 Dec 2020 19:18:36 +0100 Subject: [PATCH] Add word existence checking for +spell/correct `(bounds-of-thing-at-point 'word)` can return `nil`. This checks that it does not, giving an `user-error` if no word is found. --- modules/checkers/spell/autoload/+spell-fu.el | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/checkers/spell/autoload/+spell-fu.el b/modules/checkers/spell/autoload/+spell-fu.el index 25a0a1063..a0ae0bbd1 100644 --- a/modules/checkers/spell/autoload/+spell-fu.el +++ b/modules/checkers/spell/autoload/+spell-fu.el @@ -64,8 +64,9 @@ (if (not (or (featurep! :completion ivy) (featurep! :completion helm))) (call-interactively #'ispell-word) - (cl-destructuring-bind (start . end) - (bounds-of-thing-at-point 'word) + (let ((current-point (bounds-of-thing-at-point 'word))) + (if current-point + (cl-destructuring-bind (start . end) current-point (let ((word (thing-at-point 'word t)) (orig-pt (point)) poss ispell-filter) @@ -106,7 +107,8 @@ (+spell--correct cmd poss wrd orig-pt start end) (unless (string-equal wrd word) (+spell--correct wrd poss word orig-pt start end)))))) - (ispell-pdict-save t))))))) + (ispell-pdict-save t))))) + (user-error "No word at point"))))) ;;;###autoload (defalias '+spell/add-word #'spell-fu-word-add) ;;;###autoload (defalias '+spell/remove-word #'spell-fu-word-remove)