Mercurial > emacs
changeset 73779:ab4757475733
(flyspell-correct-word-before-point):
New function broken out of flyspell-correct-word.
(flyspell-mode-map): Bind it to M-RET.
(flyspell-correct-word): Call it.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 06 Nov 2006 16:06:11 +0000 |
parents | 7e762349b1c3 |
children | b84950e6ade6 |
files | lisp/textmodes/flyspell.el |
diffstat | 1 files changed, 51 insertions(+), 40 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/textmodes/flyspell.el Mon Nov 06 16:01:53 2006 +0000 +++ b/lisp/textmodes/flyspell.el Mon Nov 06 16:06:11 2006 +0000 @@ -412,6 +412,7 @@ (define-key map flyspell-auto-correct-binding 'flyspell-auto-correct-previous-word) (define-key map [(control ?\,)] 'flyspell-goto-next-error) (define-key map [(control ?\.)] 'flyspell-auto-correct-word) + (define-key map [(meta ?\^m)] 'flyspell-correct-word-before-point) map) "Minor mode keymap for Flyspell mode--for the whole buffer.") @@ -1999,52 +2000,62 @@ ;;*---------------------------------------------------------------------*/ ;;* flyspell-correct-word ... */ ;;*---------------------------------------------------------------------*/ + (defun flyspell-correct-word (event) "Pop up a menu of possible corrections for a misspelled word. The word checked is the word at the mouse position." (interactive "e") - ;; use the correct dictionary - (flyspell-accept-buffer-local-defs) - ;; retain cursor location (I don't know why but save-excursion here fails). (let ((save (point))) (mouse-set-point event) - (let ((cursor-location (point)) - (word (flyspell-get-word nil))) - (if (consp word) - (let ((start (car (cdr word))) - (end (car (cdr (cdr word)))) - (word (car word)) - poss ispell-filter) - ;; now check spelling of word. - (ispell-send-string "%\n") ;put in verbose mode - (ispell-send-string (concat "^" word "\n")) - ;; wait until ispell has processed 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 - ((or (eq poss t) (stringp poss)) - ;; don't correct word - t) - ((null poss) - ;; ispell error - (error "Ispell: error in Ispell process")) - ((featurep 'xemacs) - (flyspell-xemacs-popup - poss word cursor-location start end save)) - (t - ;; The word is incorrect, we have to propose a replacement. - (flyspell-do-correct (flyspell-emacs-popup event poss word) - poss word cursor-location start end save))) - (ispell-pdict-save t)))))) + (flyspell-correct-word-before-point event save))) + +(defun flyspell-correct-word-before-point (&optional event opoint) + "Pop up a menu of possible corrections for misspelled word before point. +If EVENT is non-nil, it is the mouse event that invoked this operation; +that controls where to put the menu. +If OPOINT is non-nil, restore point there after adjusting it for replacement." + (interactive) + (unless (mouse-position) + (error "Pop-up menus do not work on this terminal")) + ;; use the correct dictionary + (flyspell-accept-buffer-local-defs) + (let ((cursor-location (point)) + (word (flyspell-get-word nil))) + (if (consp word) + (let ((start (car (cdr word))) + (end (car (cdr (cdr word)))) + (word (car word)) + poss ispell-filter) + ;; now check spelling of word. + (ispell-send-string "%\n") ;put in verbose mode + (ispell-send-string (concat "^" word "\n")) + ;; wait until ispell has processed 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 + ((or (eq poss t) (stringp poss)) + ;; don't correct word + t) + ((null poss) + ;; ispell error + (error "Ispell: error in Ispell process")) + ((featurep 'xemacs) + (flyspell-xemacs-popup + poss word cursor-location start end opoint)) + (t + ;; The word is incorrect, we have to propose a replacement. + (flyspell-do-correct (flyspell-emacs-popup event poss word) + poss word cursor-location start end opoint))) + (ispell-pdict-save t))))) ;;*---------------------------------------------------------------------*/ ;;* flyspell-do-correct ... */