emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Change in rmail-insert-mime-forwarded-message


From: Mark Lillibridge
Subject: Re: Change in rmail-insert-mime-forwarded-message
Date: Fri, 11 Jan 2013 08:48:07 -0800

Eli Zaretskii <address@hidden> writes:

>  > Date: Thu, 10 Jan 2013 23:43:33 -0500
>  > From: Richard Stallman <address@hidden>
>  > Cc: address@hidden
>  > 
>  >    Hmmm.  Richard, does the behavior of "f" when
>  >     rmail-enable-mime-composing is set to nil do what you want?
>  > 
>  > I just tried it, and it seems ok.
>  > 
>  >                                                             If so, we
>  >     just need to figure out a good way to make that behavior and my patch
>  >     behavior for "f" available at the same time.
>  > 
>  > That's ok with me.  Any suggestions?
>  
>  Test rmail-enable-mime-composing's value and do one or the other
>  depending on that value?

    The obvious first step would seem to be to modify rmail-forward
(below) to have an optional argument that overrides the setting of
rmail-enable-mime-composing.  

    The question is how best to select this argument interactively?
Unfortunately, the prefix argument is already being used to toggle
between regular forward and resend message.  We could make C-u f resend
and C-u C-u f forward the non-default way, but that feels kludgy to me.
Accordingly, I'm thinking adding a new command key would be better.  We
could add F for the alternative forward method or move resend to its own
key, R, and make C-u f the alternative forward (not muscle memory
backwards compatible).  If you don't like shifting (I don't think Rmail
currently uses any shifted letters), y and z look available but are not
very memorable.  Either way, this probably means adding a short helper
function that calls rmail-forward with the appropriate arguments.  An
advantage of "F" is that it would allow using C-u F in the future for
alternative methods of forwarding like (3).

    Note that there are a few other ways to forward messages (menubar,
from summary buffer) that would also need to be changed similarly to
whatever we do with the main one.  We should probably rename (with
obsolete alias) rmail-enable-mime-composing to something like
rmail-default-forwarding-method if we do this.

    I don't have a strong argument offhand for which way the default
should be set, but if it's (2), it might be useful to have a mini-buffer
message if the message has attachments suggesting that the user might
want to use (1) instead.

- Mark



(defun rmail-forward (resend)
  "Forward the current message to another user.
With prefix argument, \"resend\" the message instead of forwarding it;
see the documentation of `rmail-resend'."
  (interactive "P")
  (if (zerop rmail-current-message)
      (error "No message to forward"))
  (if resend
      (call-interactively 'rmail-resend)
    (let ((forward-buffer rmail-buffer)
          (msgnum rmail-current-message)
          (subject (concat "["
                           (let ((from (or (mail-fetch-field "From")
                                           (mail-fetch-field ">From"))))
                             (if from
                                 (concat (mail-strip-quoted-names from) ": ")
                               ""))
                           (or (mail-fetch-field "Subject") "")
                           "]")))
      (if (rmail-start-mail
           nil nil subject nil nil rmail-buffer
           (list (list 'rmail-mark-message
                       forward-buffer
                       (with-current-buffer rmail-buffer
                         (aref rmail-msgref-vector msgnum))
                       rmail-forwarded-attr-index))
           ;; If only one window, use it for the mail buffer.
           ;; Otherwise, use another window for the mail buffer
           ;; so that the Rmail buffer remains visible
           ;; and sending the mail will get back to it.
           (and (not rmail-mail-new-frame) (one-window-p t)))
          ;; The mail buffer is now current.
          (save-excursion
            ;; Insert after header separator--before signature if any.
            (rfc822-goto-eoh)
            (forward-line 1)
            (if (and rmail-enable-mime rmail-enable-mime-composing
                     rmail-insert-mime-forwarded-message-function)
                (prog1
                    (funcall rmail-insert-mime-forwarded-message-function
                             forward-buffer)
                  ;; rmail-insert-mime-forwarded-message-function
                  ;; works by inserting MML tags into forward-buffer.
                  ;; The MUA will need to convert it to MIME before
                  ;; sending.  mail-encode-mml tells them to do that.
                  ;; message.el does that automagically.
                  (or (eq mail-user-agent 'message-user-agent)
                      (setq mail-encode-mml t)))
              (insert "------- Start of forwarded message -------\n")
              ;; Quote lines with `- ' if they start with `-'.
              (let ((beg (point)) end)
                (setq end (point-marker))
                (set-marker-insertion-type end t)
                (insert-buffer-substring forward-buffer)
                (goto-char beg)
                (while (re-search-forward "^-" end t)
                  (beginning-of-line)
                  (insert "- ")
                  (forward-line 1))
                (goto-char end)
                (skip-chars-backward "\n")
                (if (< (point) end)
                    (forward-char 1))
                (delete-region (point) end)
                (set-marker end nil))
              (insert "------- End of forwarded message -------\n"))
            (push-mark))))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]