Compare commits
2 Commits
9357cbb0fe
...
d405304d86
Author | SHA1 | Date |
---|---|---|
TEC | d405304d86 | |
TEC | 44e3a693da |
21
config.org
21
config.org
|
@ -4279,12 +4279,21 @@ too. We could just not save it, but it seems nice to get the count information.
|
|||
(defvar autocorrect-abbrev-table--saved-version 0
|
||||
"The version of `autocorrect-abbrev-table' saved to disk.")
|
||||
|
||||
(declare-function math-next-small-prime "calc-comb")
|
||||
|
||||
(defun autocorrect--setup-abbrevs ()
|
||||
"Setup `autocorrect-abbrev-table'.
|
||||
Also set it as a parent of `global-abbrev-table'."
|
||||
(unless autocorrect-abbrev-table
|
||||
(setq autocorrect-abbrev-table
|
||||
(make-abbrev-table (list :enable-function #'autocorrect--appropriate-p)))
|
||||
(let ((obarray-default-size
|
||||
(if (>= emacs-major-version 30)
|
||||
4 ; In Emacs 30+ obarrays will dynamically grow.
|
||||
(require 'calc-comb)
|
||||
(math-next-small-prime
|
||||
(+ (hash-table-size autocorrect-record-table) 50)))))
|
||||
(setq autocorrect-abbrev-table
|
||||
(make-abbrev-table
|
||||
(list :enable-function #'autocorrect--appropriate-p))))
|
||||
(abbrev-table-put
|
||||
global-abbrev-table :parents
|
||||
(cons autocorrect-abbrev-table
|
||||
|
@ -4310,7 +4319,7 @@ Also set it as a parent of `global-abbrev-table'."
|
|||
(setq coding-system-for-write 'utf-8-emacs))
|
||||
(goto-char (point-min))
|
||||
(insert (format ";;-*-coding: %s;-*-\n\n" coding-system-for-write))
|
||||
(write-region nil nil autocorrect-abbrev-file 0)))
|
||||
(write-region nil nil autocorrect-abbrev-file)))
|
||||
(setq autocorrect-abbrev-table--saved-version
|
||||
(abbrev-table-get autocorrect-abbrev-table
|
||||
:abbrev-table-modiff))))
|
||||
|
@ -4409,12 +4418,14 @@ split the actual reading and the abbrev generation into two parts though.
|
|||
"Ensure that all entries of the abbrev table are valid."
|
||||
(obarray-map
|
||||
(lambda (misspelling)
|
||||
(when (stringp misspelling) ; Abbrev's obarrays start with a symbol
|
||||
(setq misspelling (symbol-name misspelling))
|
||||
(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)))))
|
||||
(define-abbrev autocorrect-abbrev-table misspelling nil)
|
||||
(unintern misspelling autocorrect-abbrev-table)))))
|
||||
autocorrect-abbrev-table))
|
||||
|
||||
(defun autocorrect--create-history-abbrevs ()
|
||||
|
|
Loading…
Reference in New Issue