X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=lisp%2Fmessage.el;h=0a32d12f5910859d6973be6b391aa9e596f53650;hb=625b891fc07e1e5fc5f2658176b6c0e3cb244ee0;hp=f0eb4817377a377b31790e225630f23b301b5304;hpb=9b2fb1b90d4ff43730e19ffbfd10f5f91f98a2e9;p=elisp%2Fgnus.git- diff --git a/lisp/message.el b/lisp/message.el index f0eb481..0a32d12 100644 --- a/lisp/message.el +++ b/lisp/message.el @@ -169,7 +169,8 @@ Don't touch this variable unless you really know what you're doing. Checks include subject-cmsg multiple-headers sendsys message-id from long-lines control-chars size new-text redirected-followup signature approved sender empty empty-headers message-id from subject -shorten-followup-to existing-newsgroups buffer-file-name unchanged." +shorten-followup-to existing-newsgroups buffer-file-name unchanged +newsgroups." :group 'message-news) (defcustom message-required-news-headers @@ -860,12 +861,7 @@ The cdr of ech entry is a function for applying the face to a region.") "Coding system to encode outgoing mail.") (defvar message-draft-coding-system - (cond - ((not (fboundp 'coding-system-p)) nil) - ((coding-system-p 'emacs-mule) 'emacs-mule) - ((memq 'escape-quoted (mm-get-coding-system-list)) 'escape-quoted) - ((coding-system-p 'no-conversion) 'no-conversion) - (t nil)) + mm-auto-save-coding-system "Coding system to compose mail.") ;;; Internal variables. @@ -1320,7 +1316,7 @@ Point is left at the beginning of the narrowed-to region." ["Newline and Reformat" message-newline-and-reformat t] ["Rename buffer" message-rename-buffer t] ["Spellcheck" ispell-message t] - ["Attach file as MIME" message-mime-attach-file t] + ["Attach file as MIME" mml-attach-file t] "----" ["Send Message" message-send-and-exit t] ["Abort Message" message-dont-send t] @@ -1352,6 +1348,7 @@ Point is left at the beginning of the narrowed-to region." "Major mode for editing mail and news to be sent. Like Text Mode but with these additional commands: C-c C-s message-send (send the message) C-c C-c message-send-and-exit +C-c C-d Pospone sending the message C-c C-k Kill the message C-c C-f move to a header field (and create it if there isn't): C-c C-f C-t move to To C-c C-f C-s move to Subject C-c C-f C-c move to Cc C-c C-f C-b move to Bcc @@ -1523,7 +1520,7 @@ C-c C-a mml-attach-file (attach a file as MIME)." "Move point to the end of the headers." (interactive) (message-goto-body) - (forward-line -2)) + (forward-line -1)) (defun message-goto-signature () "Move point to the beginning of the message signature. @@ -1761,7 +1758,7 @@ Numeric argument means justify as well." (goto-char (point-min)) (search-forward (concat "\n" mail-header-separator "\n") nil t) (let ((fill-prefix message-yank-prefix)) - (fill-individual-paragraphs (point) (point-max) justifyp t)))) + (fill-individual-paragraphs (point) (point-max) justifyp)))) (defun message-indent-citation () "Modify text just inserted from a message to be cited. @@ -2013,6 +2010,8 @@ the user from the mailer." (car elem)))) (setq success (funcall (caddr elem) arg))))) (setq sent t))) + (unless sent + (error "No methods specified to send by")) (when (and success sent) (message-do-fcc) ;;(when (fboundp 'mail-hist-put-headers-into-history) @@ -2088,14 +2087,12 @@ the user from the mailer." (case-fold-search nil) (news (message-news-p)) (mailbuf (current-buffer))) - (message-encode-message-body) (save-restriction (message-narrow-to-headers) ;; Insert some headers. (let ((message-deletable-headers (if news nil message-deletable-headers))) (message-generate-headers message-required-mail-headers)) - (mail-encode-encoded-word-buffer) ;; Let the user do all of the above. (run-hooks 'message-header-hook)) (unwind-protect @@ -2108,10 +2105,15 @@ the user from the mailer." (set-buffer mailbuf) (buffer-string)))) ;; Remove some headers. + (message-encode-message-body) (save-restriction (message-narrow-to-headers) + ;; We (re)generate the Lines header. + (when (memq 'Lines message-required-mail-headers) + (message-generate-headers '(Lines))) ;; Remove some headers. - (message-remove-header message-ignored-mail-headers t)) + (message-remove-header message-ignored-mail-headers t) + (mail-encode-encoded-word-buffer)) (goto-char (point-max)) ;; require one newline at the end. (or (= (preceding-char) ?\n) @@ -2264,13 +2266,10 @@ to find out how to use this." result) (if (not (message-check-news-body-syntax)) nil - (message-encode-message-body) (save-restriction (message-narrow-to-headers) ;; Insert some headers. (message-generate-headers message-required-news-headers) - (let ((mail-parse-charset message-posting-charset)) - (mail-encode-encoded-word-buffer)) ;; Let the user do all of the above. (run-hooks 'message-header-hook)) (message-cleanup-headers) @@ -2286,11 +2285,17 @@ to find out how to use this." "%s" (save-excursion (set-buffer messbuf) (buffer-string)))) + (message-encode-message-body) ;; Remove some headers. (save-restriction (message-narrow-to-headers) + ;; We (re)generate the Lines header. + (when (memq 'Lines message-required-mail-headers) + (message-generate-headers '(Lines))) ;; Remove some headers. - (message-remove-header message-ignored-news-headers t)) + (message-remove-header message-ignored-news-headers t) + (let ((mail-parse-charset message-posting-charset)) + (mail-encode-encoded-word-buffer))) (goto-char (point-max)) ;; require one newline at the end. (or (= (preceding-char) ?\n) @@ -2339,6 +2344,15 @@ to find out how to use this." (defun message-check-news-header-syntax () (and + ;; Check Newsgroups header. + (message-check 'newsgroyps + (let ((group (message-fetch-field "newsgroups"))) + (or + (and group + (not (string-match "\\`[ \t]*\\'" group))) + (ignore + (message + "The newsgroups field is empty or missing. Posting is denied."))))) ;; Check the Subject header. (message-check 'subject (let* ((case-fold-search t) @@ -2501,12 +2515,15 @@ to find out how to use this." (message-check 'from (let* ((case-fold-search t) (from (message-fetch-field "from")) - (ad (nth 1 (mail-extract-address-components from)))) + ad) (cond ((not from) (message "There is no From line. Posting is denied.") nil) - ((or (not (string-match "@[^\\.]*\\." ad)) ;larsi@ifi + ((or (not (string-match + "@[^\\.]*\\." + (setq ad (nth 1 (mail-extract-address-components + from))))) ;larsi@ifi (string-match "\\.\\." ad) ;larsi@ifi..uio (string-match "@\\." ad) ;larsi@.ifi.uio (string-match "\\.$" ad) ;larsi@ifi.uio. @@ -2684,7 +2701,7 @@ If NOW, use that time instead." parse-time-months)))) (format-time-string "%Y %H:%M:%S " now) ;; We do all of this because XEmacs doesn't have the %z spec. - (format "%s%02d%02d" sign (/ zone 3600) (% zone 3600))))) + (format "%s%02d%02d" sign (/ zone 3600) (/ (% zone 3600) 60))))) (defun message-make-message-id () "Make a unique Message-ID." @@ -2988,7 +3005,7 @@ Headers already prepared in the buffer are not modified." ;; colon, if there is none. (if (/= (char-after) ? ) (insert " ") (forward-char 1)) ;; Find out whether the header is empty... - (looking-at "[ \t]*$"))) + (looking-at "[ \t]*\n[^ \t]"))) ;; So we find out what value we should insert. (setq value (cond @@ -3375,6 +3392,7 @@ OTHER-HEADERS is an alist of header/value pairs." from subject date reply-to to cc references message-id follow-to (inhibit-point-motion-hooks t) + (message-this-is-mail t) mct never-mct gnus-warning) (save-restriction (message-narrow-to-head) @@ -3830,7 +3848,8 @@ Optional NEWS will use news to forward instead of mail." (when (looking-at "From ") (replace-match "X-From-Line: ")) ;; Send it. - (let (message-required-mail-headers) + (let ((message-inhibit-body-encoding t) + message-required-mail-headers) (message-send-mail)) (kill-buffer (current-buffer))) (message "Resending message to %s...done" address))) @@ -3842,33 +3861,27 @@ This only makes sense if the current message is a bounce message than contains some mail you have written which has been bounced back to you." (interactive) - (let ((cur (current-buffer)) + (let ((handles (mm-dissect-buffer)) boundary) (message-pop-to-buffer (message-buffer-name "bounce")) - (insert-buffer-substring cur) - (undo-boundary) - (message-narrow-to-head) - (if (and (message-fetch-field "Mime-Version") - (setq boundary (message-fetch-field "Content-Type"))) - (if (string-match "boundary=\"\\([^\"]+\\)\"" boundary) - (setq boundary (concat (match-string 1 boundary) " *\n" - "Content-Type: message/rfc822")) - (setq boundary nil))) - (widen) - (goto-char (point-min)) - (search-forward "\n\n" nil t) - (or (and boundary - (re-search-forward boundary nil t) - (forward-line 2)) - (and (re-search-forward message-unsent-separator nil t) - (forward-line 1)) - (re-search-forward "^Return-Path:.*\n" nil t)) - ;; We remove everything before the bounced mail. - (delete-region - (point-min) - (if (re-search-forward "^[^ \n\t]+:" nil t) - (match-beginning 0) - (point))) + (if (stringp (car handles)) + ;; This is a MIME bounce. + (mm-insert-part (car (last handles))) + ;; This is a non-MIME bounce, so we try to remove things + ;; manually. + (mm-insert-part (car (last handles))) + (undo-boundary) + (goto-char (point-min)) + (search-forward "\n\n" nil t) + (or (and (re-search-forward message-unsent-separator nil t) + (forward-line 1)) + (re-search-forward "^Return-Path:.*\n" nil t)) + ;; We remove everything before the bounced mail. + (delete-region + (point-min) + (if (re-search-forward "^[^ \n\t]+:" nil t) + (match-beginning 0) + (point)))) (save-restriction (message-narrow-to-head) (message-remove-header message-ignored-bounced-headers t) @@ -4105,10 +4118,10 @@ regexp varstr." ;;; MIME functions ;;; -(defvar messgage-inhibit-body-encoding nil) +(defvar message-inhibit-body-encoding nil) (defun message-encode-message-body () - (unless messgage-inhibit-body-encoding + (unless message-inhibit-body-encoding (let ((mail-parse-charset (or mail-parse-charset message-default-charset message-posting-charset))