Import Oort Gnus v0.09.
[elisp/gnus.git-] / lisp / mm-decode.el
index b38ac3b..0e76d92 100644 (file)
@@ -141,8 +141,8 @@ the safe url names.  The value of the variable `w3m-safe-url-regexp'
 will be bound with this value.  You may set this value to nil if you
 consider all the urls to be safe."
   :type '(choice (regexp :tag "Regexp")
-                (const :tag "All URLs are safe" nil)
-  :group 'mime-display))
+                (const :tag "All URLs are safe" nil))
+  :group 'mime-display)
 
 (defcustom mm-inline-text-html-with-w3m-keymap t
   "If non-nil, use emacs-w3m command keys in the article buffer."
@@ -700,36 +700,33 @@ external if displayed external."
          (message "Viewing with %s" method)
          (cond
           (needsterm
-           (unwind-protect
-               (if window-system
-                   (start-process "*display*" nil
-                                  mm-external-terminal-program
-                                  "-e" shell-file-name
-                                  shell-command-switch
-                                  (mm-mailcap-command
-                                   method file (mm-handle-type handle)))
-                 (require 'term)
-                 (require 'gnus-win)
-                 (set-buffer
-                  (setq buffer
-                        (make-term "display"
-                                   shell-file-name
-                                   nil
-                                   shell-command-switch
-                                   (mm-mailcap-command
-                                    method file
-                                    (mm-handle-type handle)))))
-                 (term-mode)
-                 (term-char-mode)
-                 (set-process-sentinel
-                  (get-buffer-process buffer)
-                  `(lambda (process state)
-                     (if (eq 'exit (process-status process))
-                         (gnus-configure-windows
-                          ',gnus-current-window-configuration))))
-                 (gnus-configure-windows 'display-term))
-             (mm-handle-set-external-undisplayer handle (cons file buffer)))
-           (message "Displaying %s..." (format method file))
+           (let ((command (mm-mailcap-command
+                           method file (mm-handle-type handle))))
+             (unwind-protect
+                 (if window-system
+                     (start-process "*display*" nil
+                                    mm-external-terminal-program
+                                    "-e" shell-file-name
+                                    shell-command-switch command)
+                   (require 'term)
+                   (require 'gnus-win)
+                   (set-buffer
+                    (setq buffer
+                          (make-term "display"
+                                     shell-file-name
+                                     nil
+                                     shell-command-switch command)))
+                   (term-mode)
+                   (term-char-mode)
+                   (set-process-sentinel
+                    (get-buffer-process buffer)
+                    `(lambda (process state)
+                       (if (eq 'exit (process-status process))
+                           (gnus-configure-windows
+                            ',gnus-current-window-configuration))))
+                   (gnus-configure-windows 'display-term))
+               (mm-handle-set-external-undisplayer handle (cons file buffer)))
+             (message "Displaying %s..." command))
            'external)
           (copiousoutput
            (with-current-buffer outbuf
@@ -756,17 +753,17 @@ external if displayed external."
                   (ignore-errors (kill-buffer buffer))))))
            'inline)
           (t
-           (unwind-protect
-               (start-process "*display*"
-                              (setq buffer
-                                    (generate-new-buffer " *mm*"))
-                              shell-file-name
-                              shell-command-switch
-                              (mm-mailcap-command
-                               method file (mm-handle-type handle)))
-             (mm-handle-set-external-undisplayer
-              handle (cons file buffer)))
-           (message "Displaying %s..." (format method file))
+           (let ((command (mm-mailcap-command
+                           method file (mm-handle-type handle))))
+             (unwind-protect
+                 (start-process "*display*"
+                                (setq buffer
+                                      (generate-new-buffer " *mm*"))
+                                shell-file-name
+                                shell-command-switch command)
+               (mm-handle-set-external-undisplayer
+                handle (cons file buffer)))
+             (message "Displaying %s..." command))
            'external)))))))
 
 (defun mm-mailcap-command (method file type-list)
@@ -774,7 +771,8 @@ external if displayed external."
        (beg 0)
        (uses-stdin t)
        out sub total)
-    (while (string-match "%{\\([^}]+\\)}\\|%s\\|%t\\|%%" method beg)
+    (while (string-match "%{\\([^}]+\\)}\\|'%s'\\|\"%s\"\\|%s\\|%t\\|%%"
+                        method beg)
       (push (substring method beg (match-beginning 0)) out)
       (setq beg (match-end 0)
            total (match-string 0 method)
@@ -782,7 +780,10 @@ external if displayed external."
       (cond
        ((string= total "%%")
        (push "%" out))
-       ((string= total "%s")
+       ((or (string= total "%s")
+           ;; We do our own quoting.
+           (string= total "'%s'")
+           (string= total "\"%s\""))
        (setq uses-stdin nil)
        (push (mm-quote-arg
               (gnus-map-function mm-path-name-rewrite-functions file)) out))