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: Re: mail-add-attachment Date: Thu, 08 Sep 2011 19:38:55 +0300 Message-ID: <8339g76lb4.fsf@gnu.org> References: <838vq60wm6.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: lo.gmane.org X-Trace: dough.gmane.org 1315499966 7192 80.91.229.12 (8 Sep 2011 16:39:26 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 8 Sep 2011 16:39:26 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Sep 08 18:39:22 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 1R1hdJ-0003sR-Rr for ged-emacs-devel@m.gmane.org; Thu, 08 Sep 2011 18:39:21 +0200 Original-Received: from localhost ([::1]:59392 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R1hdJ-0005FZ-83 for ged-emacs-devel@m.gmane.org; Thu, 08 Sep 2011 12:39:21 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:60197) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R1hdG-0005FK-In for emacs-devel@gnu.org; Thu, 08 Sep 2011 12:39:20 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R1hdE-0006xk-TK for emacs-devel@gnu.org; Thu, 08 Sep 2011 12:39:18 -0400 Original-Received: from mtaout22.012.net.il ([80.179.55.172]:51322) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R1hdE-0006xW-L1 for emacs-devel@gnu.org; Thu, 08 Sep 2011 12:39:16 -0400 Original-Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0LR700300PY6PZ00@a-mtaout22.012.net.il> for emacs-devel@gnu.org; Thu, 08 Sep 2011 19:38:50 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([77.126.9.62]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0LR700271Q8POIK0@a-mtaout22.012.net.il> for emacs-devel@gnu.org; Thu, 08 Sep 2011 19:38:50 +0300 (IDT) In-reply-to: <838vq60wm6.fsf@gnu.org> X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-Received-From: 80.179.55.172 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:143819 Archived-At: Ping! > Date: Sat, 03 Sep 2011 13:05:21 +0300 > From: Eli Zaretskii > > 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. >