help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Printer definition


From: Stefan Monnier
Subject: Re: Printer definition
Date: Tue, 24 May 2011 20:01:57 -0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

> The best thing would be to trap the error (the way it does with pr)
> and signal the user.

I don't know what trapping you're referring to.

> No response meant I had to manually debug the code.  The man page for
> the lpr that I use specifically says that it does not honor
> the -d option.

I've installed the change below (for the future Emacs-24), which makes
print-buffer echo the output of lp/lpr.  So the warning about "-d" not
being supported is not silently discarded any more (it may still go
unnoticed, of course, but that's another issue).


        Stefan


=== modified file 'lisp/lpr.el'
--- lisp/lpr.el 2011-01-26 08:36:39 +0000
+++ lisp/lpr.el 2011-05-06 16:33:11 +0000
@@ -258,9 +258,13 @@
                             lpr-page-header-switches)))
            (setq start (point-min)
                  end   (point-max))))
+      (let ((buf (current-buffer)))
+        (with-temp-buffer
+          (let ((tempbuf (current-buffer)))
+            (with-current-buffer buf
       (apply (or print-region-function 'call-process-region)
             (nconc (list start end lpr-command
-                         nil nil nil)
+                                  nil tempbuf nil)
                    (and lpr-add-switches
                         (list "-J" name))
                    ;; These belong in pr if we are using that.
@@ -269,10 +273,15 @@
                    (and (stringp printer-name)
                         (list (concat lpr-printer-switch
                                       printer-name)))
-                   nswitches))
+                            nswitches))))
       (if (markerp end)
          (set-marker end nil))
-      (message "Spooling%s...done" switch-string))))
+          (message "Spooling%s...done%s%s" switch-string
+                   (case (count-lines (point-min) (point-max))
+                     (0 "")
+                     (1 ": ")
+                     (t ":\n"))
+                   (buffer-string)))))))
 
 ;; This function copies the text between start and end
 ;; into a new buffer, makes that buffer current.



reply via email to

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