1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-20 04:30:55 -08:00

(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.
This commit is contained in:
Richard M. Stallman 1998-04-17 03:37:10 +00:00
parent 0de86efccd
commit 909f0455e0

View file

@ -882,64 +882,67 @@ or \\[ispell-region] to update the Ispell process."
quietly ispell-quietly)) quietly ispell-quietly))
(ispell-accept-buffer-local-defs) ; use the correct dictionary (ispell-accept-buffer-local-defs) ; use the correct dictionary
(let ((cursor-location (point)) ; retain cursor location (let ((cursor-location (point)) ; retain cursor location
(opoint (point))
(word (ispell-get-word following)) (word (ispell-get-word following))
start end poss replace) start end poss replace)
;; destructure return word info list. (unless (or (equal (car word) "")
(setq start (car (cdr word)) (< (nth 2 word) opoint))
end (car (cdr (cdr word))) ;; destructure return word info list.
word (car word)) (setq start (car (cdr word))
end (car (cdr (cdr word)))
word (car word))
;; now check spelling of word. ;; now check spelling of word.
(or quietly (or quietly
(message "Checking spelling of %s..." (message "Checking spelling of %s..."
(funcall ispell-format-word word))) (funcall ispell-format-word word)))
(process-send-string ispell-process "%\n") ;put in verbose mode (process-send-string ispell-process "%\n") ;put in verbose mode
(process-send-string ispell-process (concat "^" word "\n")) (process-send-string ispell-process (concat "^" word "\n"))
;; wait until ispell has processed word ;; wait until ispell has processed word
(while (progn (while (progn
(accept-process-output ispell-process) (accept-process-output ispell-process)
(not (string= "" (car ispell-filter))))) (not (string= "" (car ispell-filter)))))
;;(process-send-string ispell-process "!\n") ;back to terse mode. ;;(process-send-string ispell-process "!\n") ;back to terse mode.
(setq ispell-filter (cdr ispell-filter)) (setq ispell-filter (cdr ispell-filter))
(if (listp ispell-filter) (if (listp ispell-filter)
(setq poss (ispell-parse-output (car ispell-filter)))) (setq poss (ispell-parse-output (car ispell-filter))))
(cond ((eq poss t) (cond ((eq poss t)
(or quietly (or quietly
(message "%s is correct" (funcall ispell-format-word word)))) (message "%s is correct" (funcall ispell-format-word word))))
((stringp poss) ((stringp poss)
(or quietly (or quietly
(message "%s is correct because of root %s" (message "%s is correct because of root %s"
(funcall ispell-format-word word) (funcall ispell-format-word word)
(funcall ispell-format-word poss)))) (funcall ispell-format-word poss))))
((null poss) (message "Error in ispell process")) ((null poss) (message "Error in ispell process"))
(ispell-check-only ; called from ispell minor mode. (ispell-check-only ; called from ispell minor mode.
(message "Misspelled word `%s'" word) (message "Misspelled word `%s'" word)
(beep)) (beep))
(t ; prompt for correct word. (t ; prompt for correct word.
(save-window-excursion (save-window-excursion
(setq replace (ispell-command-loop (setq replace (ispell-command-loop
(car (cdr (cdr poss))) (car (cdr (cdr poss)))
(car (cdr (cdr (cdr poss)))) (car (cdr (cdr (cdr poss))))
(car poss) start end))) (car poss) start end)))
(cond ((equal 0 replace) (cond ((equal 0 replace)
(ispell-add-per-file-word-list (car poss))) (ispell-add-per-file-word-list (car poss)))
(replace (replace
(setq word (if (atom replace) replace (car replace)) (setq word (if (atom replace) replace (car replace))
cursor-location (+ (- (length word) (- end start)) cursor-location (+ (- (length word) (- end start))
cursor-location)) cursor-location))
(if (not (equal word (car poss))) (if (not (equal word (car poss)))
(progn (progn
(delete-region start end) (delete-region start end)
(insert word))) (insert word)))
(if (not (atom replace)) ; recheck spelling of replacement (if (not (atom replace)) ; recheck spelling of replacement
(progn (progn
(goto-char cursor-location) (goto-char cursor-location)
(ispell-word following quietly))))) (ispell-word following quietly)))))
(if (get-buffer ispell-choices-buffer) (if (get-buffer ispell-choices-buffer)
(kill-buffer ispell-choices-buffer)))) (kill-buffer ispell-choices-buffer))))
(goto-char cursor-location) ; return to original location (goto-char cursor-location) ; return to original location
(ispell-pdict-save ispell-silently-savep) (ispell-pdict-save ispell-silently-savep)
(if ispell-quit (setq ispell-quit nil))))) (if ispell-quit (setq ispell-quit nil))))))
(defun ispell-get-word (following &optional extra-otherchars) (defun ispell-get-word (following &optional extra-otherchars)
@ -991,12 +994,14 @@ Word syntax described by `ispell-dictionary-alist' (which see)."
(re-search-backward ispell-not-casechars (point-min) 'move) (re-search-backward ispell-not-casechars (point-min) 'move)
(backward-char -1)))) (backward-char -1))))
;; Now mark the word and save to string. ;; Now mark the word and save to string.
(or (re-search-forward word-regexp (point-max) t) (if (not (re-search-forward word-regexp (point-max) t))
(error "No word found to check!")) (if ispell-check-only
(setq start (match-beginning 0) (list "" (point) (point))
end (point) (error "No word found to check!"))
word (buffer-substring-no-properties start end)) (setq start (match-beginning 0)
(list word start end))) end (point)
word (buffer-substring-no-properties start end))
(list word start end))))
;;; Global ispell-pdict-modified-p is set by ispell-command-loop and ;;; 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."
(interactive "*") (interactive "*")
(let ((ispell-minor-mode nil) (let ((ispell-minor-mode nil)
(ispell-check-only t)) (ispell-check-only t))
(save-restriction (save-excursion
(narrow-to-region (point-min) (point)) (save-restriction
(ispell-word nil t)) (narrow-to-region (point-min) (point))
(ispell-word nil t)))
(call-interactively (key-binding (this-command-keys))))) (call-interactively (key-binding (this-command-keys)))))