aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1994-09-27 19:32:35 +0000
committerRichard M. Stallman1994-09-27 19:32:35 +0000
commit1825bea1065695ac80c959823698d2feb3d4e782 (patch)
tree19e3350c3e5f94cf138f656b6102daf2f882a3aa
parent63af2693ce90cb3f1a08720b4f753ce99eedb4e7 (diff)
downloademacs-1825bea1065695ac80c959823698d2feb3d4e782.tar.gz
emacs-1825bea1065695ac80c959823698d2feb3d4e782.zip
(rmail-forward): Simplify insertion of forwarded msg.
Don't use exchange-point-and-mark. (rmail-msg-number-after-expunge): New function. (rmail-reply, rmail-forward): Use separate local variables rmail-send-actions-rmail-msg-number, rmail-send-actions-rmail-buffer to record which message to mark as answered or forwarded. (rmail-only-expunge): Update msg numbers stored in those variables.
-rw-r--r--lisp/mail/rmail.el86
1 files changed, 68 insertions, 18 deletions
diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el
index 0ee9f943ed1..cc805e3ae37 100644
--- a/lisp/mail/rmail.el
+++ b/lisp/mail/rmail.el
@@ -1796,6 +1796,21 @@ Deleted messages stay in the file until the \\[rmail-expunge] command is given."
1796 (interactive) 1796 (interactive)
1797 (rmail-delete-forward t)) 1797 (rmail-delete-forward t))
1798 1798
1799;; Compute the message number a given message would have after expunging.
1800;; The present number of the message is OLDNUM.
1801;; DELETEDVEC should be rmail-deleted-vector.
1802;; The value is nil for a message that would be deleted.
1803(defun rmail-msg-number-after-expunge (deletedvec oldnum)
1804 (if (or (null oldnum) (= (aref deletedvec oldnum) ?D))
1805 nil
1806 (let ((i 0)
1807 (newnum 0))
1808 (while (< i oldnum)
1809 (if (/= (aref deletedvec i) ?D)
1810 (setq newnum (1+ newnum)))
1811 (setq i (1+ i)))
1812 newnum)))
1813
1799(defun rmail-only-expunge () 1814(defun rmail-only-expunge ()
1800 "Actually erase all deleted messages in the file." 1815 "Actually erase all deleted messages in the file."
1801 (interactive) 1816 (interactive)
@@ -1824,6 +1839,7 @@ Deleted messages stay in the file until the \\[rmail-expunge] command is given."
1824 (total rmail-total-messages) 1839 (total rmail-total-messages)
1825 (new-message-number rmail-current-message) 1840 (new-message-number rmail-current-message)
1826 (new-summary nil) 1841 (new-summary nil)
1842 (rmailbuf (current-buffer))
1827 (buffer-read-only nil) 1843 (buffer-read-only nil)
1828 (messages rmail-message-vector) 1844 (messages rmail-message-vector)
1829 (deleted rmail-deleted-vector) 1845 (deleted rmail-deleted-vector)
@@ -1833,6 +1849,22 @@ Deleted messages stay in the file until the \\[rmail-expunge] command is given."
1833 rmail-message-vector nil 1849 rmail-message-vector nil
1834 rmail-deleted-vector nil 1850 rmail-deleted-vector nil
1835 rmail-summary-vector nil) 1851 rmail-summary-vector nil)
1852
1853 ;; Find each sendmail buffer that is set to reply
1854 ;; to a message in this buffer, and update its
1855 ;; message number.
1856 (let ((bufs (buffer-list)))
1857 (while bufs
1858 (save-excursion
1859 (set-buffer (car bufs))
1860 (and (boundp 'rmail-send-actions-rmail-buffer)
1861 (eq rmail-send-actions-rmail-buffer rmailbuf)
1862 (setq rmail-send-actions-rmail-msg-number
1863 (rmail-msg-number-after-expunge
1864 deleted
1865 rmail-send-actions-rmail-msg-number))))
1866 (setq bufs (cdr bufs))))
1867
1836 (while (<= number total) 1868 (while (<= number total)
1837 (if (= (aref deleted number) ?D) 1869 (if (= (aref deleted number) ?D)
1838 (progn 1870 (progn
@@ -1903,7 +1935,9 @@ Normally include CC: to all other recipients of original message;
1903prefix argument means ignore them. While composing the reply, 1935prefix argument means ignore them. While composing the reply,
1904use \\[mail-yank-original] to yank the original message into it." 1936use \\[mail-yank-original] to yank the original message into it."
1905 (interactive "P") 1937 (interactive "P")
1906 (let (from reply-to cc subject date to message-id resent-reply-to) 1938 (let (from reply-to cc subject date to message-id resent-reply-to
1939 (msgnum rmail-current-message)
1940 (rmail-buffer (current-buffer)))
1907 (save-excursion 1941 (save-excursion
1908 (save-restriction 1942 (save-restriction
1909 (widen) 1943 (widen)
@@ -1956,11 +1990,19 @@ use \\[mail-yank-original] to yank the original message into it."
1956 (if (null cc) to (concat to ", " cc)))))) 1990 (if (null cc) to (concat to ", " cc))))))
1957 (if (string= cc-list "") nil cc-list))) 1991 (if (string= cc-list "") nil cc-list)))
1958 (current-buffer) 1992 (current-buffer)
1959 (list (list '(lambda (buf msgnum) 1993 (list (list '(lambda ()
1960 (save-excursion 1994 (let ((msgnum rmail-send-actions-rmail-msg-number))
1961 (set-buffer buf) 1995 (save-excursion
1962 (rmail-set-attribute "answered" t msgnum))) 1996 (set-buffer rmail-send-actions-rmail-buffer)
1963 (current-buffer) rmail-current-message))))) 1997 (if msgnum
1998 (rmail-set-attribute "answered" t msgnum))))))))
1999 ;; We keep the rmail buffer and message number in these
2000 ;; buffer-local vars in the sendmail buffer,
2001 ;; so that rmail-only-expunge can relocate the message number.
2002 (make-local-variable 'rmail-send-actions-rmail-buffer)
2003 (make-local-variable 'rmail-send-actions-rmail-msg-number)
2004 (setq rmail-send-actions-rmail-buffer rmail-buffer)
2005 (setq rmail-send-actions-rmail-msg-number msgnum)))
1964 2006
1965(defun rmail-make-in-reply-to-field (from date message-id) 2007(defun rmail-make-in-reply-to-field (from date message-id)
1966 (cond ((not from) 2008 (cond ((not from)
@@ -2027,6 +2069,7 @@ see the documentation of `rmail-resend'."
2027 (if resend 2069 (if resend
2028 (call-interactively 'rmail-resend) 2070 (call-interactively 'rmail-resend)
2029 (let ((forward-buffer (current-buffer)) 2071 (let ((forward-buffer (current-buffer))
2072 (msgnum rmail-current-message)
2030 (subject (concat "[" 2073 (subject (concat "["
2031 (let ((from (or (mail-fetch-field "From") 2074 (let ((from (or (mail-fetch-field "From")
2032 (mail-fetch-field ">From")))) 2075 (mail-fetch-field ">From"))))
@@ -2043,26 +2086,33 @@ see the documentation of `rmail-resend'."
2043 (function mail) 2086 (function mail)
2044 (function rmail-start-mail)) 2087 (function rmail-start-mail))
2045 nil nil subject nil nil nil 2088 nil nil subject nil nil nil
2046 (list (list (function (lambda (buf msgnum) 2089 (list (list (function
2047 (save-excursion 2090 (lambda ()
2048 (set-buffer buf) 2091 (let ((msgnum
2049 (rmail-set-attribute 2092 rmail-send-actions-rmail-msg-number))
2050 "forwarded" t msgnum)))) 2093 (save-excursion
2051 (current-buffer) 2094 (set-buffer rmail-send-actions-rmail-buffer)
2052 rmail-current-message))) 2095 (if msgnum
2096 (rmail-set-attribute
2097 "forwarded" t msgnum)))))))))
2098 ;; The mail buffer is now current.
2053 (save-excursion 2099 (save-excursion
2100 ;; We keep the rmail buffer and message number in these
2101 ;; buffer-local vars in the sendmail buffer,
2102 ;; so that rmail-only-expunge can relocate the message number.
2103 (make-local-variable 'rmail-send-actions-rmail-buffer)
2104 (make-local-variable 'rmail-send-actions-rmail-msg-number)
2105 (setq rmail-send-actions-rmail-buffer forward-buffer)
2106 (setq rmail-send-actions-rmail-msg-number msgnum)
2054 ;; Insert after header separator--before signature if any. 2107 ;; Insert after header separator--before signature if any.
2055 (goto-char (point-min)) 2108 (goto-char (point-min))
2056 (search-forward-regexp 2109 (search-forward-regexp
2057 (concat "^" (regexp-quote mail-header-separator) "$")) 2110 (concat "^" (regexp-quote mail-header-separator) "$"))
2058 (forward-line 1) 2111 (forward-line 1)
2059 (insert "------- Start of forwarded message -------\n") 2112 (insert "------- Start of forwarded message -------\n")
2060 (insert-buffer forward-buffer) 2113 (insert-buffer-substring forward-buffer)
2061 (forward-line -1)
2062 (exchange-point-and-mark)
2063 (insert "------- End of forwarded message -------\n") 2114 (insert "------- End of forwarded message -------\n")
2064 (forward-line -1) 2115 (push-mark))))))
2065 (exchange-point-and-mark))))))
2066 2116
2067(defun rmail-resend (address &optional from comment mail-alias-file) 2117(defun rmail-resend (address &optional from comment mail-alias-file)
2068 "Resend current message to ADDRESSES. 2118 "Resend current message to ADDRESSES.