comparison lisp/vm/vm-reply.el @ 70:131b0175ea99 r20-0b30

Import from CVS: tag r20-0b30
author cvs
date Mon, 13 Aug 2007 09:02:59 +0200
parents 05472e90ae02
children c0c698873ce1
comparison
equal deleted inserted replaced
69:804d1389bcd6 70:131b0175ea99
1 ;;; Mailing, forwarding, and replying commands for VM 1 ;;; Mailing, forwarding, and replying commands for VM
2 ;;; Copyright (C) 1989-1997 Kyle E. Jones 2 ;;; Copyright (C) 1989, 1990, 1991, 1993, 1994, 1995 Kyle E. Jones
3 ;;; 3 ;;;
4 ;;; This program is free software; you can redistribute it and/or modify 4 ;;; This program is free software; you can redistribute it and/or modify
5 ;;; it under the terms of the GNU General Public License as published by 5 ;;; it under the terms of the GNU General Public License as published by
6 ;;; the Free Software Foundation; either version 1, or (at your option) 6 ;;; the Free Software Foundation; either version 1, or (at your option)
7 ;;; any later version. 7 ;;; any later version.
27 (while mp 27 (while mp
28 (cond 28 (cond
29 ((eq mlist mp) 29 ((eq mlist mp)
30 (cond ((setq to 30 (cond ((setq to
31 (let ((reply-to 31 (let ((reply-to
32 (vm-get-header-contents (car mp) "Reply-To:" 32 (vm-get-header-contents (car mp) "Reply-To:")))
33 ", ")))
34 (if (vm-ignored-reply-to reply-to) 33 (if (vm-ignored-reply-to reply-to)
35 nil 34 nil
36 reply-to )))) 35 reply-to ))))
37 ((setq to (vm-get-header-contents (car mp) "From:" ", "))) 36 ((setq to (vm-get-header-contents (car mp) "From:")))
38 ;; bad, but better than nothing for some 37 ;; bad, but better than nothing for some
39 ((setq to (vm-grok-From_-author (car mp)))) 38 ((setq to (vm-grok-From_-author (car mp))))
40 (t (error "No From: or Reply-To: header in message"))) 39 (t (error "No From: or Reply-To: header in message")))
41 (setq subject (vm-get-header-contents (car mp) "Subject:") 40 (setq subject (vm-get-header-contents (car mp) "Subject:")
42 in-reply-to 41 in-reply-to
50 (equal 49 (equal
51 (string-match (regexp-quote vm-reply-subject-prefix) 50 (string-match (regexp-quote vm-reply-subject-prefix)
52 subject) 51 subject)
53 0))) 52 0)))
54 (setq subject (concat vm-reply-subject-prefix subject)))) 53 (setq subject (concat vm-reply-subject-prefix subject))))
55 (t (cond ((setq tmp (vm-get-header-contents (car mp) "Reply-To:" 54 (t (cond ((setq tmp (vm-get-header-contents (car mp) "Reply-To:"))
56 ", "))
57 (setq to (concat to "," tmp))) 55 (setq to (concat to "," tmp)))
58 ((setq tmp (vm-get-header-contents (car mp) "From:" 56 ((setq tmp (vm-get-header-contents (car mp) "From:"))
59 ", "))
60 (setq to (concat to "," tmp))) 57 (setq to (concat to "," tmp)))
61 ;; bad, but better than nothing for some 58 ;; bad, but better than nothing for some
62 ((setq tmp (vm-grok-From_-author (car mp))) 59 ((setq tmp (vm-grok-From_-author (car mp)))
63 (setq to (concat to "," tmp))) 60 (setq to (concat to "," tmp)))
64 (t (error "No From: or Reply-To: header in message"))))) 61 (t (error "No From: or Reply-To: header in message")))))
65 (if to-all 62 (if to-all
66 (progn 63 (progn
67 (setq tmp (vm-get-header-contents (car mp) "To:" 64 (setq tmp (vm-get-header-contents (car mp) "To:"))
68 ", ")) 65 (setq tmp2 (vm-get-header-contents (car mp) "Cc:"))
69 (setq tmp2 (vm-get-header-contents (car mp) "Cc:"
70 ", "))
71 (if tmp 66 (if tmp
72 (if cc 67 (if cc
73 (setq cc (concat cc "," tmp)) 68 (setq cc (concat cc "," tmp))
74 (setq cc tmp))) 69 (setq cc tmp)))
75 (if tmp2 70 (if tmp2
76 (if cc 71 (if cc
77 (setq cc (concat cc "," tmp2)) 72 (setq cc (concat cc "," tmp2))
78 (setq cc tmp2))))) 73 (setq cc tmp2)))))
79 (setq references 74 (setq references
80 (cons (vm-get-header-contents (car mp) "References:" " ") 75 (cons (vm-get-header-contents (car mp) "References:")
81 (cons (vm-get-header-contents (car mp) "In-reply-to:" " ") 76 (cons (vm-get-header-contents (car mp) "In-reply-to:")
82 (cons (vm-get-header-contents (car mp) "Message-ID:" 77 (cons (vm-get-header-contents (car mp) "Message-ID:")
83 " ")
84 references)))) 78 references))))
85 (setq newsgroups 79 (setq newsgroups
86 (cons (or (and to-all (vm-get-header-contents (car mp) "Followup-To:" ",")) 80 (cons (or (and to-all (vm-get-header-contents (car mp) "Followup-To:"))
87 (vm-get-header-contents (car mp) "Newsgroups:" ",")) 81 (vm-get-header-contents (car mp) "Newsgroups:"))
88 newsgroups)) 82 newsgroups))
89 (setq mp (cdr mp))) 83 (setq mp (cdr mp)))
90 (if vm-strip-reply-headers 84 (if vm-strip-reply-headers
91 (let ((mail-use-rfc822 t)) 85 (let ((mail-use-rfc822 t))
92 (and to (setq to (mail-strip-quoted-names to))) 86 (and to (setq to (mail-strip-quoted-names to)))
128 (let ((case-fold-search nil)) 122 (let ((case-fold-search nil))
129 (re-search-forward 123 (re-search-forward
130 (concat "^" (regexp-quote mail-header-separator) "$") nil 0)) 124 (concat "^" (regexp-quote mail-header-separator) "$") nil 0))
131 (forward-char 1) 125 (forward-char 1)
132 (while mlist 126 (while mlist
133 (save-restriction 127 (vm-yank-message (car mlist))
134 (narrow-to-region (point) (point)) 128 (goto-char (point-max))
135 (vm-yank-message (car mlist))
136 (goto-char (point-max)))
137 (setq mlist (cdr mlist))))) 129 (setq mlist (cdr mlist)))))
138 (run-hooks 'vm-reply-hook) 130 (run-hooks 'vm-reply-hook)
139 (run-hooks 'vm-mail-mode-hook))) 131 (run-hooks 'vm-mail-mode-hook)))
140 132
141 (defun vm-strip-ignored-addresses (addresses) 133 (defun vm-strip-ignored-addresses (addresses)
198 (let ((b (current-buffer)) newbuf sumbuf default result prompt mp) 190 (let ((b (current-buffer)) newbuf sumbuf default result prompt mp)
199 (set-buffer (or (vm-get-file-buffer folder) (find-file-noselect folder))) 191 (set-buffer (or (vm-get-file-buffer folder) (find-file-noselect folder)))
200 (setq newbuf (current-buffer)) 192 (setq newbuf (current-buffer))
201 (if (not (eq major-mode 'vm-mode)) 193 (if (not (eq major-mode 'vm-mode))
202 (vm-mode)) 194 (vm-mode))
203 (if vm-presentation-buffer-handle
204 (vm-bury-buffer vm-presentation-buffer-handle))
205 (if (null vm-message-pointer) 195 (if (null vm-message-pointer)
206 (error "No messages in folder %s" folder)) 196 (error "No messages in folder %s" folder))
207 (setq default (vm-number-of (car vm-message-pointer))) 197 (setq default (vm-number-of (car vm-message-pointer)))
208 (save-excursion 198 (save-excursion
209 (save-window-excursion 199 (save-window-excursion
283 (setq message (vm-real-message-of message)) 273 (setq message (vm-real-message-of message))
284 (let ((b (current-buffer)) (start (point)) end) 274 (let ((b (current-buffer)) (start (point)) end)
285 (save-restriction 275 (save-restriction
286 (widen) 276 (widen)
287 (save-excursion 277 (save-excursion
288 (if (vectorp (vm-mm-layout message)) 278 (set-buffer (vm-buffer-of message))
289 (let* ((o (vm-mm-layout message)) 279 (save-restriction
290 (type (car (vm-mm-layout-type o))) 280 (widen)
291 parts) 281 (append-to-buffer b (vm-headers-of message) (vm-text-end-of message))
292 (vm-insert-region-from-buffer (vm-buffer-of message) 282 (setq end (vm-marker (+ start (- (vm-text-end-of message)
293 (vm-headers-of message) 283 (vm-headers-of message))) b))))
294 (vm-text-of message))
295 (cond ((vm-mime-types-match "multipart" type)
296 (setq parts (copy-sequence (vm-mm-layout-parts o))))
297 (t (setq parts (list o))))
298 (while parts
299 (cond ((vm-mime-text-type-p (car parts))
300 (if (cond ((vm-mime-types-match
301 "text/html"
302 (car (vm-mm-layout-type (car parts))))
303 (vm-mime-display-internal-text/html
304 (car parts)))
305 ((vm-mime-types-match
306 "text/enriched"
307 (car (vm-mm-layout-type (car parts))))
308 (vm-mime-display-internal-text/enriched
309 (car parts)))
310 ((vm-mime-display-internal-text/plain
311 (car parts) t)))
312 nil
313 ;; charset problems probably
314 ;; just dump the raw bits
315 (vm-mime-insert-mime-body (car parts))
316 (vm-mime-transfer-decode-region (car parts)
317 start (point)))
318 (setq parts (cdr parts)))
319 ((vm-mime-composite-type-p
320 (car (vm-mm-layout-type (car parts))))
321 (setq parts (nconc (copy-sequence
322 (vm-mm-layout-parts
323 (car parts)))
324 (cdr parts))))
325 (t (setq parts (cdr parts)))))
326 (setq end (point-marker)))
327 (set-buffer (vm-buffer-of message))
328 (save-restriction
329 (widen)
330 (append-to-buffer b (vm-headers-of message)
331 (vm-text-end-of message))
332 (setq end (vm-marker (+ start (- (vm-text-end-of message)
333 (vm-headers-of message))) b)))))
334 (push-mark end) 284 (push-mark end)
335 (cond (mail-citation-hook (run-hooks 'mail-citation-hook)) 285 (cond (mail-citation-hook (run-hooks 'mail-citation-hook))
336 (mail-yank-hooks (run-hooks 'mail-yank-hooks)) 286 (mail-yank-hooks (run-hooks 'mail-yank-hooks))
337 (t (vm-mail-yank-default message)))))) 287 (t (vm-mail-yank-default message))))))
338 288
339 (defun vm-mail-send-and-exit (arg) 289 (defun vm-mail-send-and-exit (arg)
340 "Just like mail-send-and-exit except that VM flags the appropriate message(s) 290 "Just like mail-send-and-exit except that VM flags the appropriate message(s)
341 as having been replied to, if appropriate." 291 as having been replied to, if appropriate."
342 (interactive "P") 292 (interactive "P")
343 (vm-check-for-killed-folder)
344 (let ((b (current-buffer))) 293 (let ((b (current-buffer)))
345 (vm-mail-send) 294 (vm-mail-send)
346 (cond ((null (buffer-name b)) ;; dead buffer 295 (cond ((null (buffer-name b)) ;; dead buffer
347 ;; This improves window configuration behavior in
348 ;; XEmacs. It avoids taking the folder buffer from
349 ;; one frame and attaching it to the selected frame.
350 (set-buffer (window-buffer (selected-window)))
351 (vm-display nil nil '(vm-mail-send-and-exit) 296 (vm-display nil nil '(vm-mail-send-and-exit)
352 '(vm-mail-send-and-exit 297 '(vm-mail-send-and-exit reading-message startup)))
353 reading-message
354 startup)))
355 (t 298 (t
356 (vm-display b nil '(vm-mail-send-and-exit) 299 (vm-display b nil '(vm-mail-send-and-exit)
357 '(vm-mail-send-and-exit reading-message startup)) 300 '(vm-mail-send-and-exit reading-message startup))
358 (vm-bury-buffer b))))) 301 (vm-bury-buffer b)))))
359 302
368 (if (not (eq vm-keep-sent-messages t)) 311 (if (not (eq vm-keep-sent-messages t))
369 (let ((extras (nthcdr (or vm-keep-sent-messages 0) 312 (let ((extras (nthcdr (or vm-keep-sent-messages 0)
370 vm-kept-mail-buffers))) 313 vm-kept-mail-buffers)))
371 (mapcar (function 314 (mapcar (function
372 (lambda (b) 315 (lambda (b)
373 (and (buffer-name b) 316 (and (buffer-name b) (kill-buffer b))))
374 (not (buffer-modified-p b))
375 (kill-buffer b))))
376 extras) 317 extras)
377 (and vm-kept-mail-buffers extras 318 (and vm-kept-mail-buffers extras
378 (setcdr (memq (car extras) vm-kept-mail-buffers) nil))))) 319 (setcdr (memq (car extras) vm-kept-mail-buffers) nil)))))
379 320
380 (defun vm-help-tale () 321 (defun vm-help-tale ()
394 "Just like mail-send except that VM flags the appropriate message(s) 335 "Just like mail-send except that VM flags the appropriate message(s)
395 as replied to, forwarded, etc, if appropriate." 336 as replied to, forwarded, etc, if appropriate."
396 (interactive) 337 (interactive)
397 (if vm-tale-is-an-idiot 338 (if vm-tale-is-an-idiot
398 (vm-help-tale)) 339 (vm-help-tale))
399 ;; protect value of this-command from minibuffer read 340 (if (and vm-confirm-mail-send
400 (let ((this-command this-command)) 341 (not (y-or-n-p "Send the message? ")))
401 (if (and vm-confirm-mail-send 342 (error "Message not sent."))
402 (not (y-or-n-p "Send the message? ")))
403 (error "Message not sent.")))
404 ;; send mail using MIME if user requests it and if the buffer
405 ;; has not already been MIME encoded.
406 (if (and vm-send-using-mime
407 (null (vm-mail-mode-get-header-contents "MIME-Version:")))
408 (vm-mime-encode-composition))
409 ;; this to prevent Emacs 19 from asking whether a message that 343 ;; this to prevent Emacs 19 from asking whether a message that
410 ;; has already been sent should be sent again. VM renames mail 344 ;; has already been sent should be sent again. VM renames mail
411 ;; buffers after the message has been sent, so the user should 345 ;; buffers after the message has been sent, so the user should
412 ;; already know that the message has been sent. 346 ;; already know that the message has been sent.
413 (set-buffer-modified-p t) 347 (set-buffer-modified-p t)
414 (let ((composition-buffer (current-buffer)) 348 ;; don't want a buffer change to occur here
415 ;; preserve these in case the composition buffer gets 349 ;; save-excursion to be sure.
416 ;; killed. 350 (save-excursion
417 (vm-reply-list vm-reply-list) 351 (mail-send))
418 (vm-forward-list vm-forward-list) 352 (vm-rename-current-mail-buffer)
419 (vm-redistribute-list vm-redistribute-list)) 353 (cond ((eq vm-system-state 'replying)
420 ;; fragment message using message/partial if it is too big. 354 (vm-mail-mark-replied))
421 (if (and vm-send-using-mime 355 ((eq vm-system-state 'forwarding)
422 (integerp vm-mime-max-message-size) 356 (vm-mail-mark-forwarded))
423 (> (buffer-size) vm-mime-max-message-size)) 357 ((eq vm-system-state 'redistributing)
424 (let (list) 358 (vm-mail-mark-redistributed)))
425 (setq list (vm-mime-fragment-composition vm-mime-max-message-size)) 359 (vm-keep-mail-buffer (current-buffer))
426 (while list 360 (vm-display nil nil '(vm-mail-send) '(vm-mail-send)))
427 (save-excursion
428 (set-buffer (car list))
429 (vm-mail-send)
430 (kill-buffer (car list)))
431 (setq list (cdr list)))
432 ;; what mail-send would have done
433 (set-buffer-modified-p nil))
434 ;; don't want a buffer change to occur here
435 ;; save-excursion to be sure.
436 ;;
437 ;; also protect value of this-command from minibuffer reads
438 (let ((this-command this-command))
439 (save-excursion
440 (mail-send))))
441 ;; be careful, something could have killed the composition
442 ;; buffer inside mail-send.
443 (if (eq (current-buffer) composition-buffer)
444 (progn
445 (cond ((eq vm-system-state 'replying)
446 (vm-mail-mark-replied))
447 ((eq vm-system-state 'forwarding)
448 (vm-mail-mark-forwarded))
449 ((eq vm-system-state 'redistributing)
450 (vm-mail-mark-redistributed)))
451 (vm-rename-current-mail-buffer)
452 (vm-keep-mail-buffer (current-buffer))))
453 (vm-display nil nil '(vm-mail-send) '(vm-mail-send))))
454
455 (defun vm-mail-mode-get-header-contents (header-name-regexp)
456 (let ((contents nil)
457 regexp)
458 (setq regexp (concat "^\\(" header-name-regexp "\\)\\|\\(^"
459 (regexp-quote mail-header-separator) "$\\)"))
460 (save-excursion
461 (save-restriction
462 (widen)
463 (goto-char (point-min))
464 (let ((case-fold-search t))
465 (if (and (re-search-forward regexp nil t)
466 (match-beginning 1)
467 (progn (goto-char (match-beginning 0))
468 (vm-match-header)))
469 (vm-matched-header-contents)
470 nil ))))))
471 361
472 (defun vm-rename-current-mail-buffer () 362 (defun vm-rename-current-mail-buffer ()
473 (if vm-rename-current-buffer-function 363 (if vm-rename-current-buffer-function
474 (funcall vm-rename-current-buffer-function) 364 (funcall vm-rename-current-buffer-function)
475 (let ((case-fold-search nil)) 365 (let ((case-fold-search nil))
593 483
594 (defun vm-forward-message-all-headers () 484 (defun vm-forward-message-all-headers ()
595 "Like vm-forward-message but always forwards all the headers." 485 "Like vm-forward-message but always forwards all the headers."
596 (interactive) 486 (interactive)
597 (let ((vm-forwarded-headers nil) 487 (let ((vm-forwarded-headers nil)
598 (vm-unforwarded-header-regexp "only-drop-this-header") 488 (vm-unforwarded-header-regexp "only-drop-this-header"))
599 ;; set these because vm-forward-message calls vm-send-digest
600 ;; if there is more than one message to be forwarded.
601 (vm-rfc934-digest-headers nil)
602 (vm-rfc934-digest-discard-header-regexp "only-drop-this-header")
603 (vm-rfc1153-digest-headers nil)
604 (vm-rfc1153-digest-discard-header-regexp "only-drop-this-header")
605 (vm-mime-digest-headers nil)
606 (vm-mime-digest-discard-header-regexp "only-drop-this-header"))
607 (vm-forward-message))) 489 (vm-forward-message)))
608 490
609 (defun vm-forward-message () 491 (defun vm-forward-message ()
610 "Forward the current message to one or more recipients. 492 "Forward the current message to one or more recipients.
611 You will be placed in a Mail mode buffer as you would with a 493 You will be placed in a Mail mode buffer as you would with a
614 (interactive) 496 (interactive)
615 (vm-follow-summary-cursor) 497 (vm-follow-summary-cursor)
616 (vm-select-folder-buffer) 498 (vm-select-folder-buffer)
617 (vm-check-for-killed-summary) 499 (vm-check-for-killed-summary)
618 (vm-error-if-folder-empty) 500 (vm-error-if-folder-empty)
619 (if (and (eq last-command 'vm-next-command-uses-marks) 501 (if (eq last-command 'vm-next-command-uses-marks)
620 (cdr (vm-select-marked-or-prefixed-messages 0)))
621 (let ((vm-digest-send-type vm-forwarding-digest-type)) 502 (let ((vm-digest-send-type vm-forwarding-digest-type))
622 (setq this-command 'vm-next-command-uses-marks) 503 (setq this-command 'vm-next-command-uses-marks)
623 (command-execute 'vm-send-digest)) 504 (command-execute 'vm-send-digest))
624 (let ((dir default-directory) 505 (let ((dir default-directory)
625 (miming (and vm-send-using-mime 506 (mp vm-message-pointer))
626 (equal vm-forwarding-digest-type "mime")))
627 mail-buffer
628 header-end
629 (mp (vm-select-marked-or-prefixed-messages 1)))
630 (save-restriction 507 (save-restriction
631 (widen) 508 (widen)
632 (vm-mail-internal 509 (vm-mail-internal
633 (format "forward of %s's note re: %s" 510 (format "forward of %s's note re: %s"
634 (vm-su-full-name (car vm-message-pointer)) 511 (vm-su-full-name (car vm-message-pointer))
639 (vm-sprintf 'vm-forwarding-subject-format (car mp))))) 516 (vm-sprintf 'vm-forwarding-subject-format (car mp)))))
640 (make-local-variable 'vm-forward-list) 517 (make-local-variable 'vm-forward-list)
641 (setq vm-system-state 'forwarding 518 (setq vm-system-state 'forwarding
642 vm-forward-list (list (car mp)) 519 vm-forward-list (list (car mp))
643 default-directory dir) 520 default-directory dir)
644 (if miming 521 (goto-char (point-min))
645 (progn 522 (re-search-forward
646 (setq mail-buffer (current-buffer)) 523 (concat "^" (regexp-quote mail-header-separator) "\n") nil 0)
647 (set-buffer (generate-new-buffer "*vm-forward-buffer*")) 524 (cond ((equal vm-forwarding-digest-type "rfc934")
648 (setq header-end (point))
649 (insert "\n"))
650 (goto-char (point-min))
651 (re-search-forward (concat "^" (regexp-quote mail-header-separator)
652 "\n"))
653 (goto-char (match-end 0))
654 (setq header-end (match-beginning 0)))
655 (cond ((equal vm-forwarding-digest-type "mime")
656 (vm-mime-encapsulate-messages (list (car mp))
657 vm-forwarded-headers
658 vm-unforwarded-header-regexp
659 nil)
660 (goto-char header-end)
661 (insert "MIME-Version: 1.0\n")
662 (insert "Content-Type: message/rfc822\n")
663 (insert "Content-Transfer-Encoding: "
664 (vm-determine-proper-content-transfer-encoding
665 (point)
666 (point-max))
667 "\n"))
668 ((equal vm-forwarding-digest-type "rfc934")
669 (vm-rfc934-encapsulate-messages 525 (vm-rfc934-encapsulate-messages
670 vm-forward-list vm-forwarded-headers 526 vm-forward-list vm-forwarded-headers
671 vm-unforwarded-header-regexp)) 527 vm-unforwarded-header-regexp))
672 ((equal vm-forwarding-digest-type "rfc1153") 528 ((equal vm-forwarding-digest-type "rfc1153")
673 (vm-rfc1153-encapsulate-messages 529 (vm-rfc1153-encapsulate-messages
674 vm-forward-list vm-forwarded-headers 530 vm-forward-list vm-forwarded-headers
675 vm-unforwarded-header-regexp)) 531 vm-unforwarded-header-regexp))
532 ((equal vm-forwarding-digest-type "rfc1521")
533 (vm-rfc1521-encapsulate-messages
534 vm-forward-list vm-forwarded-headers
535 vm-unforwarded-header-regexp))
676 ((equal vm-forwarding-digest-type nil) 536 ((equal vm-forwarding-digest-type nil)
677 (vm-no-frills-encapsulate-message 537 (vm-no-frills-encapsulate-message
678 (car vm-forward-list) vm-forwarded-headers 538 (car vm-forward-list) vm-forwarded-headers
679 vm-unforwarded-header-regexp))) 539 vm-unforwarded-header-regexp)))
680 (if miming
681 (let ((b (current-buffer)))
682 (set-buffer mail-buffer)
683 (mail-text)
684 (vm-mime-attach-object b "message/rfc822" nil nil t)
685 (add-hook 'kill-buffer-hook
686 (list 'lambda ()
687 (list 'if (list 'eq mail-buffer '(current-buffer))
688 (list 'kill-buffer b))))))
689 (mail-position-on-field "To")) 540 (mail-position-on-field "To"))
690 (run-hooks 'vm-forward-message-hook) 541 (run-hooks 'vm-forward-message-hook)
691 (run-hooks 'vm-mail-mode-hook)))) 542 (run-hooks 'vm-mail-mode-hook))))
692 543
693 (defun vm-resend-bounced-message () 544 (defun vm-resend-bounced-message ()
699 (vm-select-folder-buffer) 550 (vm-select-folder-buffer)
700 (vm-check-for-killed-summary) 551 (vm-check-for-killed-summary)
701 (vm-error-if-folder-empty) 552 (vm-error-if-folder-empty)
702 (let ((b (current-buffer)) start 553 (let ((b (current-buffer)) start
703 (dir default-directory) 554 (dir default-directory)
704 (layout (vm-mm-layout (car vm-message-pointer)))
705 (lim (vm-text-end-of (car vm-message-pointer)))) 555 (lim (vm-text-end-of (car vm-message-pointer))))
706 (save-restriction 556 (save-restriction
707 (widen) 557 (widen)
708 (if (or (not (vectorp layout)) 558 (save-excursion
709 (not (setq layout (vm-mime-layout-contains-type 559 (goto-char (vm-text-of (car vm-message-pointer)))
710 layout "message/rfc822")))) 560 (let ((case-fold-search t))
711 (save-excursion 561 ;; What a wonderful world it would be if mailers used a single
712 (goto-char (vm-text-of (car vm-message-pointer))) 562 ;; message encapsulation standard instead all the weird variants
713 (let ((case-fold-search t)) 563 ;; It is useless to try to cover them all.
714 ;; What a wonderful world it would be if mailers 564 ;; This simple rule should cover the sanest of the formats
715 ;; used a single message encapsulation standard 565 (if (not (re-search-forward "^Received:" lim t))
716 ;; instead of all the weird variants. It is 566 (error "This doesn't look like a bounced message."))
717 ;; useless to try to cover them all. This simple 567 (beginning-of-line)
718 ;; rule should cover the sanest of the formats 568 (setq start (point))))
719 (if (not (re-search-forward "^Received:" lim t))
720 (error "This doesn't look like a bounced message."))
721 (beginning-of-line)
722 (setq start (point)))))
723 ;; briefly nullify vm-mail-header-from to keep vm-mail-internal 569 ;; briefly nullify vm-mail-header-from to keep vm-mail-internal
724 ;; from inserting another From header. 570 ;; from inserting another From header.
725 (let ((vm-mail-header-from nil)) 571 (let ((vm-mail-header-from nil))
726 (vm-mail-internal 572 (vm-mail-internal
727 (format "retry of bounce from %s" 573 (format "retry of bounce from %s"
728 (vm-su-from (car vm-message-pointer))))) 574 (vm-su-from (car vm-message-pointer)))))
729 (goto-char (point-min)) 575 (goto-char (point-min))
730 (if (vectorp layout) 576 (insert-buffer-substring b start lim)
731 (progn
732 (setq start (point))
733 (vm-mime-insert-mime-body layout)
734 (vm-mime-transfer-decode-region layout start (point)))
735 (insert-buffer-substring b start lim))
736 (delete-region (point) (point-max)) 577 (delete-region (point) (point-max))
737 (goto-char (point-min)) 578 (goto-char (point-min))
738 ;; delete all but pertinent headers 579 ;; delete all but pertinent headers
739 (vm-reorder-message-headers nil nil "\\(X-VM-\\|Status:\\|Sender:\\)") 580 (vm-reorder-message-headers nil nil "\\(X-VM-\\|Status:\\|Sender:\\)")
740 (vm-reorder-message-headers nil vm-resend-bounced-headers 581 (vm-reorder-message-headers nil vm-resend-bounced-headers
741 vm-resend-bounced-discard-header-regexp) 582 vm-resend-bounced-discard-header-regexp)
742 (if (search-forward "\n\n" nil t) 583 (if (search-forward "\n\n" nil t)
743 (replace-match "") 584 (replace-match "")
744 (goto-char (point-max))) 585 (goto-char (point-max)))
745 (insert ?\n mail-header-separator ?\n) 586 (insert ?\n mail-header-separator ?\n)
746 (goto-char (point-min)) 587 (mail-position-on-field "To")
747 (if vm-mail-header-from
748 (insert "Resent-From: " vm-mail-header-from ?\n))
749 (mail-position-on-field "Resent-To")
750 (setq default-directory dir))) 588 (setq default-directory dir)))
751 (run-hooks 'vm-resend-bounced-message-hook) 589 (run-hooks 'vm-resend-bounced-message-hook)
752 (run-hooks 'vm-mail-mode-hook)) 590 (run-hooks 'vm-mail-mode-hook))
753 591
754 (defun vm-resend-message () 592 (defun vm-resend-message ()
755 "Resend the current message to someone else. 593 "Resend the current message to someone else.
756 The current message will be copied to a Mail mode buffer and you 594 The current message will be copied to a Mail mode buffer and you
757 can edit the message and send it as usual. 595 can edit the message and send it as usual.
758 596
759 NOTE: since you are doing a resend, a Resent-To header is provided 597 NOTE: since you are doing a resend, a Resent-To header is
760 for you to fill in the new recipient list. If you don't fill in 598 provided for you to fill in. If you don't fill it in, when you
761 this header, what happens when you send the message is undefined. 599 send the message it will go to the original recipients listed in
762 You may also create a Resent-Cc header." 600 the To and Cc headers. You may also create a Resent-Cc header."
763 (interactive) 601 (interactive)
764 (vm-follow-summary-cursor) 602 (vm-follow-summary-cursor)
765 (vm-select-folder-buffer) 603 (vm-select-folder-buffer)
766 (vm-check-for-killed-summary) 604 (vm-check-for-killed-summary)
767 (vm-error-if-folder-empty) 605 (vm-error-if-folder-empty)
822 (interactive "P") 660 (interactive "P")
823 (vm-select-folder-buffer) 661 (vm-select-folder-buffer)
824 (vm-check-for-killed-summary) 662 (vm-check-for-killed-summary)
825 (vm-error-if-folder-empty) 663 (vm-error-if-folder-empty)
826 (let ((dir default-directory) 664 (let ((dir default-directory)
827 (miming (and vm-send-using-mime (equal vm-digest-send-type "mime"))) 665 (mp vm-message-pointer)
828 mp mail-buffer b
829 ;; prefix arg doesn't have "normal" meaning here, so only call 666 ;; prefix arg doesn't have "normal" meaning here, so only call
830 ;; vm-select-marked-or-prefixed-messages if we're using marks. 667 ;; vm-select-marked-or-prefixed-messages if we're using marks.
831 (mlist (if (eq last-command 'vm-next-command-uses-marks) 668 (mlist (if (eq last-command 'vm-next-command-uses-marks)
832 (vm-select-marked-or-prefixed-messages 0) 669 (vm-select-marked-or-prefixed-messages 0)
833 vm-message-list)) 670 vm-message-list))
834 start header-end boundary) 671 start)
835 (save-restriction 672 (save-restriction
836 (widen) 673 (widen)
837 (vm-mail-internal (format "digest from %s" (buffer-name))) 674 (vm-mail-internal (format "digest from %s" (buffer-name)))
838 (make-local-variable 'vm-forward-list) 675 (make-local-variable 'vm-forward-list)
839 (setq vm-system-state 'forwarding 676 (setq vm-system-state 'forwarding
840 vm-forward-list mlist 677 vm-forward-list mlist
841 default-directory dir) 678 default-directory dir)
842 (if miming 679 (goto-char (point-min))
843 (progn 680 (re-search-forward (concat "^" (regexp-quote mail-header-separator)
844 (setq mail-buffer (current-buffer)) 681 "\n"))
845 (set-buffer (generate-new-buffer "*vm-digest-buffer*")) 682 (goto-char (match-end 0))
846 (setq header-end (point)) 683 (setq start (point)
847 (insert "\n") 684 mp mlist)
848 (setq start (point-marker))) 685 (vm-unsaved-message "Building %s digest..." vm-digest-send-type)
849 (goto-char (point-min)) 686 (cond ((equal vm-digest-send-type "rfc934")
850 (re-search-forward (concat "^" (regexp-quote mail-header-separator)
851 "\n"))
852 (goto-char (match-end 0))
853 (setq start (point-marker)
854 header-end (match-beginning 0)))
855 (message "Building %s digest..." vm-digest-send-type)
856 (cond ((equal vm-digest-send-type "mime")
857 (setq boundary (vm-mime-encapsulate-messages
858 mlist vm-mime-digest-headers
859 vm-mime-digest-discard-header-regexp
860 t))
861 (goto-char header-end)
862 (insert "MIME-Version: 1.0\n")
863 (insert (if vm-mime-avoid-folding-content-type
864 "Content-Type: multipart/digest; boundary=\""
865 "Content-Type: multipart/digest;\n\tboundary=\"")
866 boundary "\"\n")
867 (insert "Content-Transfer-Encoding: "
868 (vm-determine-proper-content-transfer-encoding
869 (point)
870 (point-max))
871 "\n"))
872 ((equal vm-digest-send-type "rfc934")
873 (vm-rfc934-encapsulate-messages 687 (vm-rfc934-encapsulate-messages
874 mlist vm-rfc934-digest-headers 688 mlist vm-rfc934-digest-headers
875 vm-rfc934-digest-discard-header-regexp)) 689 vm-rfc934-digest-discard-header-regexp))
876 ((equal vm-digest-send-type "rfc1153") 690 ((equal vm-digest-send-type "rfc1153")
877 (vm-rfc1153-encapsulate-messages 691 (vm-rfc1153-encapsulate-messages
878 mlist vm-rfc1153-digest-headers 692 mlist vm-rfc1153-digest-headers
879 vm-rfc1153-digest-discard-header-regexp))) 693 vm-rfc1153-digest-discard-header-regexp))
694 ((equal vm-digest-send-type "rfc1521")
695 (vm-rfc1521-encapsulate-messages
696 mlist vm-rfc1521-digest-headers
697 vm-rfc1521-digest-discard-header-regexp)))
880 (goto-char start) 698 (goto-char start)
881 (setq mp mlist) 699 (setq mp mlist)
882 (if miming
883 (let ((b (current-buffer)))
884 (set-buffer mail-buffer)
885 (mail-text)
886 (vm-mime-attach-object b "multipart/digest"
887 (list (concat "boundary=\""
888 boundary "\"")) nil t)
889 (add-hook 'kill-buffer-hook
890 (list 'lambda ()
891 (list 'if (list 'eq mail-buffer '(current-buffer))
892 (list 'kill-buffer b))))))
893 (if prefix 700 (if prefix
894 (save-excursion 701 (progn
895 (message "Building digest preamble...") 702 (vm-unsaved-message "Building digest preamble...")
896 (if miming
897 (progn
898 (set-buffer mail-buffer)
899 (mail-text)))
900 (while mp 703 (while mp
901 (let ((vm-summary-uninteresting-senders nil)) 704 (let ((vm-summary-uninteresting-senders nil))
902 (insert (vm-sprintf 'vm-digest-preamble-format (car mp)) "\n")) 705 (insert (vm-sprintf 'vm-digest-preamble-format (car mp)) "\n"))
903 (if vm-digest-center-preamble 706 (if vm-digest-center-preamble
904 (progn 707 (progn
921 "Like vm-send-digest but always sends an RFC 1153 digest." 724 "Like vm-send-digest but always sends an RFC 1153 digest."
922 (interactive "P") 725 (interactive "P")
923 (let ((vm-digest-send-type "rfc1153")) 726 (let ((vm-digest-send-type "rfc1153"))
924 (vm-send-digest preamble))) 727 (vm-send-digest preamble)))
925 728
926 (defun vm-send-mime-digest (&optional preamble) 729 (defun vm-send-rfc1521-digest (&optional preamble)
927 "Like vm-send-digest but always sends an MIME (multipart/digest) digest." 730 "Like vm-send-digest but always sends an RFC 1521 (MIME) digest."
928 (interactive "P") 731 (interactive "P")
929 (let ((vm-digest-send-type "mime")) 732 (let ((vm-digest-send-type "rfc1521"))
930 (vm-send-digest preamble))) 733 (vm-send-digest preamble)))
931 734
932 (defun vm-continue-composing-message (&optional not-picky) 735 (defun vm-continue-composing-message (&optional not-picky)
933 "Find and select the most recently used mail composition buffer. 736 "Find and select the most recently used mail composition buffer.
934 If the selected buffer is already a Mail mode buffer then it is 737 If the selected buffer is already a Mail mode buffer then it is
944 (progn 747 (progn
945 ;; avoid having the window configuration code choose a 748 ;; avoid having the window configuration code choose a
946 ;; different composition buffer. 749 ;; different composition buffer.
947 (vm-unbury-buffer b) 750 (vm-unbury-buffer b)
948 (set-buffer b) 751 (set-buffer b)
949 (if (and vm-mutable-frames vm-frame-per-composition 752 (if (and vm-frame-per-composition (vm-multiple-frames-possible-p)
950 (vm-multiple-frames-possible-p)
951 ;; only pop up a frame if there's an undisplay 753 ;; only pop up a frame if there's an undisplay
952 ;; hook in place to make the frame go away. 754 ;; hook in place to make the frame go away.
953 vm-undisplay-buffer-hook) 755 vm-undisplay-buffer-hook)
954 (let ((w (vm-get-buffer-window b))) 756 (let ((w (vm-get-buffer-window b)))
955 (if (null w) 757 (if (null w)
963 (vm-set-hooks-for-frame-deletion))) 765 (vm-set-hooks-for-frame-deletion)))
964 (vm-display b t '(vm-continue-composing-message) 766 (vm-display b t '(vm-continue-composing-message)
965 '(vm-continue-composing-message composing-message))) 767 '(vm-continue-composing-message composing-message)))
966 (message "No composition buffers found")))) 768 (message "No composition buffers found"))))
967 769
968 (defun vm-mail-to-mailto-url (url)
969 (let ((address (car (vm-parse url "^mailto:\\(.+\\)"))))
970 (vm-select-folder-buffer)
971 (vm-check-for-killed-summary)
972 (vm-mail-internal nil address)
973 (run-hooks 'vm-mail-hook)
974 (run-hooks 'vm-mail-mode-hook)))
975
976 ;; to quiet the v19 byte compiler 770 ;; to quiet the v19 byte compiler
977 (defvar mail-mode-map) 771 (defvar mail-mode-map)
978 (defvar mail-aliases) 772 (defvar mail-aliases)
979 (defvar mail-default-reply-to) 773 (defvar mail-default-reply-to)
980 (defvar mail-signature-file) 774 (defvar mail-signature-file)
993 (use-local-map vm-mail-mode-map) 787 (use-local-map vm-mail-mode-map)
994 ;; make mail-mode-map the parent of this vm-mail-mode-map, if we can. 788 ;; make mail-mode-map the parent of this vm-mail-mode-map, if we can.
995 ;; do it only once. 789 ;; do it only once.
996 (if (not vm-mail-mode-map-parented) 790 (if (not vm-mail-mode-map-parented)
997 (cond ((fboundp 'set-keymap-parents) 791 (cond ((fboundp 'set-keymap-parents)
998 (set-keymap-parents vm-mail-mode-map (list mail-mode-map)) 792 (set-keymap-parents vm-mail-mode-map (list mail-mode-map)))
999 (setq vm-mail-mode-map-parented t))
1000 ((consp mail-mode-map) 793 ((consp mail-mode-map)
1001 (nconc vm-mail-mode-map mail-mode-map) 794 (nconc vm-mail-mode-map mail-mode-map)
1002 (setq vm-mail-mode-map-parented t)))) 795 (setq vm-mail-mode-map-parented t))))
1003 (setq vm-mail-buffer folder-buffer 796 (setq vm-mail-buffer folder-buffer
1004 mode-popup-menu (and vm-use-menus vm-popup-menu-on-mouse-3 797 mode-popup-menu (and vm-use-menus
1005 (vm-menu-support-possible-p) 798 (vm-menu-support-possible-p)
1006 (vm-menu-mode-menu))) 799 (vm-menu-mode-menu)))
800 ;; sets up popup menu for FSF Emacs
1007 (and vm-use-menus (vm-menu-support-possible-p) 801 (and vm-use-menus (vm-menu-support-possible-p)
1008 (vm-menu-install-mail-mode-menu)) 802 (vm-menu-install-mail-mode-menu))
1009 (if (fboundp 'mail-aliases-setup) ; use mail-abbrevs.el if present 803 (if (fboundp 'mail-aliases-setup) ; use mail-abbrevs.el if present
1010 (mail-aliases-setup) 804 (mail-aliases-setup)
1011 (if (eq mail-aliases t) 805 (if (eq mail-aliases t)
1012 (progn 806 (progn
1013 (setq mail-aliases nil) 807 (setq mail-aliases nil)
1014 (if (file-exists-p (or mail-personal-alias-file "~/.mailrc")) 808 (if (file-exists-p "~/.mailrc")
1015 (build-mail-aliases))))) 809 (build-mail-aliases)))))
1016 (if (stringp vm-mail-header-from) 810 (if (stringp vm-mail-header-from)
1017 (insert "From: " vm-mail-header-from "\n")) 811 (insert "From: " vm-mail-header-from "\n"))
1018 (insert "To: " (or to "") "\n") 812 (insert "To: " (or to "") "\n")
1019 (and cc (insert "Cc: " cc "\n")) 813 (and cc (insert "Cc: " cc "\n"))
1020 (insert "Subject: " (or subject "") "\n") 814 (insert "Subject: " (or subject "") "\n")
1021 (and newsgroups (insert "Newsgroups: " newsgroups "\n")) 815 (and newsgroups (insert "Newsgroups: " newsgroups "\n"))
1022 (and in-reply-to (insert "In-Reply-To: " in-reply-to "\n")) 816 (and in-reply-to (insert "In-Reply-To: " in-reply-to "\n"))
1023 (and references (insert "References: " references "\n")) 817 (and references (insert "References: " references "\n"))
1024 (insert "X-Mailer: VM " vm-version " under " 818 ;; REPLYTO support for FSF Emacs v19.29
1025 (if vm-fsfemacs-19-p "Emacs " "") 819 (and (eq mail-default-reply-to t)
1026 emacs-version "\n")
1027 ;; REPLYTO environmental variable support
1028 ;; note that in FSF Emacs v19.29 we would initialize if the
1029 ;; value was t. nil is the treigger value used now.
1030 (and (eq mail-default-reply-to nil)
1031 (setq mail-default-reply-to (getenv "REPLYTO"))) 820 (setq mail-default-reply-to (getenv "REPLYTO")))
1032 (if mail-default-reply-to 821 (if mail-default-reply-to
1033 (insert "Reply-To: " mail-default-reply-to "\n")) 822 (insert "Reply-To: " mail-default-reply-to "\n"))
1034 (if mail-self-blind 823 (if mail-self-blind
1035 (insert "Bcc: " (user-login-name) "\n")) 824 (insert "Bcc: " (user-login-name) "\n"))
1052 "~/.signature"))))) 841 "~/.signature")))))
1053 ;; move this buffer to the head of the buffer list so window 842 ;; move this buffer to the head of the buffer list so window
1054 ;; config stuff will select it as the composition buffer. 843 ;; config stuff will select it as the composition buffer.
1055 (vm-unbury-buffer (current-buffer)) 844 (vm-unbury-buffer (current-buffer))
1056 ;; make a new frame if the user wants it. 845 ;; make a new frame if the user wants it.
1057 (if (and vm-mutable-frames vm-frame-per-composition 846 (if (and vm-frame-per-composition (vm-multiple-frames-possible-p))
1058 (vm-multiple-frames-possible-p))
1059 (progn 847 (progn
1060 (vm-goto-new-frame 'composition) 848 (vm-goto-new-frame 'composition)
1061 (vm-set-hooks-for-frame-deletion))) 849 (vm-set-hooks-for-frame-deletion)))
1062 ;; now do window configuration 850 ;; now do window configuration
1063 (vm-display (current-buffer) t 851 (vm-display (current-buffer) t
1076 vm-send-digest-other-frame 864 vm-send-digest-other-frame
1077 vm-send-rfc934-digest 865 vm-send-rfc934-digest
1078 vm-send-rfc934-digest-other-frame 866 vm-send-rfc934-digest-other-frame
1079 vm-send-rfc1153-digest 867 vm-send-rfc1153-digest
1080 vm-send-rfc1153-digest-other-frame 868 vm-send-rfc1153-digest-other-frame
1081 vm-send-mime-digest 869 vm-send-rfc1521-digest
1082 vm-send-mime-digest-other-frame 870 vm-send-rfc1521-digest-other-frame
1083 vm-forward-message 871 vm-forward-message
1084 vm-forward-message-other-frame 872 vm-forward-message-other-frame
1085 vm-forward-message-all-headers 873 vm-forward-message-all-headers
1086 vm-forward-message-all-headers-other-frame 874 vm-forward-message-all-headers-other-frame
1087 vm-resend-message 875 vm-resend-message
1212 (vm-search-other-frames nil)) 1000 (vm-search-other-frames nil))
1213 (vm-send-rfc1153-digest prefix)) 1001 (vm-send-rfc1153-digest prefix))
1214 (if (vm-multiple-frames-possible-p) 1002 (if (vm-multiple-frames-possible-p)
1215 (vm-set-hooks-for-frame-deletion))) 1003 (vm-set-hooks-for-frame-deletion)))
1216 1004
1217 (defun vm-send-mime-digest-other-frame (&optional prefix) 1005 (defun vm-send-rfc1521-digest-other-frame (&optional prefix)
1218 "Like vm-send-mime-digest, but run in a newly created frame." 1006 "Like vm-send-rfc1521-digest, but run in a newly created frame."
1219 (interactive "P") 1007 (interactive "P")
1220 (if (vm-multiple-frames-possible-p) 1008 (if (vm-multiple-frames-possible-p)
1221 (vm-goto-new-frame 'composition)) 1009 (vm-goto-new-frame 'composition))
1222 (let ((vm-frame-per-composition nil) 1010 (let ((vm-frame-per-composition nil)
1223 (vm-search-other-frames nil)) 1011 (vm-search-other-frames nil))
1224 (vm-send-mime-digest prefix)) 1012 (vm-send-rfc1153-digest prefix))
1225 (if (vm-multiple-frames-possible-p) 1013 (if (vm-multiple-frames-possible-p)
1226 (vm-set-hooks-for-frame-deletion))) 1014 (vm-set-hooks-for-frame-deletion)))