emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/spell-fu 53bd2b24c6 81/86: Cleanup: add spell-fu--canonica


From: ELPA Syncer
Subject: [nongnu] elpa/spell-fu 53bd2b24c6 81/86: Cleanup: add spell-fu--canonicalize-word utility function
Date: Thu, 7 Jul 2022 12:03:45 -0400 (EDT)

branch: elpa/spell-fu
commit 53bd2b24c6a72af90b7d4313b5403fa52e010287
Author: Campbell Barton <ideasman42@gmail.com>
Commit: Campbell Barton <ideasman42@gmail.com>

    Cleanup: add spell-fu--canonicalize-word utility function
---
 spell-fu.el | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/spell-fu.el b/spell-fu.el
index 334254fa4e..10208ba902 100644
--- a/spell-fu.el
+++ b/spell-fu.el
@@ -160,6 +160,10 @@ Notes:
 ;; ---------------------------------------------------------------------------
 ;; Dictionary Utility Functions
 
+(defsubst spell-fu--canonicalize-word (word)
+  "Return lowercase UTF-8 encoded WORD."
+  (encode-coding-string (downcase word) 'utf-8))
+
 (defun spell-fu--default-dictionaries ()
   "Construct the default value of `spell-fu-dictionaries'."
   (nconc
@@ -209,7 +213,7 @@ already contain WORD."
   (let
     (
       (adding (eq action 'add))
-      (encoded-word (encode-coding-string (downcase word) 'utf-8)))
+      (encoded-word (spell-fu--canonicalize-word word)))
     (delq
       nil
       (mapcar
@@ -373,7 +377,7 @@ save some time by not spending time reading it back."
       (while (not (eobp))
         (let ((l (buffer-substring-no-properties (line-beginning-position) 
(line-end-position))))
           ;; Value of 't' is just for simplicity, it's no used except for 
check the item exists.
-          (puthash (encode-coding-string (downcase l) 'utf-8) t word-table)
+          (puthash (spell-fu--canonicalize-word l) t word-table)
           (forward-line 1))))
 
     ;; Write write it to a file.
@@ -473,7 +477,7 @@ Marking the spelling as incorrect using 
`spell-fu-incorrect-face' on failure.
 Argument POS-BEG the beginning position of WORD.
 Argument POS-END the end position of WORD."
   ;; Dictionary search.
-  (unless (spell-fu--check-word-in-dict-list (encode-coding-string (downcase 
word) 'utf-8))
+  (unless (spell-fu--check-word-in-dict-list (spell-fu--canonicalize-word 
word))
     ;; Ignore all uppercase words.
     (unless (equal word (upcase word))
       ;; Mark as incorrect otherwise.
@@ -962,7 +966,7 @@ Return t when the word has been added."
         "Add to dictionary: ")))
   (let ((word (spell-fu--word-at-point)))
     (if dict
-      (let ((encoded-word (encode-coding-string (downcase word) 'utf-8)))
+      (let ((encoded-word (spell-fu--canonicalize-word word)))
         (funcall (get dict 'add-word) encoded-word)
         (puthash encoded-word t (symbol-value dict))
         t)
@@ -980,7 +984,7 @@ Return t when the word has been removed."
         "Remove from dictionary: ")))
   (let ((word (spell-fu--word-at-point)))
     (if dict
-      (let ((encoded-word (encode-coding-string (downcase 
(spell-fu--word-at-point)) 'utf-8)))
+      (let ((encoded-word (spell-fu--canonicalize-word word)))
         (funcall (get dict 'remove-word) encoded-word)
         (remhash encoded-word (symbol-value dict))
         t)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]