From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: mail-add-attachment Date: Sat, 03 Sep 2011 13:05:21 +0300 Message-ID: <838vq60wm6.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: lo.gmane.org X-Trace: dough.gmane.org 1315044349 22953 80.91.229.12 (3 Sep 2011 10:05:49 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 3 Sep 2011 10:05:49 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Sep 03 12:05:46 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Qzn6e-00020z-Us for ged-emacs-devel@m.gmane.org; Sat, 03 Sep 2011 12:05:45 +0200 Original-Received: from localhost ([::1]:36122 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qzn6e-0002Zt-4e for ged-emacs-devel@m.gmane.org; Sat, 03 Sep 2011 06:05:44 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:51848) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qzn6b-0002Zo-Ap for emacs-devel@gnu.org; Sat, 03 Sep 2011 06:05:42 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qzn6a-0000nW-4U for emacs-devel@gnu.org; Sat, 03 Sep 2011 06:05:41 -0400 Original-Received: from mtaout21.012.net.il ([80.179.55.169]:55507) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qzn6Z-0000nK-Ro for emacs-devel@gnu.org; Sat, 03 Sep 2011 06:05:40 -0400 Original-Received: from conversion-daemon.a-mtaout21.012.net.il by a-mtaout21.012.net.il (HyperSendmail v2007.08) id <0LQX00L00YMYAI00@a-mtaout21.012.net.il> for emacs-devel@gnu.org; Sat, 03 Sep 2011 13:05:19 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([84.229.83.44]) by a-mtaout21.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0LQX00LJPYOUAH00@a-mtaout21.012.net.il> for emacs-devel@gnu.org; Sat, 03 Sep 2011 13:05:19 +0300 (IDT) X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-Received-From: 80.179.55.169 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:143737 Archived-At: Is it okay to install this command at this time? I know we're in a feature freeze, but the new command is actually a very thin wrapper around code we already use elsewhere (gnus-dired.el and mml.el). The result will be that users of sendmail.el will be able to send MIME attachments. Here's the patch: === modified file 'lisp/mail/sendmail.el' --- lisp/mail/sendmail.el 2011-09-03 10:00:13 +0000 +++ lisp/mail/sendmail.el 2011-09-03 10:00:32 +0000 @@ -34,6 +34,21 @@ (autoload 'mml-to-mime "mml" "Translate the current buffer from MML to MIME.") +(autoload 'mml-attach-file "mml" + "Attach a file to the outgoing MIME message. +The file is not inserted or encoded until you send the message with +`\\[message-send-and-exit]' or `\\[message-send]'. + +FILE is the name of the file to attach. TYPE is its +content-type, a string of the form \"type/subtype\". DESCRIPTION +is a one-line description of the attachment. The DISPOSITION +specifies how the attachment is intended to be displayed. It can +be either \"inline\" (displayed automatically within the message +body) or \"attachment\" (separate from the body).") + +(autoload 'mm-default-file-encoding "mm-encode" + "Return the default encoding for FILE.") + (defgroup sendmail nil "Mail sending commands for Emacs." :prefix "mail-" @@ -355,6 +370,9 @@ The default value matches citations like (define-key map [menu-bar mail] (cons "Mail" (make-sparse-keymap "Mail"))) + (define-key map [menu-bar mail attachment] + '("Attach File" . mail-add-attachment)) + (define-key map [menu-bar mail fill] '("Fill Citation" . mail-fill-yanked-message)) @@ -700,6 +718,8 @@ Here are commands that move to a header \\[mail-signature] mail-signature (insert `mail-signature-file' file). \\[mail-yank-original] mail-yank-original (insert current message, in Rmail). \\[mail-fill-yanked-message] mail-fill-yanked-message (fill what was yanked). +\\[mail-attach-file] insert a text file into the message. +\\[mail-add-attachment] add to the message a file as a MIME attachment. Turning on Mail mode runs the normal hooks `text-mode-hook' and `mail-mode-hook' (in that order)." (make-local-variable 'mail-reply-action) @@ -1716,6 +1736,15 @@ If the current line has `mail-yank-prefi (insert-file-contents file) (or (bolp) (newline)) (goto-char start)))) + +(defun mail-add-attachment (file) + "Add a file as a MIME attachment to the end of the message." + (interactive "fAttach file: ") + (mml-attach-file file + (or (mm-default-file-encoding file) + "application/octet-stream") nil) + (setq mail-encode-mml t)) + ;; Put these commands last, to reduce chance of lossage from quitting ;; in middle of loading the file.