[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/auto-correct 0d38425 10/11: auto-correct: Add support f
From: |
Stefan Monnier |
Subject: |
[elpa] externals/auto-correct 0d38425 10/11: auto-correct: Add support for flyspell-correct-word-* |
Date: |
Tue, 1 Dec 2020 15:17:29 -0500 (EST) |
branch: externals/auto-correct
commit 0d38425fad4cd96714c07cfa66983b20764ff518
Author: Ian Dunn <dunni@gnu.org>
Commit: Ian Dunn <dunni@gnu.org>
auto-correct: Add support for flyspell-correct-word-*
* auto-correct.el (auto-correct--flyspell-old-word): New variable.
(auto-correct--flyspell-do-correct-wrapper): Wrapper for
flyspell-do-correct.
(auto-correct-flyspell-insert): Use the new variable.
(auto-correct--activate-flyspell-support): Advise flyspell-do-correct.
---
auto-correct.el | 29 +++++++++++++++++++++++------
1 file changed, 23 insertions(+), 6 deletions(-)
diff --git a/auto-correct.el b/auto-correct.el
index 39c224d..528dad2 100644
--- a/auto-correct.el
+++ b/auto-correct.el
@@ -5,7 +5,7 @@
;; Author: Ian Dunn <dunni@gnu.org>
;; Maintainer: Ian Dunn <dunni@gnu.org>
;; Keywords: editing
-;; Version: 1.1.3
+;; Version: 1.1.4
;; This file is part of GNU Emacs.
@@ -204,19 +204,32 @@ indicating whether to activate or deactivate support."
;; Flyspell Support
+(defvar-local auto-correct--flyspell-old-word nil)
+
(defvar flyspell-auto-correct-word)
(defvar flyspell-use-global-abbrev-table-p)
(defvar flyspell-insert-function)
+(defun auto-correct--flyspell-do-correct-wrapper (oldfun replace poss word
cursor-location start end save)
+ "Wraps `flyspell-do-correct' to store the word it's correcting."
+ (let ((auto-correct--flyspell-old-word word))
+ (funcall oldfun replace poss word cursor-location start end save)))
+
(defun auto-correct-flyspell-insert (word)
"Insert WORD and add it as a correction.
The original (misspelled) word is drawn from the variable
-`flyspell-auto-correct-word'.
+`flyspell-auto-correct-word' (if coming from
+`flyspell-auto-correct-word') or `auto-correct--flyspell-old-word'
+if coming from `flyspell-do-correct'.
When `auto-correct-mode' is enabled, this function is set as
`flyspell-insert-function'."
- (let ((old-word flyspell-auto-correct-word)
+ ;; If coming from `flyspell-auto-correct-word' (the function), use
+ ;; `flyspell-auto-correct-word' (the variable) for the old word. Otherwise,
+ ;; we're coming from `flyspell-do-correct', so use our stored old word.
+ (let ((old-word (or flyspell-auto-correct-word
+ auto-correct--flyspell-old-word))
(new-word word)
(local (not flyspell-use-global-abbrev-table-p)))
(auto-correct--add-or-update-correction old-word new-word local)))
@@ -230,9 +243,13 @@ Otherwise, deactivate it.
Activation means adding `auto-correct-flyspell-insert' to
`flyspell-insert-function'."
(if activate
- (add-function :before flyspell-insert-function
- #'auto-correct-flyspell-insert)
- (remove-function flyspell-insert-function #'auto-correct-flyspell-insert)))
+ (progn
+ (advice-add 'flyspell-do-correct :around
+ #'auto-correct--flyspell-do-correct-wrapper)
+ (add-function :before flyspell-insert-function
+ #'auto-correct-flyspell-insert))
+ (remove-function flyspell-insert-function #'auto-correct-flyspell-insert)
+ (advice-remove 'flyspell-do-correct
#'auto-correct--flyspell-do-correct-wrapper)))
;; Silence the byte-compiler; this will be enabled shortly
(defvar auto-correct-enable-flyspell-support)
- [elpa] branch externals/auto-correct created (now 3ab1d23), Stefan Monnier, 2020/12/01
- [elpa] externals/auto-correct 9147742 01/11: Added auto-correct package, Stefan Monnier, 2020/12/01
- [elpa] externals/auto-correct 80fe805 03/11: auto-correct.el: Changed default predicate to enable auto-correct, Stefan Monnier, 2020/12/01
- [elpa] externals/auto-correct 3e4d699 02/11: auto-correct.el: Cleaned up support activation/deactivation, Stefan Monnier, 2020/12/01
- [elpa] externals/auto-correct fb9950c 07/11: auto-correct: Fixed handle-support bug and bumped version, Stefan Monnier, 2020/12/01
- [elpa] externals/auto-correct 0d38425 10/11: auto-correct: Add support for flyspell-correct-word-*,
Stefan Monnier <=
- [elpa] externals/auto-correct 3ab1d23 11/11: * .gitignore: New file, Stefan Monnier, 2020/12/01
- [elpa] externals/auto-correct 0be9302 06/11: auto-correct: Bumped version to 1.1.1, Stefan Monnier, 2020/12/01
- [elpa] externals/auto-correct f9c542b 08/11: auto-correct: Defer loading of flyspell support until after flyspell has been enabled, Stefan Monnier, 2020/12/01
- [elpa] externals/auto-correct 27a2323 04/11: auto-correct.el: Reverted last commit, Stefan Monnier, 2020/12/01
- [elpa] externals/auto-correct 84101c5 05/11: auto-correct: Changed default predicate to a function and added examples, Stefan Monnier, 2020/12/01
- [elpa] externals/auto-correct 12955c8 09/11: Updated copyright on auto-correct, captain, and vigenere, Stefan Monnier, 2020/12/01