diff options
| author | Richard M. Stallman | 1998-04-17 03:37:10 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-04-17 03:37:10 +0000 |
| commit | 909f0455e00dc80afcd15ad7a66549383aa10dbc (patch) | |
| tree | 39aa5fd61baee1163a899f80ed8e76c173f2566c | |
| parent | 0de86efccd36ae80affc9711c87eb2dd7e25b5ea (diff) | |
| download | emacs-909f0455e00dc80afcd15ad7a66549383aa10dbc.tar.gz emacs-909f0455e00dc80afcd15ad7a66549383aa10dbc.zip | |
(ispell-get-word): No error if can't find a word to check.
(ispell-word): Don't fuss about a word if not adjacent to it.
(ispell-minor-check): Use save-excursion.
| -rw-r--r-- | lisp/textmodes/ispell.el | 136 |
1 files changed, 71 insertions, 65 deletions
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el index e8eaf568b11..4d67535b018 100644 --- a/lisp/textmodes/ispell.el +++ b/lisp/textmodes/ispell.el | |||
| @@ -882,64 +882,67 @@ or \\[ispell-region] to update the Ispell process." | |||
| 882 | quietly ispell-quietly)) | 882 | quietly ispell-quietly)) |
| 883 | (ispell-accept-buffer-local-defs) ; use the correct dictionary | 883 | (ispell-accept-buffer-local-defs) ; use the correct dictionary |
| 884 | (let ((cursor-location (point)) ; retain cursor location | 884 | (let ((cursor-location (point)) ; retain cursor location |
| 885 | (opoint (point)) | ||
| 885 | (word (ispell-get-word following)) | 886 | (word (ispell-get-word following)) |
| 886 | start end poss replace) | 887 | start end poss replace) |
| 887 | ;; destructure return word info list. | 888 | (unless (or (equal (car word) "") |
| 888 | (setq start (car (cdr word)) | 889 | (< (nth 2 word) opoint)) |
| 889 | end (car (cdr (cdr word))) | 890 | ;; destructure return word info list. |
| 890 | word (car word)) | 891 | (setq start (car (cdr word)) |
| 891 | 892 | end (car (cdr (cdr word))) | |
| 892 | ;; now check spelling of word. | 893 | word (car word)) |
| 893 | (or quietly | 894 | |
| 894 | (message "Checking spelling of %s..." | 895 | ;; now check spelling of word. |
| 895 | (funcall ispell-format-word word))) | 896 | (or quietly |
| 896 | (process-send-string ispell-process "%\n") ;put in verbose mode | 897 | (message "Checking spelling of %s..." |
| 897 | (process-send-string ispell-process (concat "^" word "\n")) | 898 | (funcall ispell-format-word word))) |
| 898 | ;; wait until ispell has processed word | 899 | (process-send-string ispell-process "%\n") ;put in verbose mode |
| 899 | (while (progn | 900 | (process-send-string ispell-process (concat "^" word "\n")) |
| 900 | (accept-process-output ispell-process) | 901 | ;; wait until ispell has processed word |
| 901 | (not (string= "" (car ispell-filter))))) | 902 | (while (progn |
| 902 | ;;(process-send-string ispell-process "!\n") ;back to terse mode. | 903 | (accept-process-output ispell-process) |
| 903 | (setq ispell-filter (cdr ispell-filter)) | 904 | (not (string= "" (car ispell-filter))))) |
| 904 | (if (listp ispell-filter) | 905 | ;;(process-send-string ispell-process "!\n") ;back to terse mode. |
| 905 | (setq poss (ispell-parse-output (car ispell-filter)))) | 906 | (setq ispell-filter (cdr ispell-filter)) |
| 906 | (cond ((eq poss t) | 907 | (if (listp ispell-filter) |
| 907 | (or quietly | 908 | (setq poss (ispell-parse-output (car ispell-filter)))) |
| 908 | (message "%s is correct" (funcall ispell-format-word word)))) | 909 | (cond ((eq poss t) |
| 909 | ((stringp poss) | 910 | (or quietly |
| 910 | (or quietly | 911 | (message "%s is correct" (funcall ispell-format-word word)))) |
| 911 | (message "%s is correct because of root %s" | 912 | ((stringp poss) |
| 912 | (funcall ispell-format-word word) | 913 | (or quietly |
| 913 | (funcall ispell-format-word poss)))) | 914 | (message "%s is correct because of root %s" |
| 914 | ((null poss) (message "Error in ispell process")) | 915 | (funcall ispell-format-word word) |
| 915 | (ispell-check-only ; called from ispell minor mode. | 916 | (funcall ispell-format-word poss)))) |
| 916 | (message "Misspelled word `%s'" word) | 917 | ((null poss) (message "Error in ispell process")) |
| 917 | (beep)) | 918 | (ispell-check-only ; called from ispell minor mode. |
| 918 | (t ; prompt for correct word. | 919 | (message "Misspelled word `%s'" word) |
| 919 | (save-window-excursion | 920 | (beep)) |
| 920 | (setq replace (ispell-command-loop | 921 | (t ; prompt for correct word. |
| 921 | (car (cdr (cdr poss))) | 922 | (save-window-excursion |
| 922 | (car (cdr (cdr (cdr poss)))) | 923 | (setq replace (ispell-command-loop |
| 923 | (car poss) start end))) | 924 | (car (cdr (cdr poss))) |
| 924 | (cond ((equal 0 replace) | 925 | (car (cdr (cdr (cdr poss)))) |
| 925 | (ispell-add-per-file-word-list (car poss))) | 926 | (car poss) start end))) |
| 926 | (replace | 927 | (cond ((equal 0 replace) |
| 927 | (setq word (if (atom replace) replace (car replace)) | 928 | (ispell-add-per-file-word-list (car poss))) |
| 928 | cursor-location (+ (- (length word) (- end start)) | 929 | (replace |
| 929 | cursor-location)) | 930 | (setq word (if (atom replace) replace (car replace)) |
| 930 | (if (not (equal word (car poss))) | 931 | cursor-location (+ (- (length word) (- end start)) |
| 931 | (progn | 932 | cursor-location)) |
| 932 | (delete-region start end) | 933 | (if (not (equal word (car poss))) |
| 933 | (insert word))) | 934 | (progn |
| 934 | (if (not (atom replace)) ; recheck spelling of replacement | 935 | (delete-region start end) |
| 935 | (progn | 936 | (insert word))) |
| 936 | (goto-char cursor-location) | 937 | (if (not (atom replace)) ; recheck spelling of replacement |
| 937 | (ispell-word following quietly))))) | 938 | (progn |
| 938 | (if (get-buffer ispell-choices-buffer) | 939 | (goto-char cursor-location) |
| 939 | (kill-buffer ispell-choices-buffer)))) | 940 | (ispell-word following quietly))))) |
| 940 | (goto-char cursor-location) ; return to original location | 941 | (if (get-buffer ispell-choices-buffer) |
| 941 | (ispell-pdict-save ispell-silently-savep) | 942 | (kill-buffer ispell-choices-buffer)))) |
| 942 | (if ispell-quit (setq ispell-quit nil))))) | 943 | (goto-char cursor-location) ; return to original location |
| 944 | (ispell-pdict-save ispell-silently-savep) | ||
| 945 | (if ispell-quit (setq ispell-quit nil)))))) | ||
| 943 | 946 | ||
| 944 | 947 | ||
| 945 | (defun ispell-get-word (following &optional extra-otherchars) | 948 | (defun ispell-get-word (following &optional extra-otherchars) |
| @@ -991,12 +994,14 @@ Word syntax described by `ispell-dictionary-alist' (which see)." | |||
| 991 | (re-search-backward ispell-not-casechars (point-min) 'move) | 994 | (re-search-backward ispell-not-casechars (point-min) 'move) |
| 992 | (backward-char -1)))) | 995 | (backward-char -1)))) |
| 993 | ;; Now mark the word and save to string. | 996 | ;; Now mark the word and save to string. |
| 994 | (or (re-search-forward word-regexp (point-max) t) | 997 | (if (not (re-search-forward word-regexp (point-max) t)) |
| 995 | (error "No word found to check!")) | 998 | (if ispell-check-only |
| 996 | (setq start (match-beginning 0) | 999 | (list "" (point) (point)) |
| 997 | end (point) | 1000 | (error "No word found to check!")) |
| 998 | word (buffer-substring-no-properties start end)) | 1001 | (setq start (match-beginning 0) |
| 999 | (list word start end))) | 1002 | end (point) |
| 1003 | word (buffer-substring-no-properties start end)) | ||
| 1004 | (list word start end)))) | ||
| 1000 | 1005 | ||
| 1001 | 1006 | ||
| 1002 | ;;; Global ispell-pdict-modified-p is set by ispell-command-loop and | 1007 | ;;; Global ispell-pdict-modified-p is set by ispell-command-loop and |
| @@ -2141,9 +2146,10 @@ warns you if the previous word is incorrectly spelled." | |||
| 2141 | (interactive "*") | 2146 | (interactive "*") |
| 2142 | (let ((ispell-minor-mode nil) | 2147 | (let ((ispell-minor-mode nil) |
| 2143 | (ispell-check-only t)) | 2148 | (ispell-check-only t)) |
| 2144 | (save-restriction | 2149 | (save-excursion |
| 2145 | (narrow-to-region (point-min) (point)) | 2150 | (save-restriction |
| 2146 | (ispell-word nil t)) | 2151 | (narrow-to-region (point-min) (point)) |
| 2152 | (ispell-word nil t))) | ||
| 2147 | (call-interactively (key-binding (this-command-keys))))) | 2153 | (call-interactively (key-binding (this-command-keys))))) |
| 2148 | 2154 | ||
| 2149 | 2155 | ||