aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1993-11-07 22:45:42 +0000
committerRichard M. Stallman1993-11-07 22:45:42 +0000
commitaf4d43e9093ea04dd075011a530a5c3fbc48583a (patch)
treee8e0481c49a64326eea70dffaf752a0bfcafb924
parent7f5d354194fc9274dfd581e706b0276490cae1ab (diff)
downloademacs-af4d43e9093ea04dd075011a530a5c3fbc48583a.tar.gz
emacs-af4d43e9093ea04dd075011a530a5c3fbc48583a.zip
(ispell-message): Stop if ispell-region returns nil.
(ispell-next, ispell-word): Catch ispell-quit, not quit. (ispell-next): Return t if exit normally (no throw to ispell-quit). (ispell-command-loop): For q, throw to ispell-quit. Explicitly handle C-g. (ispell): If we don't call ispell-next, return t. (ispell-non-empty-string): New function. (ispell-message): Add autoload. Choose a citation regexp automatically. Don't fail if there is no following cited line after filled lines.
-rw-r--r--lisp/textmodes/ispell4.el107
1 files changed, 82 insertions, 25 deletions
diff --git a/lisp/textmodes/ispell4.el b/lisp/textmodes/ispell4.el
index 63724f0d0c0..cb632810a19 100644
--- a/lisp/textmodes/ispell4.el
+++ b/lisp/textmodes/ispell4.el
@@ -314,7 +314,8 @@ q, \\[keyboard-quit] Leave the command loop. You can come back later with \\[is
314 (setq ispell-bad-words (nreverse bad-words)))) 314 (setq ispell-bad-words (nreverse bad-words))))
315 (cond ((not (markerp (car ispell-bad-words))) 315 (cond ((not (markerp (car ispell-bad-words)))
316 (setq ispell-bad-words nil) 316 (setq ispell-bad-words nil)
317 (message "No misspellings.")) 317 (message "No misspellings.")
318 t)
318 (t 319 (t
319 (message "Ispell parsing done.") 320 (message "Ispell parsing done.")
320 (ispell-next)))) 321 (ispell-next))))
@@ -323,11 +324,12 @@ q, \\[keyboard-quit] Leave the command loop. You can come back later with \\[is
323(defalias 'ispell-buffer 'ispell) 324(defalias 'ispell-buffer 'ispell)
324 325
325(defun ispell-next () 326(defun ispell-next ()
326 "Resume command loop for most recent Ispell command." 327 "Resume command loop for most recent Ispell command.
328Return value is t unless exit is due to typing `q'."
327 (interactive) 329 (interactive)
328 (setq ispell-window-configuration nil) 330 (setq ispell-window-configuration nil)
329 (unwind-protect 331 (unwind-protect
330 (catch 'quit 332 (catch 'ispell-quit
331 ;; There used to be a save-excursion here, 333 ;; There used to be a save-excursion here,
332 ;; but that was annoying: it's better if point doesn't move 334 ;; but that was annoying: it's better if point doesn't move
333 ;; when you type q. 335 ;; when you type q.
@@ -337,7 +339,8 @@ q, \\[keyboard-quit] Leave the command loop. You can come back later with \\[is
337 (push-mark) 339 (push-mark)
338 (ispell-point next "at saved position.") 340 (ispell-point next "at saved position.")
339 (setq ispell-bad-words (cdr ispell-bad-words)) 341 (setq ispell-bad-words (cdr ispell-bad-words))
340 (set-marker next nil)))) 342 (set-marker next nil)))
343 t)
341 (if ispell-window-configuration 344 (if ispell-window-configuration
342 (set-window-configuration ispell-window-configuration)) 345 (set-window-configuration ispell-window-configuration))
343 (cond ((null ispell-bad-words) 346 (cond ((null ispell-bad-words)
@@ -365,7 +368,7 @@ With a prefix argument, resume handling of the previous Ispell command."
365 (if resume 368 (if resume
366 (ispell-next) 369 (ispell-next)
367 (condition-case err 370 (condition-case err
368 (catch 'quit 371 (catch 'ispell-quit
369 (save-window-excursion 372 (save-window-excursion
370 (ispell-point (point) "at point.")) 373 (ispell-point (point) "at point."))
371 (ispell-dump)) 374 (ispell-dump))
@@ -544,7 +547,9 @@ L lookup; Q quit\n")
544 (ispell-replace start end replacement) 547 (ispell-replace start end replacement)
545 (setq flag nil)) 548 (setq flag nil))
546 ((= c ?q) 549 ((= c ?q)
547 (throw 'quit nil)) 550 (throw 'ispell-quit nil))
551 ((= c quit-char)
552 (keyboard-quit))
548 ((= c ? ) 553 ((= c ? )
549 (setq flag nil)) 554 (setq flag nil))
550 ((= c ?r) 555 ((= c ?r)
@@ -916,30 +921,82 @@ an interior word fragment. `ispell-have-new-look' should be t."
916 921
917 ;; Make the list into an alist and return. 922 ;; Make the list into an alist and return.
918 (mapcar 'list (nreverse list))))) 923 (mapcar 'list (nreverse list)))))
919 924
920(defvar ispell-message-cite-regexp "^ " 925;; Return regexp-quote of STRING if STRING is non-empty.
926;; Otherwise return an unmatchable regexp.
927(defun ispell-non-empty-string (string)
928 (if (or (not string) (string-equal string ""))
929 "\\'\\`" ; An unmatchable string if string is null.
930 (regexp-quote string)))
931
932(defvar ispell-message-cite-regexp "^ \\|^\t"
921 "*Regular expression to match lines cited from one message into another.") 933 "*Regular expression to match lines cited from one message into another.")
922 934
935;;;###autoload
923(defun ispell-message () 936(defun ispell-message ()
924 "Check the spelling for an outgoing mail message." 937 "Check the spelling of a mail message or news post.
938Don't check spelling of message headers or included messages.
939
940To spell-check whenever a message is sent, include this line in .emacs:
941 (setq news-inews-hook (setq mail-send-hook 'ispell-message))
942
943Or you can bind the function to C-c i in gnus or mail with:
944 (setq mail-mode-hook (setq news-reply-mode-hook
945 (function (lambda () (local-set-key \"\\C-ci\" 'ispell-message)))))"
925 (interactive) 946 (interactive)
926 (save-excursion 947 (save-excursion
927 (beginning-of-buffer) 948 (let (non-internal-message)
928 ;; Don't spell-check the headers. 949 (goto-char (point-min))
929 (search-forward mail-header-separator nil t) 950 ;; Don't spell-check the headers.
930 (while (not (eobp)) 951 (if (search-forward mail-header-separator nil t)
931 ;; Skip across text cited from other messages. 952 ;; Move to first body line.
932 (while (and (looking-at (concat "^[ \t]*$\\|" 953 (forward-line 1)
933 ispell-message-cite-regexp)) 954 (while (and (looking-at "[a-zA-Z-]+:\\|\t\\| ")
934 (not (eobp))) 955 (not (eobp)))
935 (forward-line 1)) 956 (forward-line 1))
936 (if (not (eobp)) 957 (setq non-internal-message t)
937 ;; Fill the next batch of lines that *aren't* cited. 958 )
938 (let ((start (point))) 959 (let ((cite-regexp ;Prefix of inserted text
939 (re-search-forward 960 (cond
940 (concat "^\\(" ispell-message-cite-regexp "\\)") nil 'end) 961 ((featurep 'supercite) ; sc 3.0
941 (beginning-of-line) 962 (concat "\\(" (sc-cite-regexp) "\\)" "\\|"
942 (save-excursion (ispell-region (- start 1) (point)))))))) 963 (ispell-non-empty-string sc-reference-tag-string)))
964 ((featurep 'sc) ; sc 2.3
965 (concat "\\(" sc-cite-regexp "\\)" "\\|"
966 (ispell-non-empty-string sc-reference-tag-string)))
967 (non-internal-message ; Assume nn sent us this message.
968 (concat "In [a-zA-Z.]+ you write:" "\\|"
969 "In <[^,;&+=]+> [^,;&+=]+ writes:" "\\|"
970 " *> *"))
971 ((equal major-mode 'news-reply-mode) ;Gnus
972 (concat "In article <" "\\|"
973 (ispell-non-empty-string mail-yank-prefix)
974 ))
975 ((boundp 'vm-included-text-prefix) ; VM mail message
976 (concat "[^,;&+=]+ writes:" "\\|"
977 (ispell-non-empty-string vm-included-text-prefix)
978 ))
979 ((boundp 'mh-ins-buf-prefix) ; mh mail message
980 (ispell-non-empty-string mh-ins-buf-prefix))
981 (mail-yank-prefix ; vanilla mail message.
982 (ispell-non-empty-string mail-yank-prefix))
983 (t ispell-message-cite-regexp)))
984 (continue t))
985
986 (while (and (not (eobp)) continue)
987 ;; Skip across text cited from other messages.
988 (while (and (looking-at (concat "^[ \t]*$\\|" cite-regexp))
989 (not (eobp)))
990 (forward-line 1))
991 (if (not (eobp))
992 ;; Fill the next batch of lines that *aren't* cited.
993 (let ((start (point)))
994 (if (re-search-forward
995 (concat "^\\(" cite-regexp "\\)") nil 'end)
996 (beginning-of-line))
997 (beginning-of-line)
998 (save-excursion
999 (setq continue (ispell-region (- start 1) (point)))))))))))
943 1000
944(provide 'ispell) 1001(provide 'ispell)
945 1002