From 7e6315f5e5339cc5ad13338702801ced3ea06fad Mon Sep 17 00:00:00 2001 From: ShengHuo ZHU Date: Sat, 2 Feb 2002 21:57:49 +0000 Subject: [PATCH] * 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. --- lisp/ChangeLog | 9 +++++++++ lisp/gnus-art.el | 7 ++++--- lisp/gnus-dired.el | 45 ++++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 55 insertions(+), 6 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 99e2c0307..0840ad431 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,12 @@ +2002-02-02 ShengHuo ZHU + + * 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 * gnus-dired.el (turn-on-gnus-dired-mode): Autoload. Make defun. diff --git a/lisp/gnus-art.el b/lisp/gnus-art.el index 695cceb32..2615eb0c5 100644 --- a/lisp/gnus-art.el +++ b/lisp/gnus-art.el @@ -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." diff --git a/lisp/gnus-dired.el b/lisp/gnus-dired.el index ab5298a87..14104f4ce 100644 --- a/lisp/gnus-dired.el +++ b/lisp/gnus-dired.el @@ -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 -- 2.25.1