Mercurial > emacs
comparison lisp/textmodes/=ispell4.el @ 4926:c639a86ac9f1
(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.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 07 Nov 1993 22:45:42 +0000 |
parents | 7c2d90ff5849 |
children | 24bb9fff22ce |
comparison
equal
deleted
inserted
replaced
4925:76fb8b35df3f | 4926:c639a86ac9f1 |
---|---|
312 bad-words)))) | 312 bad-words)))) |
313 (setq bad-words (cons pos bad-words)) | 313 (setq bad-words (cons pos bad-words)) |
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)))) |
321 | 322 |
322 ;;;###autoload | 323 ;;;###autoload |
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. |
328 Return 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. |
334 (let (next) | 336 (let (next) |
335 (while (markerp (setq next (car ispell-bad-words))) | 337 (while (markerp (setq next (car ispell-bad-words))) |
336 (switch-to-buffer (marker-buffer next)) | 338 (switch-to-buffer (marker-buffer next)) |
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) |
344 (error "Ispell has not yet been run.")) | 347 (error "Ispell has not yet been run.")) |
345 ((markerp (car ispell-bad-words)) | 348 ((markerp (car ispell-bad-words)) |
363 With a prefix argument, resume handling of the previous Ispell command." | 366 With a prefix argument, resume handling of the previous Ispell command." |
364 (interactive "P") | 367 (interactive "P") |
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)) |
372 (ispell-startup-error | 375 (ispell-startup-error |
373 (cond ((y-or-n-p "Problem starting ispell, use old-style spell instead? ") | 376 (cond ((y-or-n-p "Problem starting ispell, use old-style spell instead? ") |
542 (<= c ?9) | 545 (<= c ?9) |
543 (setq replacement (nth (- c ?0) message))) | 546 (setq replacement (nth (- c ?0) message))) |
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) |
551 (ispell-replace start end (read-string "Replacement: ")) | 556 (ispell-replace start end (read-string "Replacement: ")) |
552 (setq rescan t) | 557 (setq rescan t) |
914 (erase-buffer) | 919 (erase-buffer) |
915 (message "Building list...done") | 920 (message "Building list...done") |
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. |
938 Don't check spelling of message headers or included messages. | |
939 | |
940 To spell-check whenever a message is sent, include this line in .emacs: | |
941 (setq news-inews-hook (setq mail-send-hook 'ispell-message)) | |
942 | |
943 Or 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 |
946 ;;; ispell.el ends here | 1003 ;;; ispell.el ends here |