Gnus development mailing list
 help / color / mirror / Atom feed
From: Reiner Steib <4.uce.03.r.s@nurfuerspam.de>
Subject: Re: Disable mailcap support
Date: Mon, 29 Sep 2003 21:35:07 +0200	[thread overview]
Message-ID: <v91xtzxuac.fsf@marauder.physik.uni-ulm.de> (raw)
In-Reply-To: <20030928161139.GA31465@deneb.enyo.de>

On Sun, Sep 28 2003, Florian Weimer wrote:

> After some discussion with RMS after he posted
> <mailman.944.1061837187.29551.info-gnu@gnu.org>, we have come to the
> conclusion that it might be a good idea to disable mailcap processing.
>
> Reiner Steib kindly wrote the patch reproduced, which makes Gnus'
> behavior more configurable.

Here's another patch, allowing additional regexp and function values
for `mm-enable-external':

--8<---------------cut here---------------start------------->8---
--- mm-decode.el.~6.94.~	Thu Aug 28 11:06:58 2003
+++ mm-decode.el	Mon Sep 29 21:19:14 2003
@@ -151,6 +151,27 @@
   :type 'boolean
   :group 'mime-display)
 
+(defcustom mm-enable-external 'ask
+  "Indicate which external MIME handlers should be used.
+
+If t, all defined external MIME handlers are used.  If nil, files are saved by
+`mailcap-save-binary-file'.  If it is the symbol `ask', you are prompted
+before the external MIME handler is invoked.
+
+If `mm-enable-external' is a function, that function is called with three
+arguments: the MIME type, the method and the filename for this MIME handle.
+The external MIME handler is invoked, iff this function returns non-nil.
+
+If if `mm-enable-external' is a regular expression, the external MIME handler
+is invoked, iff the MIME type is matches the expression."
+  :version "21.4"
+  :type '(choice (const :tag "Always" t)
+		 (const :tag "Never" nil)
+		 (const :tag "Ask" ask)
+		 (function :tag "A function")
+		 (regexp :tag "Regexp"))
+  :group 'mime-display)
+
 (defcustom mm-inline-media-tests
   '(("image/jpeg"
      mm-inline-image
@@ -619,7 +640,13 @@
     (if (mm-handle-displayed-p handle)
 	(mm-remove-part handle)
       (let* ((type (mm-handle-media-type handle))
-	     (method (mailcap-mime-info type)))
+	     (method (mailcap-mime-info type))
+	     (filename (or (mail-content-type-get
+			    (mm-handle-disposition handle) 'filename)
+			   (mail-content-type-get
+			    (mm-handle-type handle) 'name)
+			   "<file>"))
+	     (external mm-enable-external))
 	(if (and (mm-inlinable-p handle)
 		 (mm-inlined-p handle))
 	    (progn
@@ -634,8 +661,28 @@
 		  (forward-line 1)
 		  (mm-insert-inline handle (mm-get-part handle))
 		  'inline)
-	      (mm-display-external
-	       handle (or method 'mailcap-save-binary-file)))))))))
+	      (if (and method ;; If nil, we always use "save".
+		       (stringp method) ;; 'mailcap-save-binary-file
+		       (or (and (eq mm-enable-external 'ask)
+				(y-or-n-p
+				 (concat
+				  "Display part (" type
+				  ") using external program \""
+				  (format method filename) "\"? ")))
+			   (and (stringp mm-enable-external)
+				(string-match mm-enable-external type))
+			   (and (symbolp mm-enable-external)
+				(fboundp mm-enable-external)
+				(funcall mm-enable-external
+					 type method filename))
+			   nil))
+		  (setq external t)
+		(setq external nil))
+	      (if external
+		  (mm-display-external
+		   handle (or method 'mailcap-save-binary-file))
+		(mm-display-external
+		 handle 'mailcap-save-binary-file)))))))))
 
 (defun mm-display-external (handle method)
   "Display HANDLE using METHOD."
@@ -656,7 +703,8 @@
 	    (mm-set-buffer-file-coding-system mm-binary-coding-system)
 	    (insert-buffer-substring cur)
 	    (goto-char (point-min))
-	    (message "Viewing with %s" method)
+	    (when method
+	      (message "Viewing with %s" method))
 	    (let ((mm (current-buffer))
 		  (non-viewer (assq 'non-viewer
 				    (mailcap-mime-info
--8<---------------cut here---------------end--------------->8---

The last hunk is independent from the current subject: It makes no
sense to say "Viewing with nil" when the part is saved to disk.

> I'd like to see 'mm-enable-external' disabled in the default
> configuration, but my judgement in such matters is typically quite
> drastic.  Comments?

`mm-enable-external' is Gnus' current behavior.  My preference is
`ask' which is not as drastic as Florian's suggestion, but it allows
the user to see which external program will be invoked.

Maybe we should also think about this comment in `mailcap.el' before
the defvar of `mailcap-mime-data':

;; Postpone using defcustom for this as it's so big and we essentially
;; have to have two copies of the data around then.  Perhaps just
;; customize the Lisp viewers and rely on the normal configuration
;; files for the rest?  -- fx

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo--- PGP key available via WWW   http://rsteib.home.pages.de/




  parent reply	other threads:[~2003-09-29 19:35 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-28 16:11 Florian Weimer
2003-09-28 22:56 ` Jesper Harder
2003-09-29 18:04   ` Florian Weimer
2003-09-29 21:47     ` Jesper Harder
2003-11-09 15:35       ` Florian Weimer
2004-01-03 19:28       ` Reiner Steib
2003-09-29 19:35 ` Reiner Steib [this message]
2003-09-29 21:27   ` Jesper Harder
2003-09-30 18:04     ` Reiner Steib
2003-09-30 23:37       ` Jesper Harder
2003-10-02 18:02         ` Reiner Steib
2003-10-02 22:25           ` Jesper Harder
2003-10-03 18:10             ` Reiner Steib
2003-10-17 17:17           ` Lars Magne Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=v91xtzxuac.fsf@marauder.physik.uni-ulm.de \
    --to=4.uce.03.r.s@nurfuerspam.de \
    --cc=reiner.steib@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).