From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.user/17517 Path: news.gmane.org!not-for-mail From: SF Newsgroups: gmane.emacs.gnus.user Subject: mml-attach-file always at the end of the buffer Date: Sun, 22 Mar 2015 19:48:36 -0700 (PDT) Message-ID: <5a71fcaf-e84f-41fb-ab4c-d7adc4be9c83@googlegroups.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1427093037 13015 80.91.229.3 (23 Mar 2015 06:43:57 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 23 Mar 2015 06:43:57 +0000 (UTC) To: info-gnus-english@gnu.org Original-X-From: info-gnus-english-bounces+gegu-info-gnus-english=m.gmane.org@gnu.org Mon Mar 23 07:43:56 2015 Return-path: Envelope-to: gegu-info-gnus-english@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YZw5c-0005k6-7o for gegu-info-gnus-english@m.gmane.org; Mon, 23 Mar 2015 07:43:56 +0100 Original-Received: from localhost ([::1]:53943 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YZw5b-0007zT-Ci for gegu-info-gnus-english@m.gmane.org; Mon, 23 Mar 2015 02:43:55 -0400 X-Received: by 10.50.254.65 with SMTP id ag1mr10920252igd.7.1427078916952; Sun, 22 Mar 2015 19:48:36 -0700 (PDT) X-Received: by 10.182.81.69 with SMTP id y5mr760026obx.32.1427078916908; Sun, 22 Mar 2015 19:48:36 -0700 (PDT) Original-Path: usenet.stanford.edu!z20no3400727igj.0!news-out.google.com!qk8ni62932igc.0!nntp.google.com!z20no2292091igj.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.gnus Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=135.23.124.91; posting-account=LnI6_AoAAAAP4UPVPgd7RC7Ogp-JZPdU Original-NNTP-Posting-Host: 135.23.124.91 User-Agent: G2/1.0 Injection-Date: Mon, 23 Mar 2015 02:48:36 +0000 Original-Xref: usenet.stanford.edu gnu.emacs.gnus:88645 X-Mailman-Approved-At: Mon, 23 Mar 2015 02:43:50 -0400 X-BeenThere: info-gnus-english@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Announcements and discussions for GNUS, the GNU Emacs Usenet newsreader \(in English\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: info-gnus-english-bounces+gegu-info-gnus-english=m.gmane.org@gnu.org Original-Sender: info-gnus-english-bounces+gegu-info-gnus-english=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.gnus.user:17517 Archived-At: Hi, For some time already, I wanted to extend mml-attach-file, so it always attaches the file at the end of the buffer. I'm sure this could also be done with a defadvice to move to the end of the buffer and then return upon exit, nevertheless here's my solution for it, since I haven't tinkered yet a lot with defadvice. Sebastian (setq mml-attach-files-at-end t) (defun mml-attach-file (file &optional type description disposition) "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]' in Message mode, or `\\[mail-send-and-exit]' or `\\[mail-send]' in Mail mode. 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)." (interactive (let* ((file (mml-minibuffer-read-file "Attach file: ")) (type (mml-minibuffer-read-type file)) (description (mml-minibuffer-read-description)) (disposition (mml-minibuffer-read-disposition type nil file))) (list file type description disposition))) ;; If in the message header, attach at the end and leave point unchanged. (let ((head (unless (and (message-in-body-p) (not mml-attach-files-at-end)) (point)))) (if (or head mml-attach-files-at-end) (goto-char (point-max))) (mml-insert-empty-tag 'part 'type type ;; icicles redefines read-file-name and returns a ;; string w/ text properties :-/ 'filename (mm-substring-no-properties file) 'disposition (or disposition "attachment") 'description description) ;; When using Mail mode, make sure it does the mime encoding ;; when you send the message. (or (eq mail-user-agent 'message-user-agent) (setq mail-encode-mml t)) (when (or head mml-attach-files-at-end) (unless (pos-visible-in-window-p) (message "The file \"%s\" has been attached at the end of the message" (file-name-nondirectory file))) (goto-char head))))