Mercurial > emacs
changeset 9153:029821174e53
(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.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 27 Sep 1994 19:32:35 +0000 |
parents | 364abaa6ddf2 |
children | b4739bcefc44 |
files | lisp/mail/rmail.el |
diffstat | 1 files changed, 68 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/mail/rmail.el Tue Sep 27 05:41:20 1994 +0000 +++ b/lisp/mail/rmail.el Tue Sep 27 19:32:35 1994 +0000 @@ -1796,6 +1796,21 @@ (interactive) (rmail-delete-forward t)) +;; Compute the message number a given message would have after expunging. +;; The present number of the message is OLDNUM. +;; DELETEDVEC should be rmail-deleted-vector. +;; The value is nil for a message that would be deleted. +(defun rmail-msg-number-after-expunge (deletedvec oldnum) + (if (or (null oldnum) (= (aref deletedvec oldnum) ?D)) + nil + (let ((i 0) + (newnum 0)) + (while (< i oldnum) + (if (/= (aref deletedvec i) ?D) + (setq newnum (1+ newnum))) + (setq i (1+ i))) + newnum))) + (defun rmail-only-expunge () "Actually erase all deleted messages in the file." (interactive) @@ -1824,6 +1839,7 @@ (total rmail-total-messages) (new-message-number rmail-current-message) (new-summary nil) + (rmailbuf (current-buffer)) (buffer-read-only nil) (messages rmail-message-vector) (deleted rmail-deleted-vector) @@ -1833,6 +1849,22 @@ rmail-message-vector nil rmail-deleted-vector nil rmail-summary-vector nil) + + ;; Find each sendmail buffer that is set to reply + ;; to a message in this buffer, and update its + ;; message number. + (let ((bufs (buffer-list))) + (while bufs + (save-excursion + (set-buffer (car bufs)) + (and (boundp 'rmail-send-actions-rmail-buffer) + (eq rmail-send-actions-rmail-buffer rmailbuf) + (setq rmail-send-actions-rmail-msg-number + (rmail-msg-number-after-expunge + deleted + rmail-send-actions-rmail-msg-number)))) + (setq bufs (cdr bufs)))) + (while (<= number total) (if (= (aref deleted number) ?D) (progn @@ -1903,7 +1935,9 @@ prefix argument means ignore them. While composing the reply, use \\[mail-yank-original] to yank the original message into it." (interactive "P") - (let (from reply-to cc subject date to message-id resent-reply-to) + (let (from reply-to cc subject date to message-id resent-reply-to + (msgnum rmail-current-message) + (rmail-buffer (current-buffer))) (save-excursion (save-restriction (widen) @@ -1956,11 +1990,19 @@ (if (null cc) to (concat to ", " cc)))))) (if (string= cc-list "") nil cc-list))) (current-buffer) - (list (list '(lambda (buf msgnum) - (save-excursion - (set-buffer buf) - (rmail-set-attribute "answered" t msgnum))) - (current-buffer) rmail-current-message))))) + (list (list '(lambda () + (let ((msgnum rmail-send-actions-rmail-msg-number)) + (save-excursion + (set-buffer rmail-send-actions-rmail-buffer) + (if msgnum + (rmail-set-attribute "answered" t msgnum)))))))) + ;; We keep the rmail buffer and message number in these + ;; buffer-local vars in the sendmail buffer, + ;; so that rmail-only-expunge can relocate the message number. + (make-local-variable 'rmail-send-actions-rmail-buffer) + (make-local-variable 'rmail-send-actions-rmail-msg-number) + (setq rmail-send-actions-rmail-buffer rmail-buffer) + (setq rmail-send-actions-rmail-msg-number msgnum))) (defun rmail-make-in-reply-to-field (from date message-id) (cond ((not from) @@ -2027,6 +2069,7 @@ (if resend (call-interactively 'rmail-resend) (let ((forward-buffer (current-buffer)) + (msgnum rmail-current-message) (subject (concat "[" (let ((from (or (mail-fetch-field "From") (mail-fetch-field ">From")))) @@ -2043,26 +2086,33 @@ (function mail) (function rmail-start-mail)) nil nil subject nil nil nil - (list (list (function (lambda (buf msgnum) - (save-excursion - (set-buffer buf) - (rmail-set-attribute - "forwarded" t msgnum)))) - (current-buffer) - rmail-current-message))) + (list (list (function + (lambda () + (let ((msgnum + rmail-send-actions-rmail-msg-number)) + (save-excursion + (set-buffer rmail-send-actions-rmail-buffer) + (if msgnum + (rmail-set-attribute + "forwarded" t msgnum))))))))) + ;; The mail buffer is now current. (save-excursion + ;; We keep the rmail buffer and message number in these + ;; buffer-local vars in the sendmail buffer, + ;; so that rmail-only-expunge can relocate the message number. + (make-local-variable 'rmail-send-actions-rmail-buffer) + (make-local-variable 'rmail-send-actions-rmail-msg-number) + (setq rmail-send-actions-rmail-buffer forward-buffer) + (setq rmail-send-actions-rmail-msg-number msgnum) ;; Insert after header separator--before signature if any. (goto-char (point-min)) (search-forward-regexp (concat "^" (regexp-quote mail-header-separator) "$")) (forward-line 1) (insert "------- Start of forwarded message -------\n") - (insert-buffer forward-buffer) - (forward-line -1) - (exchange-point-and-mark) + (insert-buffer-substring forward-buffer) (insert "------- End of forwarded message -------\n") - (forward-line -1) - (exchange-point-and-mark)))))) + (push-mark)))))) (defun rmail-resend (address &optional from comment mail-alias-file) "Resend current message to ADDRESSES.