emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: patch: handle PS/PDF in Gnus


From: YAMAMOTO Mitsuharu
Subject: Re: patch: handle PS/PDF in Gnus
Date: Sun, 08 Jul 2007 12:15:09 +0900
User-agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (Shijō) APEL/10.6 Emacs/22.1.50 (sparc-sun-solaris2.8) MULE/5.0 (SAKAKI)

>>>>> On Fri, 6 Jul 2007 17:31:32 +0100, David Reitter <address@hidden> said:

> The Carbon framework has APIs for printing. You would have to output
> things on that end (i.e., implemented in C) and then you can call
> the standard print dialogs that will handle everything from
> outputting to PDF, choosing a printer and using the right driver,
> choosing a layout for the pages, etc.  That would be the correct
> way, and everything else is more or less a hack. It probably not
> worth implementing in Carbon, given that the Cocoa port is in the
> works.

As for the standard print dialogs in Carbon, I've tried an
experimental implementation before (for Mac OS X 10.3 and later).  The
function looks like:

  DEFUN ("mac-file-print-dialog", Fmac_file_print_dialog, 
Smac_file_print_dialog, 1, 3, 0,
         doc: /* Print file named FILENAME using the standard print dialog.
  The optional second argument NPAGES specifies the total number of
  pages; it will appear as the default in the To field of the dialog.
  The optional third argument MIME-TYPE specifies the mime type of the
  file.  It must be either a string, nil (auto-typed) or t (synonym of
  \"application/postscript\").  */)
       (filename, npages, mime_type)
       Lisp_Object filename, npages, mime_type;

and can be used as:

  (defun mac-ps-print-region (start end program
                                    &optional delete buffer display
                                    &rest args)
    (let (pages file)
      (save-excursion
        (goto-char start)
        (if (and (re-search-forward "^%%Trailer" nil end)
                 (re-search-forward "^%%Pages:\\s-*\\([0-9]+\\)" nil end))
            (setq pages (string-to-number (match-string 1)))))
      (setq file (make-temp-file "mac-ps-print"))
      (write-region start end file nil 'nomessage)
      (unwind-protect
          (mac-file-print-dialog file pages t)
        (delete-file file))))

  (setq ps-print-region-function 'mac-ps-print-region)

Of course, we need to discuss the specification of the function so
that it can be common to the platforms that support print dialogs (in
particular, recent Gtk+) in order to include such a feature in Emacs.

                                     YAMAMOTO Mitsuharu
                                address@hidden




reply via email to

[Prev in Thread] Current Thread [Next in Thread]