aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1994-10-13 09:13:36 +0000
committerRichard M. Stallman1994-10-13 09:13:36 +0000
commitd6642dffed962014e3b609b457cadc9a4e3fc2f7 (patch)
treec2980e950a99977c7eb4f278741321ac805aed3c
parent0a4df5393f9f88fa26877bd5ad6992a1d4d52f1f (diff)
downloademacs-d6642dffed962014e3b609b457cadc9a4e3fc2f7.tar.gz
emacs-d6642dffed962014e3b609b457cadc9a4e3fc2f7.zip
(mail-file-babyl-p): New function.
(mail-do-fcc): If file is a Babyl file, write output in Babyl format.
-rw-r--r--lisp/mail/sendmail.el107
1 files changed, 64 insertions, 43 deletions
diff --git a/lisp/mail/sendmail.el b/lisp/mail/sendmail.el
index 6621a72b5bd..091e5f14212 100644
--- a/lisp/mail/sendmail.el
+++ b/lisp/mail/sendmail.el
@@ -528,6 +528,16 @@ the user from the mailer."
528 (if (bufferp errbuf) 528 (if (bufferp errbuf)
529 (kill-buffer errbuf))))) 529 (kill-buffer errbuf)))))
530 530
531;; Return non-nil if file FILE is an Rmail file.
532(defun mail-file-babyl-p (file)
533 (unwind-protect
534 (save-excursion
535 (set-buffer (get-buffer-create " mail-temp"))
536 (erase-buffer)
537 (insert-file-contents file nil 0 20)
538 (looking-at "BABYL OPTIONS:"))
539 (kill-buffer " mail-temp")))
540
531(defun mail-do-fcc (header-end) 541(defun mail-do-fcc (header-end)
532 (let (fcc-list 542 (let (fcc-list
533 (rmailbuf (current-buffer)) 543 (rmailbuf (current-buffer))
@@ -569,52 +579,63 @@ the user from the mailer."
569 (forward-char -5) 579 (forward-char -5)
570 (insert ?>))) 580 (insert ?>)))
571 (while fcc-list 581 (while fcc-list
572 (let ((buffer (get-file-buffer (car fcc-list)))) 582 (let ((buffer (get-file-buffer (car fcc-list)))
583 (curbuf (current-buffer))
584 (beg (point-min)) (end (point-max))
585 (beg2 (save-excursion (goto-char (point-min))
586 (forward-line 2) (point))))
573 (if buffer 587 (if buffer
574 ;; File is present in a buffer => append to that buffer. 588 ;; File is present in a buffer => append to that buffer.
575 (let ((curbuf (current-buffer)) 589 (save-excursion
576 (beg (point-min)) (end (point-max)) 590 (set-buffer buffer)
577 (beg2 (save-excursion (goto-char (point-min)) 591 ;; Keep the end of the accessible portion at the same place
578 (forward-line 2) (point)))) 592 ;; unless it is the end of the buffer.
579 (save-excursion 593 (let ((max (if (/= (1+ (buffer-size)) (point-max))
580 (set-buffer buffer) 594 (point-max))))
581 ;; Keep the end of the accessible portion at the same place 595 (unwind-protect
582 ;; unless it is the end of the buffer. 596 ;; Code below lifted from rmailout.el
583 (let ((max (if (/= (1+ (buffer-size)) (point-max)) 597 ;; function rmail-output-to-rmail-file:
584 (point-max)))) 598 (let ((buffer-read-only nil)
585 (unwind-protect 599 (msg (and (boundp 'rmail-current-message)
586 ;; Code below lifted from rmailout.el 600 rmail-current-message)))
587 ;; function rmail-output-to-rmail-file: 601 ;; If MSG is non-nil, buffer is in RMAIL mode.
588 (let ((buffer-read-only nil) 602 (if msg
589 (msg (and (boundp 'rmail-current-message) 603 (progn
590 rmail-current-message))) 604 (rmail-maybe-set-message-counters)
591 ;; If MSG is non-nil, buffer is in RMAIL mode. 605 (widen)
592 (if msg 606 (narrow-to-region (point-max) (point-max))
593 (progn 607 (insert "\C-l\n0, unseen,,\n*** EOOH ***\n"
594 (rmail-maybe-set-message-counters) 608 "From: " (user-login-name) "\n"
595 (widen) 609 "Date: " (mail-rfc822-date) "\n")
596 (narrow-to-region (point-max) (point-max)) 610 (insert-buffer-substring curbuf beg2 end)
597 (insert "\C-l\n0, unseen,,\n*** EOOH ***\n" 611 (insert "\n\C-_")
598 "From: " (user-login-name) "\n" 612 (goto-char (point-min))
599 "Date: " (mail-rfc822-date) "\n") 613 (widen)
600 (insert-buffer-substring curbuf beg2 end) 614 (search-backward "\n\^_")
601 (insert "\n\C-_") 615 (narrow-to-region (point) (point-max))
602 (goto-char (point-min)) 616 (rmail-count-new-messages t)
603 (widen) 617 (rmail-show-message msg)
604 (search-backward "\n\^_") 618 (setq max nil))
605 (narrow-to-region (point) (point-max)) 619 ;; Output file not in rmail mode
606 (rmail-count-new-messages t) 620 ;; => just insert at the end.
607 (rmail-show-message msg) 621 (narrow-to-region (point-min) (1+ (buffer-size)))
608 (setq max nil)) 622 (goto-char (point-max))
609 ;; Output file not in rmail mode 623 (insert-buffer-substring curbuf beg end)))
610 ;; => just insert at the end. 624 (if max (narrow-to-region (point-min) max)))))
611 (narrow-to-region (point-min) (1+ (buffer-size)))
612 (goto-char (point-max))
613 (insert-buffer-substring curbuf beg end)))
614 (if max (narrow-to-region (point-min) max))))))
615 ;; Else append to the file directly. 625 ;; Else append to the file directly.
616 (write-region 626 (if (mail-file-babyl-p (car fcc-list))
617 (1+ (point-min)) (point-max) (car fcc-list) t))) 627 ;; If the file is a Babyl file,
628 ;; convert the message to Babyl format.
629 (save-excursion
630 (set-buffer (get-buffer-create " mail-temp"))
631 (insert "\C-l\n0, unseen,,\n*** EOOH ***\n"
632 "From: " (user-login-name) "\n"
633 "Date: " (mail-rfc822-date) "\n")
634 (insert-buffer-substring curbuf beg2 end)
635 (insert "\n\C-_")
636 (write-region (point-min) (point-max) (car fcc-list) t))
637 (write-region
638 (1+ (point-min)) (point-max) (car fcc-list) t))))
618 (setq fcc-list (cdr fcc-list)))) 639 (setq fcc-list (cdr fcc-list))))
619 (kill-buffer tembuf))) 640 (kill-buffer tembuf)))
620 641