From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/50462 Path: main.gmane.org!not-for-mail From: Reiner Steib <4.uce.03.r.s@nurfuerspam.de> Newsgroups: gmane.emacs.gnus.general Subject: gnus-mime-strip-part: removing attachments Date: Sat, 01 Mar 2003 00:06:25 +0100 Sender: owner-ding@hpc.uh.edu Message-ID: Reply-To: reiner.steib@gmx.de NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1046473754 28827 80.91.224.249 (28 Feb 2003 23:09:14 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Fri, 28 Feb 2003 23:09:14 +0000 (UTC) Return-path: Original-Received: from malifon.math.uh.edu ([129.7.128.13]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18otcW-0007TJ-00 for ; Sat, 01 Mar 2003 00:08:48 +0100 Original-Received: from sina.hpc.uh.edu ([129.7.128.10] ident=lists) by malifon.math.uh.edu with esmtp (Exim 3.20 #1) id 18otaY-0007pB-00; Fri, 28 Feb 2003 17:06:46 -0600 Original-Received: by sina.hpc.uh.edu (TLB v0.09a (1.20 tibbs 1996/10/09 22:03:07)); Fri, 28 Feb 2003 17:07:45 -0600 (CST) Original-Received: from sclp3.sclp.com (sclp3.sclp.com [66.230.238.2]) by sina.hpc.uh.edu (8.9.3/8.9.3) with SMTP id RAA20735 for ; Fri, 28 Feb 2003 17:07:32 -0600 (CST) Original-Received: (qmail 67376 invoked by alias); 28 Feb 2003 23:06:28 -0000 Original-Received: (qmail 67371 invoked from network); 28 Feb 2003 23:06:28 -0000 Original-Received: from theotp5.physik.uni-ulm.de (134.60.10.145) by 66.230.238.6 with SMTP; 28 Feb 2003 23:06:28 -0000 Original-Received: (from ste@localhost) by theotp5.physik.uni-ulm.de (8.11.2/8.11.2) id h1SN6QB06433; Sat, 1 Mar 2003 00:06:26 +0100 X-Authentication-Warning: theotp5.physik.uni-ulm.de: ste set sender to reiner.steib@physik.uni-ulm.de using -f Original-To: ding@gnus.org X-Face: .*T0'iU(sujq_j9\J>-d4fg;N/1++U#U$_5ii6k.=|"-n'?5O:Hyz&wi'-!I~,}7~GgT=0S /&-R5sbkNy5+Xo1y{Tw2KKxi@Xh"g@]Qc|.U<*]WDd)qvGowFDvfU1F]{EDho:7P0@|oOD=Bc{K4?> WP68K[Mx:}=`ZT'6g4'f+g?;`vri2!)xGy}3:=l'(/Cea0l4lo^H5#@/Z3ev Mail-Copies-To: nobody Mail-Followup-To: ding@gnus.org User-Agent: Gnus/5.090016 (Oort Gnus v0.16) Emacs/21.2.95 (gnu/linux) Precedence: list X-Majordomo: 1.94.jlt7 Xref: main.gmane.org gmane.emacs.gnus.general:50462 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:50462 Hi, some time ago a function to remove an attachment has been requested[1]. I like the idea (it's a feature that even Pine has!). Here's my draft version of `gnus-mime-strip-part', which is in fact only a modification of `gnus-mime-save-part-and-strip'. I would appreciate comments. I intend to add it to `gnus-art.el' unless someone objects. --8<---------------cut here---------------start------------->8--- (defun gnus-mime-strip-part () "Strip the MIME part under point." (interactive) (gnus-article-check-buffer) (let* ((data (get-text-property (point) 'gnus-data)) (handles gnus-article-mime-handles) (none "(none)") (description (or (mail-decode-encoded-word-string (or (mm-handle-description data) none)))) (filename (or (mail-content-type-get (mm-handle-disposition data) 'filename) none)) (type (mm-handle-media-type data))) (if (mm-multiple-handles gnus-article-mime-handles) (error "This function is not implemented")) (with-current-buffer (mm-handle-buffer data) (let ((bsize (format "%s" (buffer-size)))) (erase-buffer) (insert (concat "<#REMOVETHISpart type=text/plain nofile=yes disposition=attachment" " description=\"Deleted attachment (" bsize " Byte)\">" ",----\n" "| The following attachment has been deleted:\n" "|\n" "| Type: " type "\n" "| Filename: " filename "\n" "| Size (encoded): " bsize " Byte\n" "| Description: " description "\n" "`----\n" "<#/REMOVETHISpart>")) (setcdr data (cdr (mm-make-handle nil `("text/plain")))))) (set-buffer gnus-summary-buffer) ;; FIXME: maybe some of the following code (borrowed from ;; `gnus-mime-save-part-and-strip') isn't necessary? (gnus-article-edit-article `(lambda () (erase-buffer) (let ((mail-parse-charset (or gnus-article-charset ',gnus-newsgroup-charset)) (mail-parse-ignored-charsets (or gnus-article-ignored-charsets ',gnus-newsgroup-ignored-charsets)) (mbl mml-buffer-list)) (setq mml-buffer-list nil) (insert-buffer gnus-original-article-buffer) (mime-to-mml ',handles) (setq gnus-article-mime-handles nil) (let ((mbl1 mml-buffer-list)) (setq mml-buffer-list mbl) (set (make-local-variable 'mml-buffer-list) mbl1)) ;; LOCAL argument of add-hook differs between GNU Emacs ;; and XEmacs. make-local-hook makes sure they are local. (make-local-hook 'kill-buffer-hook) (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))) `(lambda (no-highlight) (let ((mail-parse-charset (or gnus-article-charset ',gnus-newsgroup-charset)) (message-options message-options) (message-options-set-recipient) (mail-parse-ignored-charsets (or gnus-article-ignored-charsets ',gnus-newsgroup-ignored-charsets))) (mml-to-mime) (mml-destroy-buffers) (remove-hook 'kill-buffer-hook 'mml-destroy-buffers t) (kill-local-variable 'mml-buffer-list)) (gnus-summary-edit-article-done ,(or (mail-header-references gnus-current-headers) "") ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))) ;; Not in `gnus-mime-save-part-and-strip': (gnus-article-edit-done) (gnus-summary-expand-window) (gnus-summary-show-article)) --8<---------------cut here---------------end--------------->8--- I'm afraid Gnus could get confused about the part-tags in this function, so I added "REMOVETHIS". Of course you should delete this, when testing the function. Bye, Reiner. [1] | From: Lars Magne Ingebrigtsen | Subject: Re: removing attachments in stored messages | Newsgroups: gnu.emacs.gnus | Date: Tue, 07 Jan 2003 05:42:20 +0100 | Message-ID: | | Julien Avarre writes: | | > Is there an easy way to remove attachment from a stored email in the | > nnml backend when you are in the summary ? in the article-mode ? | | Sure. Just `e' to edit the message, and remove the attachment. -- ,,, (o o) ---ooO-(_)-Ooo--- PGP key available via WWW http://rsteib.home.pages.de/