Fix removal of autocorrect abbrevs

This commit is contained in:
TEC 2024-03-27 01:05:14 +08:00
parent 44e3a693da
commit 755020d591
Signed by: tec
SSH Key Fingerprint: SHA256:eobz41Mnm0/iYWBvWThftS0ElEs1ftBr6jamutnXc/A
1 changed files with 9 additions and 7 deletions

View File

@ -4408,13 +4408,15 @@ split the actual reading and the abbrev generation into two parts though.
(defun autocorrect--remove-invalid-abbrevs ()
"Ensure that all entries of the abbrev table are valid."
(obarray-map
(lambda (misspelling)
(when (stringp misspelling) ; Abbrev's obarrays start with a symbol
(let ((corrections (gethash misspelling autocorrect-record-table)))
(unless (and (= (length corrections) 1)
(>= (cdar corrections)
autocorrect-count-threshold-history))
(define-abbrev autocorrect-abbrev-table misspelling nil)))))
(lambda (misspelling-symb)
(let ((misspelling (symbol-name misspelling-symb)))
(unless (string-empty-p misspelling) ; Abbrev uses an empty symbol for metadata.
(let ((corrections (gethash misspelling autocorrect-record-table)))
(unless (and (= (length corrections) 1)
(>= (cdar corrections)
autocorrect-count-threshold-history))
(define-abbrev autocorrect-abbrev-table misspelling nil)
(unintern misspelling-symb autocorrect-abbrev-table))))))
autocorrect-abbrev-table))
(defun autocorrect--create-history-abbrevs ()