# HG changeset patch # User Richard M. Stallman # Date 779757044 0 # Node ID 18bf41f29a7dce24f304f02b9abec8ce7a5dd814 # Parent 7fcda87193a3a36997ce9ff50bd0ea744d7b5ac2 (ispell-highlight-spelling-error): Test window-system. (ispell-check-only): New variable. (ispell-word): Handle ispell-check-only. (ispell-minor-mode): New variable. (ispell-minor-keymap): New map. (ispell-minor-mode): New function. diff -r 7fcda87193a3 -r 18bf41f29a7d lisp/textmodes/ispell.el --- a/lisp/textmodes/ispell.el Fri Sep 16 22:29:25 1994 +0000 +++ b/lisp/textmodes/ispell.el Fri Sep 16 23:10:44 1994 +0000 @@ -709,6 +709,8 @@ (defvar ispell-region-end (make-marker) "Marker that allows spelling continuations.") +(defvar ispell-check-only nil + "If non-nil, `ispell-word' does not try to correct the word.") ;;; ********************************************************************** ;;; ********************************************************************** @@ -776,6 +778,8 @@ (funcall ispell-format-word word) (funcall ispell-format-word poss)))) ((null poss) (message "Error in ispell process")) + (ispell-check-only ; called from ispell minor mode. + (beep)) (t ; prompt for correct word. (unwind-protect (progn @@ -1301,7 +1305,8 @@ (cond ((string-match "Lucid" emacs-version) 'ispell-highlight-spelling-error-lucid) - ((and (string-lessp "19" emacs-version) (featurep 'faces)) + ((and (string-lessp "19" emacs-version) (featurep 'faces) + window-system) 'ispell-highlight-spelling-error-overlay) (t 'ispell-highlight-spelling-error-generic)))) @@ -1857,6 +1862,54 @@ (interactive) (ispell-complete-word t)) +;;; ********************************************************************** +;;; Ispell Minor Mode +;;; ********************************************************************** + +(defvar ispell-minor-mode nil + "Non-nil if Ispell minor mode is enabled.") +;; Variable indicating that ispell minor mode is active. +(make-variable-buffer-local 'ispell-minor-mode) + +(or (assq 'ispell-minor-mode minor-mode-alist) + (setq minor-mode-alist + (cons '(ispell-minor-mode " Spell") minor-mode-alist))) + +(defvar ispell-minor-keymap + (let ((map (make-sparse-keymap))) + (define-key map " " 'ispell-minor-check) + (define-key map "\r" 'ispell-minor-check) + map) + "Keymap used for Ispell minor mode.") + +(or (not (boundp 'minor-mode-map-alist)) + (assoc 'ispell-minor-mode minor-mode-map-alist) + (setq minor-mode-map-alist + (cons (cons 'ispell-minor-mode ispell-minor-keymap) + minor-mode-map-alist))) + +;;;###autoload +(defun ispell-minor-mode (&optional arg) + "Toggle Ispell minor mode. +With prefix arg, turn Ispell minor mode on iff arg is positive. + +In Ispell minor mode, pressing SPC or RET +warns you if the previous word is incorrectly spelled." + (interactive "P") + (setq ispell-minor-mode + (not (or (and (null arg) ispell-minor-mode) + (<= (prefix-numeric-value arg) 0)))) + (set-buffer-modified-p (buffer-modified-p))) + +(defun ispell-minor-check () + ;; Check previous word then continue with the normal binding of this key. + (interactive "*") + (let ((ispell-minor-mode nil) + (ispell-check-only t)) + (save-restriction + (narrow-to-region (point-min) (point)) + (ispell-word nil t)) + (call-interactively (key-binding (this-command-keys))))) ;;; ********************************************************************** ;;; Ispell Message