Function: gnus-dired-print

gnus-dired-print is an interactive and byte-compiled function defined in gnus-dired.el.gz.

Signature

(gnus-dired-print &optional FILE-NAME PRINT-TO)

Documentation

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.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/gnus-dired.el.gz
(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))
	       dired-mode)
  (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"
						'no-decode))))
	  (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)
	  (if (eq gnus-dired-mail-mode 'gnus-user-agent)
	      (gnus-print-buffer)
	    ;; FIXME:
	    (error "MIME print only implemented via Gnus")))
	(ps-despool print-to))))
   ((file-symlink-p file-name)
    (error "File is a symlink to a nonexistent target"))
   (t
    (error (substitute-command-keys
            "File no longer exists; type \\`g' to update Dired buffer")))))