Commit f0a1f8bd authored by Richard M. Stallman's avatar Richard M. Stallman
Browse files

(ispell-word): Do not ignore short words.

parent a5f1c37e
...@@ -1468,80 +1468,79 @@ quit spell session exited." ...@@ -1468,80 +1468,79 @@ quit spell session exited."
end (car (cdr (cdr word))) end (car (cdr (cdr word)))
word (car word)) word (car word))
;; now check spelling of word if it has 3 or more characters. ;; At this point it used to ignore 2-letter words.
(cond ;; But that is silly; if the user asks for it, we should do it. - rms.
((> (length word) 2) (or quietly
(or quietly (message "Checking spelling of %s..."
(message "Checking spelling of %s..." (funcall ispell-format-word word)))
(funcall ispell-format-word word))) (ispell-send-string "%\n") ; put in verbose mode
(ispell-send-string "%\n") ; put in verbose mode (ispell-send-string (concat "^" word "\n"))
(ispell-send-string (concat "^" word "\n")) ;; wait until ispell has processed word
;; wait until ispell has processed word (while (progn
(while (progn (ispell-accept-output)
(ispell-accept-output) (not (string= "" (car ispell-filter)))))
(not (string= "" (car ispell-filter))))) ;;(ispell-send-string "!\n") ;back to terse mode.
;;(ispell-send-string "!\n") ;back to terse mode. (setq ispell-filter (cdr ispell-filter)) ; remove extra \n
(setq ispell-filter (cdr ispell-filter)) ; remove extra \n (if (and ispell-filter (listp ispell-filter))
(if (and ispell-filter (listp ispell-filter)) (if (> (length ispell-filter) 1)
(if (> (length ispell-filter) 1) (error "Ispell and its process have different character maps")
(error "Ispell and its process have different character maps") (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"
(message "%s is correct" (funcall ispell-format-word word)))
(funcall ispell-format-word word))) (and (fboundp 'extent-at)
(and (fboundp 'extent-at) (extent-at start)
(extent-at start) (delete-extent (extent-at start))))
(delete-extent (extent-at start)))) ((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))) (and (fboundp 'extent-at)
(and (fboundp 'extent-at) (extent-at start)
(extent-at start) (delete-extent (extent-at start))))
(delete-extent (extent-at start)))) ((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. (if (fboundp 'make-extent)
(if (fboundp 'make-extent) (let ((ext (make-extent start end)))
(let ((ext (make-extent start end))) (set-extent-property ext 'face ispell-highlight-face)
(set-extent-property ext 'face ispell-highlight-face) (set-extent-property ext 'priority 2000))
(set-extent-property ext 'priority 2000)) (beep)
(beep) (message "%s is incorrect"(funcall ispell-format-word word))))
(message "%s is incorrect"(funcall ispell-format-word word)))) (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 new-word (if (atom replace) replace (car replace))
(setq new-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 new-word (car poss)))
(if (not (equal new-word (car poss))) (progn
(progn (delete-region start end)
(delete-region start end) (setq start (point))
(setq start (point)) (ispell-insert-word new-word)
(ispell-insert-word new-word) (setq end (point))))
(setq end (point)))) (if (not (atom replace)) ;recheck spelling of replacement
(if (not (atom replace)) ;recheck spelling of replacement (progn
(progn (if (car (cdr replace)) ; query replace requested
(if (car (cdr replace)) ; query replace requested (save-window-excursion
(save-window-excursion (query-replace word new-word t)))
(query-replace word new-word t))) (goto-char start)
(goto-char start) ;; single word could be split into multiple words
;; single word could be split into multiple words (setq ispell-quit (not (ispell-region start end)))
(setq ispell-quit (not (ispell-region start end))) ))))
)))) ;; keep if rechecking word and we keep choices win.
;; keep if rechecking word and we keep choices win. (if (get-buffer ispell-choices-buffer)
(if (get-buffer ispell-choices-buffer) (kill-buffer ispell-choices-buffer))))
(kill-buffer ispell-choices-buffer)))) (ispell-pdict-save ispell-silently-savep)
(ispell-pdict-save ispell-silently-savep) ;; NB: Cancels ispell-quit incorrectly if called from ispell-region
;; NB: Cancels ispell-quit incorrectly if called from ispell-region (if ispell-quit (setq ispell-quit nil replace 'quit)))
(if ispell-quit (setq ispell-quit nil replace 'quit))))
(goto-char cursor-location) ; return to original location (goto-char cursor-location) ; return to original location
replace))) replace)))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment