diff options
| author | Gerd Moellmann | 2001-03-26 16:31:20 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2001-03-26 16:31:20 +0000 |
| commit | 25f2ad0554730dd0b62ff2f255090d78d86583ea (patch) | |
| tree | dd881ab037991d6743a2e640ae3ed405af81909d | |
| parent | 72c04ce241cdef6fd5f3bb8ee3950c0b108d1fb9 (diff) | |
| download | emacs-25f2ad0554730dd0b62ff2f255090d78d86583ea.tar.gz emacs-25f2ad0554730dd0b62ff2f255090d78d86583ea.zip | |
Some doc fixes.
(flyspell-maybe-correct-transposition)
(flyspell-maybe-correct-doubling): Use a temporary buffer
| -rw-r--r-- | lisp/textmodes/flyspell.el | 102 |
1 files changed, 61 insertions, 41 deletions
diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el index 2ec1e0e3833..0498820b4fb 100644 --- a/lisp/textmodes/flyspell.el +++ b/lisp/textmodes/flyspell.el | |||
| @@ -47,7 +47,7 @@ | |||
| 47 | ;* Group ... */ | 47 | ;* Group ... */ |
| 48 | ;*---------------------------------------------------------------------*/ | 48 | ;*---------------------------------------------------------------------*/ |
| 49 | (defgroup flyspell nil | 49 | (defgroup flyspell nil |
| 50 | "Spellchecking on the fly." | 50 | "Spell checking on the fly." |
| 51 | :tag "FlySpell" | 51 | :tag "FlySpell" |
| 52 | :prefix "flyspell-" | 52 | :prefix "flyspell-" |
| 53 | :group 'processes) | 53 | :group 'processes) |
| @@ -148,9 +148,9 @@ command was not the very same command." | |||
| 148 | "*List of functions to be called when incorrect words are encountered. | 148 | "*List of functions to be called when incorrect words are encountered. |
| 149 | Each function is given three arguments: the beginning and the end | 149 | Each function is given three arguments: the beginning and the end |
| 150 | of the incorrect region. The third is either the symbol 'doublon' or the list | 150 | of the incorrect region. The third is either the symbol 'doublon' or the list |
| 151 | of possible corrections returned as returned by 'ispell-parse-output'. | 151 | of possible corrections as returned by 'ispell-parse-output'. |
| 152 | 152 | ||
| 153 | If any of the functions return non-Nil, the word is not highligted as | 153 | If any of the functions return non-Nil, the word is not highlighted as |
| 154 | incorrect." | 154 | incorrect." |
| 155 | :group 'flyspell | 155 | :group 'flyspell |
| 156 | :version "21.1" | 156 | :version "21.1" |
| @@ -174,7 +174,7 @@ of `flyspell-default-dictionary' to select the default dictionary." | |||
| 174 | :type 'string) | 174 | :type 'string) |
| 175 | 175 | ||
| 176 | (defcustom flyspell-check-tex-math-command nil | 176 | (defcustom flyspell-check-tex-math-command nil |
| 177 | "*Non nils means check even inside TeX math environement. | 177 | "*Non nil means check even inside TeX math environment. |
| 178 | TeX math environments are discovered by the TEXMATHP that implemented | 178 | TeX math environments are discovered by the TEXMATHP that implemented |
| 179 | inside the texmathp.el Emacs package. That package may be found at: | 179 | inside the texmathp.el Emacs package. That package may be found at: |
| 180 | http://strw.leidenuniv.nl/~dominik/Tools" | 180 | http://strw.leidenuniv.nl/~dominik/Tools" |
| @@ -588,7 +588,7 @@ flyspell-buffer checks the whole buffer." | |||
| 588 | (defun flyspell-delay-command (command) | 588 | (defun flyspell-delay-command (command) |
| 589 | "Set COMMAND to be delayed, for Flyspell. | 589 | "Set COMMAND to be delayed, for Flyspell. |
| 590 | When flyspell `post-command-hook' is invoked because a delayed command | 590 | When flyspell `post-command-hook' is invoked because a delayed command |
| 591 | as been used the current word is not immediatly checked. | 591 | as been used the current word is not immediately checked. |
| 592 | It will be checked only after `flyspell-delay' seconds." | 592 | It will be checked only after `flyspell-delay' seconds." |
| 593 | (interactive "SDelay Flyspell after Command: ") | 593 | (interactive "SDelay Flyspell after Command: ") |
| 594 | (put command 'flyspell-delayed t)) | 594 | (put command 'flyspell-delayed t)) |
| @@ -1175,7 +1175,7 @@ this function changes the last char of the `ispell-casechars' string." | |||
| 1175 | If argument FOLLOWING is non-nil or if `ispell-following-word' | 1175 | If argument FOLLOWING is non-nil or if `ispell-following-word' |
| 1176 | is non-nil when called interactively, then the following word | 1176 | is non-nil when called interactively, then the following word |
| 1177 | \(rather than preceding\) is checked when the cursor is not over a word. | 1177 | \(rather than preceding\) is checked when the cursor is not over a word. |
| 1178 | Optional second argument contains otherchars that can be included in word | 1178 | Optional second argument contains other chars that can be included in word |
| 1179 | many times. | 1179 | many times. |
| 1180 | 1180 | ||
| 1181 | Word syntax described by `ispell-dictionary-alist' (which see)." | 1181 | Word syntax described by `ispell-dictionary-alist' (which see)." |
| @@ -1314,7 +1314,7 @@ Word syntax described by `ispell-dictionary-alist' (which see)." | |||
| 1314 | (setq flyspell-large-region-end end) | 1314 | (setq flyspell-large-region-end end) |
| 1315 | (set-buffer buffer) | 1315 | (set-buffer buffer) |
| 1316 | (erase-buffer) | 1316 | (erase-buffer) |
| 1317 | ;; this is done, we can start ckecking... | 1317 | ;; this is done, we can start checking... |
| 1318 | (message "Checking region...") | 1318 | (message "Checking region...") |
| 1319 | (set-buffer curbuf) | 1319 | (set-buffer curbuf) |
| 1320 | (let ((c (apply 'call-process-region beg | 1320 | (let ((c (apply 'call-process-region beg |
| @@ -1420,7 +1420,7 @@ FLYSPELL-BUFFER." | |||
| 1420 | (setq ovs (cdr ovs)))) | 1420 | (setq ovs (cdr ovs)))) |
| 1421 | (not r))) | 1421 | (not r))) |
| 1422 | (setq pos (1+ pos))) | 1422 | (setq pos (1+ pos))) |
| 1423 | ;; save the current location for next invokation | 1423 | ;; save the current location for next invocation |
| 1424 | (setq flyspell-old-pos-error pos) | 1424 | (setq flyspell-old-pos-error pos) |
| 1425 | (setq flyspell-old-buffer-error (current-buffer)) | 1425 | (setq flyspell-old-buffer-error (current-buffer)) |
| 1426 | (goto-char pos) | 1426 | (goto-char pos) |
| @@ -1558,7 +1558,7 @@ for the overlay." | |||
| 1558 | ;* flyspell-check-previous-highlighted-word ... */ | 1558 | ;* flyspell-check-previous-highlighted-word ... */ |
| 1559 | ;*---------------------------------------------------------------------*/ | 1559 | ;*---------------------------------------------------------------------*/ |
| 1560 | (defun flyspell-check-previous-highlighted-word (&optional arg) | 1560 | (defun flyspell-check-previous-highlighted-word (&optional arg) |
| 1561 | "Correct the closer mispelled word. | 1561 | "Correct the closer misspelled word. |
| 1562 | This function scans a mis-spelled word before the cursor. If it finds one | 1562 | This function scans a mis-spelled word before the cursor. If it finds one |
| 1563 | it proposes replacement for that word. With prefix arg, count that many | 1563 | it proposes replacement for that word. With prefix arg, count that many |
| 1564 | misspelled words backwards." | 1564 | misspelled words backwards." |
| @@ -2018,49 +2018,69 @@ 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 */ | 2021 | ;* Some example functions for real autocorrecting */ |
| 2022 | ;*---------------------------------------------------------------------*/ | 2022 | ;*---------------------------------------------------------------------*/ |
| 2023 | |||
| 2023 | (defun flyspell-maybe-correct-transposition (beg end poss) | 2024 | (defun flyspell-maybe-correct-transposition (beg end poss) |
| 2024 | "Apply 'transpose-chars' to all points in the region BEG to END. | 2025 | "Check replacements for transposed characters. |
| 2025 | Return t if any those result in a possible replacement suggested by Ispell | 2026 | |
| 2026 | in POSS. Otherwise the change is undone. | 2027 | If the text between BEG and END is equal to a correction suggested by |
| 2028 | Ispell, after transposing two adjacent characters, correct the text, | ||
| 2029 | and return t. | ||
| 2030 | |||
| 2031 | The third arg POSS is either the symbol 'doublon' or a list of | ||
| 2032 | possible corrections as returned by 'ispell-parse-output'. | ||
| 2027 | 2033 | ||
| 2028 | This function is meant to be added to 'flyspell-incorrect-hook'." | 2034 | This function is meant to be added to 'flyspell-incorrect-hook'." |
| 2029 | (when (consp poss) | 2035 | (when (consp poss) |
| 2030 | (catch 'done | 2036 | (let ((temp-buffer (get-buffer-create " *flyspell-temp*")) |
| 2037 | found) | ||
| 2038 | (save-excursion | ||
| 2039 | (copy-to-buffer temp-buffer beg end) | ||
| 2040 | (set-buffer temp-buffer) | ||
| 2041 | (goto-char (1+ (point-min))) | ||
| 2042 | (while (and (not (eobp)) (not found)) | ||
| 2043 | (transpose-chars 1) | ||
| 2044 | (if (member (buffer-string) (nth 2 poss)) | ||
| 2045 | (setq found (point)) | ||
| 2046 | (transpose-chars -1) | ||
| 2047 | (forward-char)))) | ||
| 2048 | (when found | ||
| 2031 | (save-excursion | 2049 | (save-excursion |
| 2032 | (goto-char (1+ beg)) | 2050 | (goto-char (+ beg found -1)) |
| 2033 | (while (< (point) end) | 2051 | (transpose-chars -1) |
| 2034 | (transpose-chars 1) | 2052 | t))))) |
| 2035 | (when (member (buffer-substring beg end) (nth 2 poss)) | ||
| 2036 | (throw 'done t)) | ||
| 2037 | (transpose-chars -1) | ||
| 2038 | (forward-char)) | ||
| 2039 | nil)))) | ||
| 2040 | 2053 | ||
| 2041 | (defun flyspell-maybe-correct-doubling (beg end poss) | 2054 | (defun flyspell-maybe-correct-doubling (beg end poss) |
| 2042 | "For each doubled charachter in the region BEG to END, remove one. | 2055 | "Check replacements for doubled characters. |
| 2043 | Return t if any those result in a possible replacement suggested by | 2056 | |
| 2044 | Ispell in POSS. Otherwise the change is undone. | 2057 | If the text between BEG and END is equal to a correction suggested by |
| 2058 | Ispell, after removing a pair of doubled characters, correct the text, | ||
| 2059 | and return t. | ||
| 2060 | |||
| 2061 | The third arg POSS is either the symbol 'doublon' or a list of | ||
| 2062 | possible corrections as returned by 'ispell-parse-output'. | ||
| 2045 | 2063 | ||
| 2046 | This function is meant to be added to 'flyspell-incorrect-hook'." | 2064 | This function is meant to be added to 'flyspell-incorrect-hook'." |
| 2047 | (when (consp poss) | 2065 | (when (consp poss) |
| 2048 | (catch 'done | 2066 | (let ((temp-buffer (get-buffer-create " *flyspell-temp*")) |
| 2067 | found) | ||
| 2068 | (save-excursion | ||
| 2069 | (copy-to-buffer temp-buffer beg end) | ||
| 2070 | (set-buffer temp-buffer) | ||
| 2071 | (goto-char (1+ (point-min))) | ||
| 2072 | (while (and (not (eobp)) (not found)) | ||
| 2073 | (when (char-equal (char-after) (char-before)) | ||
| 2074 | (delete-char 1) | ||
| 2075 | (if (member (buffer-string) (nth 2 poss)) | ||
| 2076 | (setq found (point)) | ||
| 2077 | (insert-char (char-before) 1))) | ||
| 2078 | (forward-char))) | ||
| 2079 | (when found | ||
| 2049 | (save-excursion | 2080 | (save-excursion |
| 2050 | (let ((last (char-after beg)) | 2081 | (goto-char (+ beg found -1)) |
| 2051 | this) | 2082 | (delete-char 1) |
| 2052 | (goto-char (1+ beg)) | 2083 | t))))) |
| 2053 | (while (< (point) end) | ||
| 2054 | (setq this (char-after)) | ||
| 2055 | (if (not (char-equal this last)) | ||
| 2056 | (forward-char) | ||
| 2057 | (delete-char 1) | ||
| 2058 | (when (member (buffer-substring beg (1- end)) (nth 2 poss)) | ||
| 2059 | (throw 'done t)) | ||
| 2060 | ;; undo | ||
| 2061 | (insert-char this 1)) | ||
| 2062 | (setq last this)) | ||
| 2063 | nil))))) | ||
| 2064 | 2084 | ||
| 2065 | ;*---------------------------------------------------------------------*/ | 2085 | ;*---------------------------------------------------------------------*/ |
| 2066 | ;* flyspell-already-abbrevp ... */ | 2086 | ;* flyspell-already-abbrevp ... */ |