aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2008-12-10 21:50:23 +0000
committerChong Yidong2008-12-10 21:50:23 +0000
commitecc69b6579121e5e2e64ace69a53953a19f2f38e (patch)
tree9a9d368f385d28b83fbfe12bba5c89fdf408e81c
parenta6ab2338109faf2f78a36dd75f5dcc7603918fa8 (diff)
downloademacs-ecc69b6579121e5e2e64ace69a53953a19f2f38e.tar.gz
emacs-ecc69b6579121e5e2e64ace69a53953a19f2f38e.zip
(pmail-perm-variables): Don't call pmail-parse-file-inboxes.
(pmail-parse-file-inboxes): Function deleted. (pmail-get-new-mail-1): Function merged into pmail-get-new-mail. (pmail-get-new-mail-2): Renamed to pmail-get-new-mail-1. (pmail-get-new-mail-filter-spam): Call rmail-spam-filter, not pmail-spam-filter. (pmail-convert-to-babyl-format): Function deleted. (pmail-nuke-pinhead-header): Function deleted. (pmail-reply): Parsing headers in mbox format. Call rmail-dont-reply-to instead of pmail-dont-reply-to.
-rw-r--r--lisp/mail/pmail.el488
1 files changed, 51 insertions, 437 deletions
diff --git a/lisp/mail/pmail.el b/lisp/mail/pmail.el
index e40fd273097..73301ee444f 100644
--- a/lisp/mail/pmail.el
+++ b/lisp/mail/pmail.el
@@ -240,7 +240,7 @@ please report it with \\[report-emacs-bug].")
240 240
241(declare-function mail-position-on-field "sendmail" (field &optional soft)) 241(declare-function mail-position-on-field "sendmail" (field &optional soft))
242(declare-function mail-text-start "sendmail" ()) 242(declare-function mail-text-start "sendmail" ())
243(declare-function pmail-dont-reply-to "mail-utils" (destinations)) 243(declare-function rmail-dont-reply-to "mail-utils" (destinations))
244(declare-function pmail-update-summary "pmailsum" (&rest ignore)) 244(declare-function pmail-update-summary "pmailsum" (&rest ignore))
245 245
246(defun pmail-probe (prog) 246(defun pmail-probe (prog)
@@ -1331,7 +1331,6 @@ Create the buffer if necessary."
1331 (make-local-variable 'pmail-message-vector) 1331 (make-local-variable 'pmail-message-vector)
1332 (make-local-variable 'pmail-msgref-vector) 1332 (make-local-variable 'pmail-msgref-vector)
1333 (make-local-variable 'pmail-inbox-list) 1333 (make-local-variable 'pmail-inbox-list)
1334 (setq pmail-inbox-list (pmail-parse-file-inboxes))
1335 ;; Provide default set of inboxes for primary mail file ~/PMAIL. 1334 ;; Provide default set of inboxes for primary mail file ~/PMAIL.
1336 (and (null pmail-inbox-list) 1335 (and (null pmail-inbox-list)
1337 (or (equal buffer-file-name (expand-file-name pmail-file-name)) 1336 (or (equal buffer-file-name (expand-file-name pmail-file-name))
@@ -1406,23 +1405,6 @@ Create the buffer if necessary."
1406 (pmail-show-message-maybe pmail-total-messages) 1405 (pmail-show-message-maybe pmail-total-messages)
1407 (run-hooks 'pmail-mode-hook)))) 1406 (run-hooks 'pmail-mode-hook))))
1408 1407
1409;; Return a list of files from this buffer's Mail: option.
1410;; Does not assume that messages have been parsed.
1411;; Just returns nil if buffer does not look like Babyl format.
1412(defun pmail-parse-file-inboxes ()
1413 (save-excursion
1414 (save-restriction
1415 (widen)
1416 (goto-char 1)
1417 (cond ((looking-at "BABYL OPTIONS:")
1418 (search-forward "\n\^_" nil 'move)
1419 (narrow-to-region 1 (point))
1420 (goto-char 1)
1421 (when (search-forward "\nMail:" nil t)
1422 (narrow-to-region (point) (progn (end-of-line) (point)))
1423 (goto-char (point-min))
1424 (mail-parse-comma-list)))))))
1425
1426(defun pmail-expunge-and-save () 1408(defun pmail-expunge-and-save ()
1427 "Expunge and save PMAIL file." 1409 "Expunge and save PMAIL file."
1428 (interactive) 1410 (interactive)
@@ -1492,7 +1474,6 @@ original copy."
1492 (interactive "FRun pmail on PMAIL file: ") 1474 (interactive "FRun pmail on PMAIL file: ")
1493 (pmail filename)) 1475 (pmail filename))
1494 1476
1495
1496;; This used to scan subdirectories recursively, but someone pointed out 1477;; This used to scan subdirectories recursively, but someone pointed out
1497;; that if the user wants that, person can put all the files in one dir. 1478;; that if the user wants that, person can put all the files in one dir.
1498;; And the recursive scan was slow. So I took it out. 1479;; And the recursive scan was slow. So I took it out.
@@ -1510,30 +1491,28 @@ original copy."
1510(defun pmail-list-to-menu (menu-name l action &optional full-name) 1491(defun pmail-list-to-menu (menu-name l action &optional full-name)
1511 (let ((menu (make-sparse-keymap menu-name))) 1492 (let ((menu (make-sparse-keymap menu-name)))
1512 (mapc 1493 (mapc
1513 (function (lambda (item) 1494 (lambda (item)
1514 (let (command) 1495 (let (command)
1515 (if (consp item) 1496 (if (consp item)
1516 (progn 1497 (setq command
1517 (setq command 1498 (pmail-list-to-menu
1518 (pmail-list-to-menu (car item) (cdr item) 1499 (car item) (cdr item) action
1519 action 1500 (if full-name
1520 (if full-name 1501 (concat full-name "/"
1521 (concat full-name "/" 1502 (car item))
1522 (car item)) 1503 (car item)))
1523 (car item)))) 1504 name (car item))
1524 (setq name (car item))) 1505 (setq name item)
1525 (progn 1506 (setq command
1526 (setq name item) 1507 (list 'lambda () '(interactive)
1527 (setq command 1508 (list action
1528 (list 'lambda () '(interactive) 1509 (expand-file-name
1529 (list action 1510 (if full-name
1530 (expand-file-name 1511 (concat full-name "/" item)
1531 (if full-name 1512 item)
1532 (concat full-name "/" item) 1513 pmail-secondary-file-directory)))))
1533 item) 1514 (define-key menu (vector (intern name))
1534 pmail-secondary-file-directory)))))) 1515 (cons name command))))
1535 (define-key menu (vector (intern name))
1536 (cons name command)))))
1537 (reverse l)) 1516 (reverse l))
1538 menu)) 1517 menu))
1539 1518
@@ -1563,7 +1542,7 @@ original copy."
1563 1542
1564;;;; *** Pmail input *** 1543;;;; *** Pmail input ***
1565 1544
1566(declare-function pmail-spam-filter "pmail-spam-filter" (msg)) 1545(declare-function rmail-spam-filter "rmail-spam-filter" (msg))
1567(declare-function pmail-summary-goto-msg "pmailsum" (&optional n nowarn skip-pmail)) 1546(declare-function pmail-summary-goto-msg "pmailsum" (&optional n nowarn skip-pmail))
1568(declare-function pmail-summary-mark-undeleted "pmailsum" (n)) 1547(declare-function pmail-summary-mark-undeleted "pmailsum" (n))
1569(declare-function pmail-summary-mark-deleted "pmailsum" (&optional n undel)) 1548(declare-function pmail-summary-mark-deleted "pmailsum" (&optional n undel))
@@ -1606,28 +1585,19 @@ It returns t if it got any new messages."
1606 ;; Get rid of all undo records for this buffer. 1585 ;; Get rid of all undo records for this buffer.
1607 (or (eq buffer-undo-list t) 1586 (or (eq buffer-undo-list t)
1608 (setq buffer-undo-list nil)) 1587 (setq buffer-undo-list nil))
1609 (pmail-get-new-mail-1 file-name)) 1588 (let ((all-files (if file-name (list file-name) pmail-inbox-list))
1610
1611(defun pmail-get-new-mail-1 (file-name)
1612 "Continuation of 'pmail-get-new-mail. Sort of a procedural
1613abstraction kind of thing to manage the code size. Return t if
1614new messages are found, nil otherwise."
1615 (let ((all-files (if file-name (list file-name)
1616 pmail-inbox-list))
1617 (pmail-enable-multibyte (default-value 'enable-multibyte-characters)) 1589 (pmail-enable-multibyte (default-value 'enable-multibyte-characters))
1618 found) 1590 found)
1619 (unwind-protect 1591 (unwind-protect
1620 (when all-files 1592 (when all-files
1621 (let ((opoint (point)) 1593 (let ((opoint (point))
1622 (delete-files ())
1623 ;; If buffer has not changed yet, and has not been 1594 ;; If buffer has not changed yet, and has not been
1624 ;; saved yet, don't replace the old backup file now. 1595 ;; saved yet, don't replace the old backup file now.
1625 (make-backup-files (and make-backup-files (buffer-modified-p))) 1596 (make-backup-files (and make-backup-files (buffer-modified-p)))
1626 (buffer-read-only nil) 1597 (buffer-read-only nil)
1627 ;; Don't make undo records for what we do in getting 1598 ;; Don't make undo records while getting mail.
1628 ;; mail.
1629 (buffer-undo-list t) 1599 (buffer-undo-list t)
1630 success files file-last-names) 1600 delete-files success files file-last-names)
1631 ;; Pull files off all-files onto files as long as there is 1601 ;; Pull files off all-files onto files as long as there is
1632 ;; no name conflict. A conflict happens when two inbox 1602 ;; no name conflict. A conflict happens when two inbox
1633 ;; file names have the same last component. 1603 ;; file names have the same last component.
@@ -1643,17 +1613,18 @@ new messages are found, nil otherwise."
1643 (goto-char (point-max)) 1613 (goto-char (point-max))
1644 (skip-chars-backward " \t\n") ; just in case of brain damage 1614 (skip-chars-backward " \t\n") ; just in case of brain damage
1645 (delete-region (point) (point-max)) ; caused by require-final-newline 1615 (delete-region (point) (point-max)) ; caused by require-final-newline
1646 (setq found (pmail-get-new-mail-2 file-name files delete-files)))) 1616 (setq found (pmail-get-new-mail-1 file-name files delete-files))))
1647 found) 1617 found)
1648 ;; Don't leave the buffer screwed up if we get a disk-full error. 1618 ;; Don't leave the buffer screwed up if we get a disk-full error.
1649 (or found (pmail-show-message-maybe)))) 1619 (or found (pmail-show-message-maybe))))
1650 1620
1651(defun pmail-get-new-mail-2 (file-name files delete-files) 1621(defun pmail-get-new-mail-1 (file-name files delete-files)
1652 "Return t if new messages are detected without error, nil otherwise." 1622 "Return t if new messages are detected without error, nil otherwise."
1653 (save-excursion 1623 (save-excursion
1654 (save-restriction 1624 (save-restriction
1655 (let ((new-messages 0) 1625 (let ((new-messages 0)
1656 (spam-filter-p (and (featurep 'pmail-spam-filter) pmail-use-spam-filter)) 1626 (spam-filter-p (and (featurep 'rmail-spam-filter)
1627 pmail-use-spam-filter))
1657 blurb result success suffix) 1628 blurb result success suffix)
1658 (narrow-to-region (point) (point)) 1629 (narrow-to-region (point) (point))
1659 ;; Read in the contents of the inbox files, renaming them as 1630 ;; Read in the contents of the inbox files, renaming them as
@@ -1735,7 +1706,7 @@ new messages are found, nil otherwise."
1735 (setq pmail-deleted-vector (make-string (1+ pmail-total-messages) ?\ )) 1706 (setq pmail-deleted-vector (make-string (1+ pmail-total-messages) ?\ ))
1736 (while (<= rsf-scanned-message-number pmail-total-messages) 1707 (while (<= rsf-scanned-message-number pmail-total-messages)
1737 (progn 1708 (progn
1738 (if (not (pmail-spam-filter rsf-scanned-message-number)) 1709 (if (not (rmail-spam-filter rsf-scanned-message-number))
1739 (progn (setq rsf-number-of-spam (1+ rsf-number-of-spam)))) 1710 (progn (setq rsf-number-of-spam (1+ rsf-number-of-spam))))
1740 (setq rsf-scanned-message-number (1+ rsf-scanned-message-number)))) 1711 (setq rsf-scanned-message-number (1+ rsf-scanned-message-number))))
1741 (if (> rsf-number-of-spam 0) 1712 (if (> rsf-number-of-spam 0)
@@ -1974,11 +1945,12 @@ message (including the blank line separator)."
1974 (insert name ": " value "\n")) 1945 (insert name ": " value "\n"))
1975 1946
1976(defun pmail-add-mbox-headers () 1947(defun pmail-add-mbox-headers ()
1977 "Validate the RFC2822 format for the new messages. Point, at 1948 "Validate the RFC2822 format for the new messages.
1978entry should be looking at the first new message. An error will 1949Point should be at the first new message.
1979be thrown if the new messages are not RCC2822 compliant. Lastly, 1950An error is signalled if the new messages are not RFC2822
1980unless one already exists, add an Rmail attribute header to the 1951compliant.
1981new messages in the region. Return the number of new messages." 1952Unless an Rmail attribute header already exists, add it to the
1953new messages. Return the number of new messages."
1982 (save-excursion 1954 (save-excursion
1983 (let ((count 0) 1955 (let ((count 0)
1984 (start (point)) 1956 (start (point))
@@ -2004,356 +1976,6 @@ new messages in the region. Return the number of new messages."
2004 (forward-char -5)) 1976 (forward-char -5))
2005 (setq start (point)))) 1977 (setq start (point))))
2006 count))) 1978 count)))
2007
2008;; the pmail-break-forwarded-messages feature is not implemented
2009(defun pmail-convert-to-babyl-format ()
2010 (let ((count 0) start
2011 (case-fold-search nil)
2012 (buffer-undo-list t)
2013 (invalid-input-resync
2014 (function (lambda ()
2015 (message "Invalid Babyl format in inbox!")
2016 (sit-for 3)
2017 ;; Try to get back in sync with a real message.
2018 (if (re-search-forward
2019 (concat pmail-mmdf-delim1 "\\|^From") nil t)
2020 (beginning-of-line)
2021 (goto-char (point-max)))))))
2022 (goto-char (point-min))
2023 (save-restriction
2024 (while (not (eobp))
2025 (setq start (point))
2026 (cond ((looking-at "BABYL OPTIONS:") ;Babyl header
2027 (if (search-forward "\n\^_" nil t)
2028 ;; If we find the proper terminator, delete through there.
2029 (delete-region (point-min) (point))
2030 (funcall invalid-input-resync)
2031 (delete-region (point-min) (point))))
2032 ;; Babyl format message
2033 ((looking-at "\^L")
2034 (or (search-forward "\n\^_" nil t)
2035 (funcall invalid-input-resync))
2036 (setq count (1+ count))
2037 ;; Make sure there is no extra white space after the ^_
2038 ;; at the end of the message.
2039 ;; Narrowing will make sure that whatever follows the junk
2040 ;; will be treated properly.
2041 (delete-region (point)
2042 (save-excursion
2043 (skip-chars-forward " \t\n")
2044 (point)))
2045 ;; The following let* form was wrapped in a `save-excursion'
2046 ;; which in one case caused infinite looping, see:
2047 ;; http://lists.gnu.org/archive/html/emacs-devel/2008-01/msg00968.html
2048 ;; Removing that form leaves `point' at the end of the
2049 ;; region decoded by `pmail-decode-region' which should
2050 ;; be correct.
2051 (let* ((header-end
2052 (progn
2053 (save-excursion
2054 (goto-char start)
2055 (forward-line 1)
2056 (if (looking-at "0")
2057 (forward-line 1)
2058 (forward-line 2))
2059 (save-restriction
2060 (narrow-to-region (point) (point-max))
2061 (rfc822-goto-eoh)
2062 (point)))))
2063 (case-fold-search t)
2064 (quoted-printable-header-field-end
2065 (save-excursion
2066 (goto-char start)
2067 (re-search-forward
2068 "^content-transfer-encoding:\\(\n?[\t ]\\)*quoted-printable\\(\n?[\t ]\\)*"
2069 header-end t)))
2070 (base64-header-field-end
2071 (save-excursion
2072 (goto-char start)
2073 ;; Don't try to decode non-text data.
2074 (and (re-search-forward
2075 "^content-type:\\(\n?[\t ]\\)\\(text\\|message\\)/"
2076 header-end t)
2077 (goto-char start)
2078 (re-search-forward
2079 "^content-transfer-encoding:\\(\n?[\t ]\\)*base64\\(\n?[\t ]\\)*"
2080 header-end t)))))
2081 (if quoted-printable-header-field-end
2082 (save-excursion
2083 (unless
2084 (mail-unquote-printable-region header-end (point) nil t t)
2085 (message "Malformed MIME quoted-printable message"))
2086 ;; Change "quoted-printable" to "8bit",
2087 ;; to reflect the decoding we just did.
2088 (goto-char quoted-printable-header-field-end)
2089 (delete-region (point) (search-backward ":"))
2090 (insert ": 8bit")))
2091 (if base64-header-field-end
2092 (save-excursion
2093 (when
2094 (condition-case nil
2095 (progn
2096 (base64-decode-region (1+ header-end)
2097 (- (point) 2))
2098 t)
2099 (error nil))
2100 ;; Change "base64" to "8bit", to reflect the
2101 ;; decoding we just did.
2102 (goto-char base64-header-field-end)
2103 (delete-region (point) (search-backward ":"))
2104 (insert ": 8bit"))))
2105 (setq last-coding-system-used nil)
2106 (or pmail-enable-mime
2107 (not pmail-enable-multibyte)
2108 (let ((mime-charset
2109 (if (and pmail-decode-mime-charset
2110 (save-excursion
2111 (goto-char start)
2112 (search-forward "\n\n" nil t)
2113 (let ((case-fold-search t))
2114 (re-search-backward
2115 pmail-mime-charset-pattern
2116 start t))))
2117 (intern (downcase (match-string 1))))))
2118 (pmail-decode-region start (point) mime-charset))))
2119 ;; Add an X-Coding-System: header if we don't have one.
2120 (save-excursion
2121 (goto-char start)
2122 (forward-line 1)
2123 (if (looking-at "0")
2124 (forward-line 1)
2125 (forward-line 2))
2126 (or (save-restriction
2127 (narrow-to-region (point) (point-max))
2128 (rfc822-goto-eoh)
2129 (goto-char (point-min))
2130 (re-search-forward "^X-Coding-System:" nil t))
2131 (insert "X-Coding-System: "
2132 (symbol-name last-coding-system-used)
2133 "\n")))
2134 (narrow-to-region (point) (point-max))
2135 (and (= 0 (% count 10))
2136 (message "Converting to Babyl format...%d" count)))
2137 ;;*** MMDF format
2138 ((let ((case-fold-search t))
2139 (looking-at pmail-mmdf-delim1))
2140 (let ((case-fold-search t))
2141 (replace-match "\^L\n0, unseen,,\n*** EOOH ***\n")
2142 (re-search-forward pmail-mmdf-delim2 nil t)
2143 (replace-match "\^_"))
2144 (save-excursion
2145 (save-restriction
2146 (narrow-to-region start (1- (point)))
2147 (goto-char (point-min))
2148 (while (search-forward "\n\^_" nil t) ; single char "\^_"
2149 (replace-match "\n^_")))) ; 2 chars: "^" and "_"
2150 (setq last-coding-system-used nil)
2151 (or pmail-enable-mime
2152 (not pmail-enable-multibyte)
2153 (decode-coding-region start (point) 'undecided))
2154 (save-excursion
2155 (goto-char start)
2156 (forward-line 3)
2157 (insert "X-Coding-System: "
2158 (symbol-name last-coding-system-used)
2159 "\n"))
2160 (narrow-to-region (point) (point-max))
2161 (setq count (1+ count))
2162 (and (= 0 (% count 10))
2163 (message "Converting to Babyl format...%d" count)))
2164 ;;*** Mail format
2165 ((looking-at "^From ")
2166 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
2167 (pmail-nuke-pinhead-header)
2168 ;; If this message has a Content-Length field,
2169 ;; skip to the end of the contents.
2170 (let* ((header-end (save-excursion
2171 (and (re-search-forward "\n\n" nil t)
2172 (1- (point)))))
2173 (case-fold-search t)
2174 (quoted-printable-header-field-end
2175 (save-excursion
2176 (re-search-forward
2177 "^content-transfer-encoding:\\(\n?[\t ]\\)*quoted-printable\\(\n?[\t ]\\)*"
2178 header-end t)))
2179 (base64-header-field-end
2180 (and
2181 ;; Don't decode non-text data.
2182 (save-excursion
2183 (re-search-forward
2184 "^content-type:\\(\n?[\t ]\\)\\(text\\|message\\)/"
2185 header-end t))
2186 (save-excursion
2187 (re-search-forward
2188 "^content-transfer-encoding:\\(\n?[\t ]\\)*base64\\(\n?[\t ]\\)*"
2189 header-end t))))
2190 (size
2191 ;; Get the numeric value from the Content-Length field.
2192 (save-excursion
2193 ;; Back up to end of prev line,
2194 ;; in case the Content-Length field comes first.
2195 (forward-char -1)
2196 (and (search-forward "\ncontent-length: "
2197 header-end t)
2198 (let ((beg (point))
2199 (eol (progn (end-of-line) (point))))
2200 (string-to-number (buffer-substring beg eol)))))))
2201 (and size
2202 (if (and (natnump size)
2203 (<= (+ header-end size) (point-max))
2204 ;; Make sure this would put us at a position
2205 ;; that we could continue from.
2206 (save-excursion
2207 (goto-char (+ header-end size))
2208 (skip-chars-forward "\n")
2209 (or (eobp)
2210 (and (looking-at "BABYL OPTIONS:")
2211 (search-forward "\n\^_" nil t))
2212 (and (looking-at "\^L")
2213 (search-forward "\n\^_" nil t))
2214 (let ((case-fold-search t))
2215 (looking-at pmail-mmdf-delim1))
2216 (looking-at "From "))))
2217 (goto-char (+ header-end size))
2218 (message "Ignoring invalid Content-Length field")
2219 (sit-for 1 0 t)))
2220 (if (let ((case-fold-search nil))
2221 (re-search-forward
2222 (concat "^[\^_]?\\("
2223 pmail-unix-mail-delimiter
2224 "\\|"
2225 pmail-mmdf-delim1 "\\|"
2226 "^BABYL OPTIONS:\\|"
2227 "\^L\n[01],\\)") nil t))
2228 (goto-char (match-beginning 1))
2229 (goto-char (point-max)))
2230 (setq count (1+ count))
2231 (if quoted-printable-header-field-end
2232 (save-excursion
2233 (unless
2234 (mail-unquote-printable-region header-end (point) nil t t)
2235 (message "Malformed MIME quoted-printable message"))
2236 ;; Change "quoted-printable" to "8bit",
2237 ;; to reflect the decoding we just did.
2238 (goto-char quoted-printable-header-field-end)
2239 (delete-region (point) (search-backward ":"))
2240 (insert ": 8bit")))
2241 (if base64-header-field-end
2242 (save-excursion
2243 (when
2244 (condition-case nil
2245 (progn
2246 (base64-decode-region
2247 (1+ header-end)
2248 (save-excursion
2249 ;; Prevent base64-decode-region
2250 ;; from removing newline characters.
2251 (skip-chars-backward "\n\t ")
2252 (point)))
2253 t)
2254 (error nil))
2255 ;; Change "base64" to "8bit", to reflect the
2256 ;; decoding we just did.
2257 (goto-char base64-header-field-end)
2258 (delete-region (point) (search-backward ":"))
2259 (insert ": 8bit")))))
2260
2261 (save-excursion
2262 (save-restriction
2263 (narrow-to-region start (point))
2264 (goto-char (point-min))
2265 (while (search-forward "\n\^_" nil t) ; single char
2266 (replace-match "\n^_")))) ; 2 chars: "^" and "_"
2267 ;; This is for malformed messages that don't end in newline.
2268 ;; There shouldn't be any, but some users say occasionally
2269 ;; there are some.
2270 (or (bolp) (newline))
2271 (insert ?\^_)
2272 (setq last-coding-system-used nil)
2273 (or pmail-enable-mime
2274 (not pmail-enable-multibyte)
2275 (let ((mime-charset
2276 (if (and pmail-decode-mime-charset
2277 (save-excursion
2278 (goto-char start)
2279 (search-forward "\n\n" nil t)
2280 (let ((case-fold-search t))
2281 (re-search-backward
2282 pmail-mime-charset-pattern
2283 start t))))
2284 (intern (downcase (match-string 1))))))
2285 (pmail-decode-region start (point) mime-charset)))
2286 (save-excursion
2287 (goto-char start)
2288 (forward-line 3)
2289 (insert "X-Coding-System: "
2290 (symbol-name last-coding-system-used)
2291 "\n"))
2292 (narrow-to-region (point) (point-max))
2293 (and (= 0 (% count 10))
2294 (message "Converting to Babyl format...%d" count)))
2295 ;;
2296 ;; This kludge is because some versions of sendmail.el
2297 ;; insert an extra newline at the beginning that shouldn't
2298 ;; be there. sendmail.el has been fixed, but old versions
2299 ;; may still be in use. -- rms, 7 May 1993.
2300 ((eolp) (delete-char 1))
2301 (t (error "Cannot convert to babyl format")))))
2302 (setq buffer-undo-list nil)
2303 count))
2304
2305;; Delete the "From ..." line, creating various other headers with
2306;; information from it if they don't already exist. Now puts the
2307;; original line into a mail-from: header line for debugging and for
2308;; use by the pmail-output function.
2309(defun pmail-nuke-pinhead-header ()
2310 (save-excursion
2311 (save-restriction
2312 (let ((start (point))
2313 (end (progn
2314 (condition-case ()
2315 (search-forward "\n\n")
2316 (error
2317 (goto-char (point-max))
2318 (insert "\n\n")))
2319 (point)))
2320 has-from has-date)
2321 (narrow-to-region start end)
2322 (let ((case-fold-search t))
2323 (goto-char start)
2324 (setq has-from (search-forward "\nFrom:" nil t))
2325 (goto-char start)
2326 (setq has-date (and (search-forward "\nDate:" nil t) (point)))
2327 (goto-char start))
2328 (let ((case-fold-search nil))
2329 (if (re-search-forward (concat "^" pmail-unix-mail-delimiter) nil t)
2330 (replace-match
2331 (concat
2332 "Mail-from: \\&"
2333 ;; Keep and reformat the date if we don't
2334 ;; have a Date: field.
2335 (if has-date
2336 ""
2337 (concat
2338 "Date: \\2, \\4 \\3 \\9 \\5 "
2339
2340 ;; The timezone could be matched by group 7 or group 10.
2341 ;; If neither of them matched, assume EST, since only
2342 ;; Easterners would be so sloppy.
2343 ;; It's a shame the substitution can't use "\\10".
2344 (cond
2345 ((/= (match-beginning 7) (match-end 7)) "\\7")
2346 ((/= (match-beginning 10) (match-end 10))
2347 (buffer-substring (match-beginning 10)
2348 (match-end 10)))
2349 (t "EST"))
2350 "\n"))
2351 ;; Keep and reformat the sender if we don't
2352 ;; have a From: field.
2353 (if has-from
2354 ""
2355 "From: \\1\n"))
2356 t)))))))
2357 1979
2358;;;; *** Pmail Message Formatting and Header Manipulation *** 1980;;;; *** Pmail Message Formatting and Header Manipulation ***
2359 1981
@@ -3560,25 +3182,18 @@ use \\[mail-yank-original] to yank the original message into it."
3560 (msgnum pmail-current-message)) 3182 (msgnum pmail-current-message))
3561 (save-excursion 3183 (save-excursion
3562 (save-restriction 3184 (save-restriction
3563 (if pmail-enable-mime 3185 (widen)
3186 (if pmail-buffers-swapped-p
3564 (narrow-to-region 3187 (narrow-to-region
3565 (goto-char (point-min)) 3188 (goto-char (point-min))
3566 (if (search-forward "\n\n" nil 'move) 3189 (search-forward "\n\n" nil 'move))
3567 (1+ (match-beginning 0))
3568 (point)))
3569 (widen)
3570 (goto-char (pmail-msgbeg pmail-current-message)) 3190 (goto-char (pmail-msgbeg pmail-current-message))
3571 (forward-line 1) 3191 (forward-line 1)
3572 (if (= (following-char) ?0) 3192 (narrow-to-region
3573 (narrow-to-region 3193 (point)
3574 (progn (forward-line 2) 3194 (search-forward "\n\n"
3575 (point)) 3195 (pmail-msgend pmail-current-message)
3576 (progn (search-forward "\n\n" (pmail-msgend pmail-current-message) 3196 'move)))
3577 'move)
3578 (point)))
3579 (narrow-to-region (point)
3580 (progn (search-forward "\n*** EOOH ***\n")
3581 (beginning-of-line) (point)))))
3582 (setq from (mail-fetch-field "from") 3197 (setq from (mail-fetch-field "from")
3583 reply-to (or (mail-fetch-field "mail-reply-to" nil t) 3198 reply-to (or (mail-fetch-field "mail-reply-to" nil t)
3584 (mail-fetch-field "reply-to" nil t) 3199 (mail-fetch-field "reply-to" nil t)
@@ -3597,12 +3212,11 @@ use \\[mail-yank-original] to yank the original message into it."
3597 ) 3212 )
3598 (unless just-sender 3213 (unless just-sender
3599 (if (mail-fetch-field "mail-followup-to" nil t) 3214 (if (mail-fetch-field "mail-followup-to" nil t)
3600 ;; If this header field is present, use it instead of the To and CC fields. 3215 ;; If this header field is present, use it instead of
3216 ;; the To and CC fields.
3601 (setq to (mail-fetch-field "mail-followup-to" nil t)) 3217 (setq to (mail-fetch-field "mail-followup-to" nil t))
3602 (setq cc (or (mail-fetch-field "cc" nil t) "") 3218 (setq cc (or (mail-fetch-field "cc" nil t) "")
3603 to (or (mail-fetch-field "to" nil t) "")))) 3219 to (or (mail-fetch-field "to" nil t) ""))))))
3604
3605 ))
3606 3220
3607 ;; Merge the resent-to and resent-cc into the to and cc. 3221 ;; Merge the resent-to and resent-cc into the to and cc.
3608 (if (and resent-to (not (equal resent-to ""))) 3222 (if (and resent-to (not (equal resent-to "")))
@@ -3631,7 +3245,7 @@ use \\[mail-yank-original] to yank the original message into it."
3631 ;; Remove unwanted names from reply-to, since Mail-Followup-To 3245 ;; Remove unwanted names from reply-to, since Mail-Followup-To
3632 ;; header causes all the names in it to wind up in reply-to, not 3246 ;; header causes all the names in it to wind up in reply-to, not
3633 ;; in cc. But if what's left is an empty list, use the original. 3247 ;; in cc. But if what's left is an empty list, use the original.
3634 (let* ((reply-to-list (pmail-dont-reply-to reply-to))) 3248 (let* ((reply-to-list (rmail-dont-reply-to reply-to)))
3635 (if (string= reply-to-list "") reply-to reply-to-list)) 3249 (if (string= reply-to-list "") reply-to reply-to-list))
3636 subject 3250 subject
3637 (pmail-make-in-reply-to-field from date message-id) 3251 (pmail-make-in-reply-to-field from date message-id)
@@ -3639,7 +3253,7 @@ use \\[mail-yank-original] to yank the original message into it."
3639 nil 3253 nil
3640 ;; mail-strip-quoted-names is NOT necessary for pmail-dont-reply-to 3254 ;; mail-strip-quoted-names is NOT necessary for pmail-dont-reply-to
3641 ;; to do its job. 3255 ;; to do its job.
3642 (let* ((cc-list (pmail-dont-reply-to 3256 (let* ((cc-list (rmail-dont-reply-to
3643 (mail-strip-quoted-names 3257 (mail-strip-quoted-names
3644 (if (null cc) to (concat to ", " cc)))))) 3258 (if (null cc) to (concat to ", " cc))))))
3645 (if (string= cc-list "") nil cc-list))) 3259 (if (string= cc-list "") nil cc-list)))