Mercurial > emacs
changeset 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 | 76fb8b35df3f |
children | 24bb9fff22ce |
files | lisp/textmodes/=ispell4.el |
diffstat | 1 files changed, 81 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/textmodes/=ispell4.el Sun Nov 07 22:19:57 1993 +0000 +++ b/lisp/textmodes/=ispell4.el Sun Nov 07 22:45:42 1993 +0000 @@ -314,7 +314,8 @@ (setq ispell-bad-words (nreverse bad-words)))) (cond ((not (markerp (car ispell-bad-words))) (setq ispell-bad-words nil) - (message "No misspellings.")) + (message "No misspellings.") + t) (t (message "Ispell parsing done.") (ispell-next)))) @@ -323,11 +324,12 @@ (defalias 'ispell-buffer 'ispell) (defun ispell-next () - "Resume command loop for most recent Ispell command." + "Resume command loop for most recent Ispell command. +Return value is t unless exit is due to typing `q'." (interactive) (setq ispell-window-configuration nil) (unwind-protect - (catch 'quit + (catch 'ispell-quit ;; There used to be a save-excursion here, ;; but that was annoying: it's better if point doesn't move ;; when you type q. @@ -337,7 +339,8 @@ (push-mark) (ispell-point next "at saved position.") (setq ispell-bad-words (cdr ispell-bad-words)) - (set-marker next nil)))) + (set-marker next nil))) + t) (if ispell-window-configuration (set-window-configuration ispell-window-configuration)) (cond ((null ispell-bad-words) @@ -365,7 +368,7 @@ (if resume (ispell-next) (condition-case err - (catch 'quit + (catch 'ispell-quit (save-window-excursion (ispell-point (point) "at point.")) (ispell-dump)) @@ -544,7 +547,9 @@ (ispell-replace start end replacement) (setq flag nil)) ((= c ?q) - (throw 'quit nil)) + (throw 'ispell-quit nil)) + ((= c quit-char) + (keyboard-quit)) ((= c ? ) (setq flag nil)) ((= c ?r) @@ -916,30 +921,82 @@ ;; Make the list into an alist and return. (mapcar 'list (nreverse list))))) + +;; Return regexp-quote of STRING if STRING is non-empty. +;; Otherwise return an unmatchable regexp. +(defun ispell-non-empty-string (string) + (if (or (not string) (string-equal string "")) + "\\'\\`" ; An unmatchable string if string is null. + (regexp-quote string))) -(defvar ispell-message-cite-regexp "^ " +(defvar ispell-message-cite-regexp "^ \\|^\t" "*Regular expression to match lines cited from one message into another.") +;;;###autoload (defun ispell-message () - "Check the spelling for an outgoing mail message." + "Check the spelling of a mail message or news post. +Don't check spelling of message headers or included messages. + +To spell-check whenever a message is sent, include this line in .emacs: + (setq news-inews-hook (setq mail-send-hook 'ispell-message)) + +Or you can bind the function to C-c i in gnus or mail with: + (setq mail-mode-hook (setq news-reply-mode-hook + (function (lambda () (local-set-key \"\\C-ci\" 'ispell-message)))))" (interactive) (save-excursion - (beginning-of-buffer) - ;; Don't spell-check the headers. - (search-forward mail-header-separator nil t) - (while (not (eobp)) - ;; Skip across text cited from other messages. - (while (and (looking-at (concat "^[ \t]*$\\|" - ispell-message-cite-regexp)) - (not (eobp))) - (forward-line 1)) - (if (not (eobp)) - ;; Fill the next batch of lines that *aren't* cited. - (let ((start (point))) - (re-search-forward - (concat "^\\(" ispell-message-cite-regexp "\\)") nil 'end) - (beginning-of-line) - (save-excursion (ispell-region (- start 1) (point)))))))) + (let (non-internal-message) + (goto-char (point-min)) + ;; Don't spell-check the headers. + (if (search-forward mail-header-separator nil t) + ;; Move to first body line. + (forward-line 1) + (while (and (looking-at "[a-zA-Z-]+:\\|\t\\| ") + (not (eobp))) + (forward-line 1)) + (setq non-internal-message t) + ) + (let ((cite-regexp ;Prefix of inserted text + (cond + ((featurep 'supercite) ; sc 3.0 + (concat "\\(" (sc-cite-regexp) "\\)" "\\|" + (ispell-non-empty-string sc-reference-tag-string))) + ((featurep 'sc) ; sc 2.3 + (concat "\\(" sc-cite-regexp "\\)" "\\|" + (ispell-non-empty-string sc-reference-tag-string))) + (non-internal-message ; Assume nn sent us this message. + (concat "In [a-zA-Z.]+ you write:" "\\|" + "In <[^,;&+=]+> [^,;&+=]+ writes:" "\\|" + " *> *")) + ((equal major-mode 'news-reply-mode) ;Gnus + (concat "In article <" "\\|" + (ispell-non-empty-string mail-yank-prefix) + )) + ((boundp 'vm-included-text-prefix) ; VM mail message + (concat "[^,;&+=]+ writes:" "\\|" + (ispell-non-empty-string vm-included-text-prefix) + )) + ((boundp 'mh-ins-buf-prefix) ; mh mail message + (ispell-non-empty-string mh-ins-buf-prefix)) + (mail-yank-prefix ; vanilla mail message. + (ispell-non-empty-string mail-yank-prefix)) + (t ispell-message-cite-regexp))) + (continue t)) + + (while (and (not (eobp)) continue) + ;; Skip across text cited from other messages. + (while (and (looking-at (concat "^[ \t]*$\\|" cite-regexp)) + (not (eobp))) + (forward-line 1)) + (if (not (eobp)) + ;; Fill the next batch of lines that *aren't* cited. + (let ((start (point))) + (if (re-search-forward + (concat "^\\(" cite-regexp "\\)") nil 'end) + (beginning-of-line)) + (beginning-of-line) + (save-excursion + (setq continue (ispell-region (- start 1) (point))))))))))) (provide 'ispell)