summaryrefslogtreecommitdiff
path: root/lisp/textmodes/flyspell.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/textmodes/flyspell.el')
-rw-r--r--lisp/textmodes/flyspell.el40
1 files changed, 36 insertions, 4 deletions
diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el
index 23f4756f4a7..ebee4691e8c 100644
--- a/lisp/textmodes/flyspell.el
+++ b/lisp/textmodes/flyspell.el
@@ -992,7 +992,7 @@ Mostly we check word delimiters."
(flyspell-accept-buffer-local-defs)
(let* ((cursor-location (point))
(flyspell-word (flyspell-get-word following))
- start end poss word)
+ start end poss word ispell-filter)
(if (or (eq flyspell-word nil)
(and (fboundp flyspell-generic-check-word-predicate)
(not (funcall flyspell-generic-check-word-predicate))))
@@ -1050,7 +1050,12 @@ Mostly we check word delimiters."
(not (string= "" (car ispell-filter))))))
;; (ispell-send-string "!\n")
;; back to terse mode.
+ ;; Remove leading empty element
(setq ispell-filter (cdr ispell-filter))
+ ;; ispell process should return something after word is sent.
+ ;; Tag word as valid (i.e., skip) otherwise
+ (or ispell-filter
+ (setq ispell-filter '(*)))
(if (consp ispell-filter)
(setq poss (ispell-parse-output (car ispell-filter))))
(let ((res (cond ((eq poss t)
@@ -1455,6 +1460,22 @@ The buffer to mark them in is `flyspell-large-region-buffer'."
(while (re-search-forward regexp nil t)
(delete-region (match-beginning 0) (match-end 0)))))))))
+;;* ---------------------------------------------------------------
+;;* flyspell-check-region-doublons
+;;* ---------------------------------------------------------------
+(defun flyspell-check-region-doublons (beg end)
+ "Check for adjacent duplicated words (doublons) in the given region."
+ (save-excursion
+ (goto-char beg)
+ (flyspell-word) ; Make sure current word is checked
+ (backward-word 1)
+ (while (and (< (point) end)
+ (re-search-forward "\\b\\([^ \n\t]+\\)[ \n\t]+\\1\\b"
+ end 'move))
+ (flyspell-word)
+ (backward-word 1))
+ (flyspell-word)))
+
;;*---------------------------------------------------------------------*/
;;* flyspell-large-region ... */
;;*---------------------------------------------------------------------*/
@@ -1499,7 +1520,8 @@ The buffer to mark them in is `flyspell-large-region-buffer'."
(progn
(flyspell-process-localwords buffer)
(with-current-buffer curbuf
- (flyspell-delete-region-overlays beg end))
+ (flyspell-delete-region-overlays beg end)
+ (flyspell-check-region-doublons beg end))
(flyspell-external-point-words))
(error "Can't check region...")))))
@@ -1830,7 +1852,7 @@ This command proposes various successive corrections for the current word."
(let ((start (car (cdr word)))
(end (car (cdr (cdr word))))
(word (car word))
- poss)
+ poss ispell-filter)
(setq flyspell-auto-correct-word word)
;; now check spelling of word.
(ispell-send-string "%\n") ;put in verbose mode
@@ -1839,7 +1861,12 @@ This command proposes various successive corrections for the current word."
(while (progn
(accept-process-output ispell-process)
(not (string= "" (car ispell-filter)))))
+ ;; Remove leading empty element
(setq ispell-filter (cdr ispell-filter))
+ ;; ispell process should return something after word is sent.
+ ;; Tag word as valid (i.e., skip) otherwise
+ (or ispell-filter
+ (setq ispell-filter '(*)))
(if (consp ispell-filter)
(setq poss (ispell-parse-output (car ispell-filter))))
(cond
@@ -1980,7 +2007,7 @@ The word checked is the word at the mouse position."
(let ((start (car (cdr word)))
(end (car (cdr (cdr word))))
(word (car word))
- poss)
+ poss ispell-filter)
;; now check spelling of word.
(ispell-send-string "%\n") ;put in verbose mode
(ispell-send-string (concat "^" word "\n"))
@@ -1988,7 +2015,12 @@ The word checked is the word at the mouse position."
(while (progn
(accept-process-output ispell-process)
(not (string= "" (car ispell-filter)))))
+ ;; Remove leading empty element
(setq ispell-filter (cdr ispell-filter))
+ ;; ispell process should return something after word is sent.
+ ;; Tag word as valid (i.e., skip) otherwise
+ (or ispell-filter
+ (setq ispell-filter '(*)))
(if (consp ispell-filter)
(setq poss (ispell-parse-output (car ispell-filter))))
(cond