aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/textmodes/flyspell.el56
1 files changed, 26 insertions, 30 deletions
diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el
index a7ea86d8fa1..2ec1e0e3833 100644
--- a/lisp/textmodes/flyspell.el
+++ b/lisp/textmodes/flyspell.el
@@ -2018,7 +2018,7 @@ The word checked is the word at the mouse position."
2018 menu)))) 2018 menu))))
2019 2019
2020;*---------------------------------------------------------------------*/ 2020;*---------------------------------------------------------------------*/
2021;* Some example functions for real autocrrecting xb */ 2021;* Some example functions for real autocrrecting */
2022;*---------------------------------------------------------------------*/ 2022;*---------------------------------------------------------------------*/
2023(defun flyspell-maybe-correct-transposition (beg end poss) 2023(defun flyspell-maybe-correct-transposition (beg end poss)
2024 "Apply 'transpose-chars' to all points in the region BEG to END. 2024 "Apply 'transpose-chars' to all points in the region BEG to END.
@@ -2026,24 +2026,17 @@ Return t if any those result in a possible replacement suggested by Ispell
2026in POSS. Otherwise the change is undone. 2026in POSS. Otherwise the change is undone.
2027 2027
2028This function is meant to be added to 'flyspell-incorrect-hook'." 2028This function is meant to be added to 'flyspell-incorrect-hook'."
2029 (when (consp poss) 2029 (when (consp poss)
2030 (catch 'done 2030 (catch 'done
2031 (let ((str (buffer-substring beg end)) 2031 (save-excursion
2032 (i 0) (len (- end beg)) tmp) 2032 (goto-char (1+ beg))
2033 (while (< (1+ i) len) 2033 (while (< (point) end)
2034 (setq tmp (aref str i)) 2034 (transpose-chars 1)
2035 (aset str i (aref str (1+ i))) 2035 (when (member (buffer-substring beg end) (nth 2 poss))
2036 (aset str (1+ i) tmp) 2036 (throw 'done t))
2037 (when (member str (nth 2 poss)) 2037 (transpose-chars -1)
2038 (save-excursion 2038 (forward-char))
2039 (goto-char (+ beg i 1)) 2039 nil))))
2040 (transpose-chars 1))
2041 (throw 'done t))
2042 (setq tmp (aref str i))
2043 (aset str i (aref str (1+ i)))
2044 (aset str (1+ i) tmp)
2045 (setq i (1+ i))))
2046 nil)))
2047 2040
2048(defun flyspell-maybe-correct-doubling (beg end poss) 2041(defun flyspell-maybe-correct-doubling (beg end poss)
2049 "For each doubled charachter in the region BEG to END, remove one. 2042 "For each doubled charachter in the region BEG to END, remove one.
@@ -2053,18 +2046,21 @@ Ispell in POSS. Otherwise the change is undone.
2053This function is meant to be added to 'flyspell-incorrect-hook'." 2046This function is meant to be added to 'flyspell-incorrect-hook'."
2054 (when (consp poss) 2047 (when (consp poss)
2055 (catch 'done 2048 (catch 'done
2056 (let ((str (buffer-substring beg end)) 2049 (save-excursion
2057 (i 0) (len (- end beg))) 2050 (let ((last (char-after beg))
2058 (while (< (1+ i) len) 2051 this)
2059 (when (and (= (aref str i) (aref str (1+ i))) 2052 (goto-char (1+ beg))
2060 (member (concat (substring str 0 (1+ i)) 2053 (while (< (point) end)
2061 (substring str (+ i 2))) 2054 (setq this (char-after))
2062 (nth 2 poss))) 2055 (if (not (char-equal this last))
2063 (goto-char (+ beg i)) 2056 (forward-char)
2064 (delete-char 1) 2057 (delete-char 1)
2065 (throw 'done t)) 2058 (when (member (buffer-substring beg (1- end)) (nth 2 poss))
2066 (setq i (1+ i)))) 2059 (throw 'done t))
2067 nil))) 2060 ;; undo
2061 (insert-char this 1))
2062 (setq last this))
2063 nil)))))
2068 2064
2069;*---------------------------------------------------------------------*/ 2065;*---------------------------------------------------------------------*/
2070;* flyspell-already-abbrevp ... */ 2066;* flyspell-already-abbrevp ... */