* gnus-dired.el (gnus-dired-find-file-mailcap): Correctly handle
authorShengHuo ZHU <zsh@cs.rochester.edu>
Sat, 2 Feb 2002 21:57:49 +0000 (21:57 +0000)
committerShengHuo ZHU <zsh@cs.rochester.edu>
Sat, 2 Feb 2002 21:57:49 +0000 (21:57 +0000)
directories.
(gnus-dired-print): New function.

* gnus-art.el (gnus-mime-print-part): Add argument filename. Call
ps-despool.

lisp/ChangeLog
lisp/gnus-art.el
lisp/gnus-dired.el

index 99e2c03..0840ad4 100644 (file)
@@ -1,3 +1,12 @@
+2002-02-02  ShengHuo ZHU  <zsh@cs.rochester.edu>
+
+       * gnus-dired.el (gnus-dired-find-file-mailcap): Correctly handle
+       directories.
+       (gnus-dired-print): New function.
+
+       * gnus-art.el (gnus-mime-print-part): Add argument filename. Call
+       ps-despool.
+
 2002-02-02  Simon Josefsson  <jas@extundo.com>
 
        * gnus-dired.el (turn-on-gnus-dired-mode): Autoload.  Make defun.
index 695cceb..2615eb0 100644 (file)
@@ -3751,9 +3751,9 @@ General format specifiers can also be used.  See
        (setq buffer-file-name nil))
       (goto-char (point-min)))))
 
-(defun gnus-mime-print-part (&optional handle)
+(defun gnus-mime-print-part (&optional handle filename)
   "Print the MIME part under point."
-  (interactive)
+  (interactive (list nil (ps-print-preprint current-prefix-arg)))
   (gnus-article-check-buffer)
   (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
         (contents (and handle (mm-get-part handle)))
@@ -3774,7 +3774,8 @@ General format specifiers can also be used.  See
              (delete-file file))
          (with-temp-buffer
            (insert contents)
-           (gnus-print-buffer))))))
+           (gnus-print-buffer))
+         (ps-despool filename)))))
 
 (defun gnus-mime-inline-part (&optional handle arg)
   "Insert the MIME part under point into the current buffer."
index ab5298a..14104f4 100644 (file)
@@ -59,7 +59,9 @@
 
   (gnus-define-keys gnus-dired-mode-map
     "\C-c\C-a" gnus-dired-attach
-    "\C-c\C-f" gnus-dired-find-file-mailcap))
+    "\C-c\C-f" gnus-dired-find-file-mailcap
+    "\C-cP" gnus-dired-print
+    ))
 
 (defun gnus-dired-mode (&optional arg)
   "Minor mode for intersections of gnus and dired.
@@ -138,10 +140,10 @@ If ARG is non-nil, open it in a new buffer."
                (file-name-sans-versions (dired-get-filename) t)
                current-prefix-arg))
   (mailcap-parse-mailcaps)
-  (if (and (file-exists-p file-name)
-          (not (file-directory-p file-name)))
+  (if (file-exists-p file-name)
       (let (mime-type method)
        (if (and (not arg)
+                (not (file-directory-p file-name))
                 (string-match "\\.[^\\.]+$" file-name)
                 (setq mime-type
                       (mailcap-extension-to-mime 
@@ -163,6 +165,43 @@ If ARG is non-nil, open it in a new buffer."
        (error "File is a symlink to a nonexistent target")
       (error "File no longer exists; type `g' to update Dired buffer"))))
 
+(defun gnus-dired-print (&optional file-name print-to)
+  "In dired, print FILE-NAME according to the mailcap file.
+
+If there is no print command, print in a PostScript image. If the
+optional argument PRINT-TO is nil, send the image to the printer. If
+PRINT-TO is a string, save the PostScript image in a file with that
+name.  If PRINT-TO is a number, prompt the user for the name of the
+file to save in."
+  (interactive (list
+               (file-name-sans-versions (dired-get-filename) t)
+               (ps-print-preprint current-prefix-arg)))
+  (mailcap-parse-mailcaps)
+  (cond 
+   ((file-directory-p file-name)
+    (error "Can't print a directory"))
+   ((file-exists-p file-name)
+    (let (mime-type method)
+      (if (and (string-match "\\.[^\\.]+$" file-name)
+              (setq mime-type
+                    (mailcap-extension-to-mime 
+                     (match-string 0 file-name)))
+              (stringp 
+               (setq method (mailcap-mime-info mime-type "print"))))
+         (call-process shell-file-name nil
+                       (generate-new-buffer " *mm*")
+                       nil
+                       shell-command-switch
+                       (mm-mailcap-command method file-name mime-type))
+       (with-temp-buffer
+         (insert-file-contents file-name)
+         (gnus-print-buffer))
+       (ps-despool print-to))))
+   ((file-symlink-p file-name)
+     (error "File is a symlink to a nonexistent target"))
+    (t
+     (error "File no longer exists; type `g' to update Dired buffer"))))
+
 (provide 'gnus-dired)
 
 ;;; gnus-dired.el ends here