comparison lisp/textmodes/flyspell.el @ 37006:2fa95954d8de

Backed out changes made by John Wiegley 2000-10-28.
author Gerd Moellmann <gerd@gnu.org>
date Mon, 26 Mar 2001 13:59:00 +0000
parents df30cce5ee20
children f4b355161455
comparison
equal deleted inserted replaced
37005:0dbe9e01a45d 37006:2fa95954d8de
2016 (popup-menu (cons (format "%s [%s]" word (or ispell-local-dictionary 2016 (popup-menu (cons (format "%s [%s]" word (or ispell-local-dictionary
2017 ispell-dictionary)) 2017 ispell-dictionary))
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.
2025 Return t if any those result in a possible replacement suggested by Ispell 2025 Return t if any those result in a possible replacement suggested by Ispell
2026 in POSS. Otherwise the change is undone. 2026 in POSS. Otherwise the change is undone.
2027 2027
2028 This function is meant to be added to 'flyspell-incorrect-hook'." 2028 This 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.
2050 Return t if any those result in a possible replacement suggested by 2043 Return t if any those result in a possible replacement suggested by
2051 Ispell in POSS. Otherwise the change is undone. 2044 Ispell in POSS. Otherwise the change is undone.
2052 2045
2053 This function is meant to be added to 'flyspell-incorrect-hook'." 2046 This 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 ... */
2071 ;*---------------------------------------------------------------------*/ 2067 ;*---------------------------------------------------------------------*/
2072 (defun flyspell-already-abbrevp (table word) 2068 (defun flyspell-already-abbrevp (table word)