Mercurial > emacs
comparison lisp/textmodes/flyspell.el @ 90650:02cf29720f31
Merge from emacs--devo--0
Patches applied:
* emacs--devo--0 (patch 490-504)
- Update from CVS
- Merge from gnus--rel--5.10
* gnus--rel--5.10 (patch 161-163)
- Update from CVS
- Merge from emacs--devo--0
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-130
author | Miles Bader <miles@gnu.org> |
---|---|
date | Tue, 07 Nov 2006 23:22:48 +0000 |
parents | 7eeafaaa9eab ab4757475733 |
children | dbe3f29e61d6 |
comparison
equal
deleted
inserted
replaced
90649:d53934e7ddef | 90650:02cf29720f31 |
---|---|
187 :group 'flyspell | 187 :group 'flyspell |
188 :version "21.1" | 188 :version "21.1" |
189 :type 'string) | 189 :type 'string) |
190 | 190 |
191 (defcustom flyspell-check-tex-math-command nil | 191 (defcustom flyspell-check-tex-math-command nil |
192 "Non nil means check even inside TeX math environment. | 192 "Non-nil means check even inside TeX math environment. |
193 TeX math environments are discovered by the TEXMATHP that implemented | 193 TeX math environments are discovered by the TEXMATHP that implemented |
194 inside the texmathp.el Emacs package. That package may be found at: | 194 inside the texmathp.el Emacs package. That package may be found at: |
195 http://strw.leidenuniv.nl/~dominik/Tools" | 195 http://strw.leidenuniv.nl/~dominik/Tools" |
196 :group 'flyspell | 196 :group 'flyspell |
197 :type 'boolean) | 197 :type 'boolean) |
410 (if flyspell-use-meta-tab | 410 (if flyspell-use-meta-tab |
411 (define-key map "\M-\t" 'flyspell-auto-correct-word)) | 411 (define-key map "\M-\t" 'flyspell-auto-correct-word)) |
412 (define-key map flyspell-auto-correct-binding 'flyspell-auto-correct-previous-word) | 412 (define-key map flyspell-auto-correct-binding 'flyspell-auto-correct-previous-word) |
413 (define-key map [(control ?\,)] 'flyspell-goto-next-error) | 413 (define-key map [(control ?\,)] 'flyspell-goto-next-error) |
414 (define-key map [(control ?\.)] 'flyspell-auto-correct-word) | 414 (define-key map [(control ?\.)] 'flyspell-auto-correct-word) |
415 (define-key map [(meta ?\^m)] 'flyspell-correct-word-before-point) | |
415 map) | 416 map) |
416 "Minor mode keymap for Flyspell mode--for the whole buffer.") | 417 "Minor mode keymap for Flyspell mode--for the whole buffer.") |
417 | 418 |
418 ;; dash character machinery | 419 ;; dash character machinery |
419 (defvar flyspell-consider-dash-as-word-delimiter-flag nil | 420 (defvar flyspell-consider-dash-as-word-delimiter-flag nil |
1997 (setq flyspell-auto-correct-previous-pos (point)))))))) | 1998 (setq flyspell-auto-correct-previous-pos (point)))))))) |
1998 | 1999 |
1999 ;;*---------------------------------------------------------------------*/ | 2000 ;;*---------------------------------------------------------------------*/ |
2000 ;;* flyspell-correct-word ... */ | 2001 ;;* flyspell-correct-word ... */ |
2001 ;;*---------------------------------------------------------------------*/ | 2002 ;;*---------------------------------------------------------------------*/ |
2003 | |
2002 (defun flyspell-correct-word (event) | 2004 (defun flyspell-correct-word (event) |
2003 "Pop up a menu of possible corrections for a misspelled word. | 2005 "Pop up a menu of possible corrections for a misspelled word. |
2004 The word checked is the word at the mouse position." | 2006 The word checked is the word at the mouse position." |
2005 (interactive "e") | 2007 (interactive "e") |
2008 (let ((save (point))) | |
2009 (mouse-set-point event) | |
2010 (flyspell-correct-word-before-point event save))) | |
2011 | |
2012 (defun flyspell-correct-word-before-point (&optional event opoint) | |
2013 "Pop up a menu of possible corrections for misspelled word before point. | |
2014 If EVENT is non-nil, it is the mouse event that invoked this operation; | |
2015 that controls where to put the menu. | |
2016 If OPOINT is non-nil, restore point there after adjusting it for replacement." | |
2017 (interactive) | |
2018 (unless (mouse-position) | |
2019 (error "Pop-up menus do not work on this terminal")) | |
2006 ;; use the correct dictionary | 2020 ;; use the correct dictionary |
2007 (flyspell-accept-buffer-local-defs) | 2021 (flyspell-accept-buffer-local-defs) |
2008 ;; retain cursor location (I don't know why but save-excursion here fails). | 2022 (let ((cursor-location (point)) |
2009 (let ((save (point))) | 2023 (word (flyspell-get-word nil))) |
2010 (mouse-set-point event) | 2024 (if (consp word) |
2011 (let ((cursor-location (point)) | 2025 (let ((start (car (cdr word))) |
2012 (word (flyspell-get-word nil))) | 2026 (end (car (cdr (cdr word)))) |
2013 (if (consp word) | 2027 (word (car word)) |
2014 (let ((start (car (cdr word))) | 2028 poss ispell-filter) |
2015 (end (car (cdr (cdr word)))) | 2029 ;; now check spelling of word. |
2016 (word (car word)) | 2030 (ispell-send-string "%\n") ;put in verbose mode |
2017 poss ispell-filter) | 2031 (ispell-send-string (concat "^" word "\n")) |
2018 ;; now check spelling of word. | 2032 ;; wait until ispell has processed word |
2019 (ispell-send-string "%\n") ;put in verbose mode | 2033 (while (progn |
2020 (ispell-send-string (concat "^" word "\n")) | 2034 (accept-process-output ispell-process) |
2021 ;; wait until ispell has processed word | 2035 (not (string= "" (car ispell-filter))))) |
2022 (while (progn | 2036 ;; Remove leading empty element |
2023 (accept-process-output ispell-process) | 2037 (setq ispell-filter (cdr ispell-filter)) |
2024 (not (string= "" (car ispell-filter))))) | 2038 ;; ispell process should return something after word is sent. |
2025 ;; Remove leading empty element | 2039 ;; Tag word as valid (i.e., skip) otherwise |
2026 (setq ispell-filter (cdr ispell-filter)) | 2040 (or ispell-filter |
2027 ;; ispell process should return something after word is sent. | 2041 (setq ispell-filter '(*))) |
2028 ;; Tag word as valid (i.e., skip) otherwise | 2042 (if (consp ispell-filter) |
2029 (or ispell-filter | 2043 (setq poss (ispell-parse-output (car ispell-filter)))) |
2030 (setq ispell-filter '(*))) | 2044 (cond |
2031 (if (consp ispell-filter) | 2045 ((or (eq poss t) (stringp poss)) |
2032 (setq poss (ispell-parse-output (car ispell-filter)))) | 2046 ;; don't correct word |
2033 (cond | 2047 t) |
2034 ((or (eq poss t) (stringp poss)) | 2048 ((null poss) |
2035 ;; don't correct word | 2049 ;; ispell error |
2036 t) | 2050 (error "Ispell: error in Ispell process")) |
2037 ((null poss) | 2051 ((featurep 'xemacs) |
2038 ;; ispell error | 2052 (flyspell-xemacs-popup |
2039 (error "Ispell: error in Ispell process")) | 2053 poss word cursor-location start end opoint)) |
2040 ((featurep 'xemacs) | 2054 (t |
2041 (flyspell-xemacs-popup | 2055 ;; The word is incorrect, we have to propose a replacement. |
2042 poss word cursor-location start end save)) | 2056 (flyspell-do-correct (flyspell-emacs-popup event poss word) |
2043 (t | 2057 poss word cursor-location start end opoint))) |
2044 ;; The word is incorrect, we have to propose a replacement. | 2058 (ispell-pdict-save t))))) |
2045 (flyspell-do-correct (flyspell-emacs-popup event poss word) | |
2046 poss word cursor-location start end save))) | |
2047 (ispell-pdict-save t)))))) | |
2048 | 2059 |
2049 ;;*---------------------------------------------------------------------*/ | 2060 ;;*---------------------------------------------------------------------*/ |
2050 ;;* flyspell-do-correct ... */ | 2061 ;;* flyspell-do-correct ... */ |
2051 ;;*---------------------------------------------------------------------*/ | 2062 ;;*---------------------------------------------------------------------*/ |
2052 (defun flyspell-do-correct (replace poss word cursor-location start end save) | 2063 (defun flyspell-do-correct (replace poss word cursor-location start end save) |