[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/guess-language 2792ac4 003/101: Guesses the language on
From: |
Stefan Monnier |
Subject: |
[elpa] externals/guess-language 2792ac4 003/101: Guesses the language only if flyspell is unhappy with what we |
Date: |
Sat, 23 Feb 2019 10:34:31 -0500 (EST) |
branch: externals/guess-language
commit 2792ac47e4b1aca4fc3671dc4bb43a4f5b2d1f4a
Author: Titus von der Malsburg <address@hidden>
Commit: Titus von der Malsburg <address@hidden>
Guesses the language only if flyspell is unhappy with what we
type.
No need to guess otherwise.
---
guess-language.el | 27 ++++++++++++++++++++-------
1 file changed, 20 insertions(+), 7 deletions(-)
diff --git a/guess-language.el b/guess-language.el
index 304a375..a920890 100644
--- a/guess-language.el
+++ b/guess-language.el
@@ -50,22 +50,21 @@
for lang in guess-language-regexps
for regexp = (cdr lang)
collect (cons (car lang) (how-many regexp beginning end)))))
- (print tally)
(car (--max-by (> (cdr it) (cdr other)) tally))))
(defun guess-language-buffer ()
(interactive)
- (print (guess-language (point-min) (point-max))))
+ (guess-language (point-min) (point-max)))
(defun guess-language-paragraph ()
(interactive)
(let ((beginning (save-excursion (backward-paragraph) (point)))
(end (save-excursion (forward-paragraph) (point))))
- (print (guess-language beginning end))))
+ (guess-language beginning end)))
(defun guess-language-region ()
(interactive)
- (print (guess-language (region-beginning) (region-end))))
+ (guess-language (region-beginning) (region-end)))
(defun guess-language-autoset ()
"Detects language of the current paragraph and sets things like
@@ -77,9 +76,23 @@ ispell dictionaries accordingly."
(typo-change-language "English")))
('de (progn
(ispell-change-dictionary "de")
- (typo-change-language "German"))))
- (flyspell-region (save-excursion (backward-paragraph) (point))
- (save-excursion (forward-paragraph) (point))))
+ (typo-change-language "German")))))
+
+(defun guess-language-autoset-and-spellcheck (beginning end doublon)
+ "Runs `guess-language-autoset' and then the flyspell on the
+current paragraph."
+ (let ((old-dictionary ispell-local-dictionary))
+ (guess-language-autoset)
+ (unless (string= old-dictionary ispell-local-dictionary)
+ (remove-hook 'flyspell-incorrect-hook
#'guess-language-autoset-and-spellcheck)
+ (flyspell-region (save-excursion (backward-paragraph) (point))
+ (save-excursion (forward-paragraph) (point)))
+ (add-hook 'flyspell-incorrect-hook
#'guess-language-autoset-and-spellcheck))))
+
+(add-hook 'flyspell-incorrect-hook #'guess-language-autoset-and-spellcheck)
+
+(setq flyspell-issue-welcome-flag nil)
+(setq flyspell-issue-message-flag nil)
(provide 'guess-language)
- [elpa] branch externals/guess-language created (now 1107b93), Stefan Monnier, 2019/02/23
- [elpa] externals/guess-language 43eb329 004/101: Fixed version number., Stefan Monnier, 2019/02/23
- [elpa] externals/guess-language 2792ac4 003/101: Guesses the language only if flyspell is unhappy with what we,
Stefan Monnier <=
- [elpa] externals/guess-language e4c103c 009/101: Compile regexps after load., Stefan Monnier, 2019/02/23
- [elpa] externals/guess-language e1db84e 006/101: Make this into a minor mode., Stefan Monnier, 2019/02/23
- [elpa] externals/guess-language 5261d2f 010/101: Make defcustoms., Stefan Monnier, 2019/02/23
- [elpa] externals/guess-language e6ffe8d 011/101: Added some documentation., Stefan Monnier, 2019/02/23
- [elpa] externals/guess-language 6ee7f77 005/101: Only guess when paragraph has some minimal length., Stefan Monnier, 2019/02/23
- [elpa] externals/guess-language 30e23aa 001/101: Added initial proof of concept., Stefan Monnier, 2019/02/23
- [elpa] externals/guess-language e13f5a9 013/101: (Re)compile regexps when necessary., Stefan Monnier, 2019/02/23
- [elpa] externals/guess-language 24213cb 032/101: Added some data for testing., Stefan Monnier, 2019/02/23
- [elpa] externals/guess-language 9b1048f 026/101: More idiomatic way to do local hooks., Stefan Monnier, 2019/02/23
- [elpa] externals/guess-language 38d7ab1 017/101: README: minor fixes, Stefan Monnier, 2019/02/23