all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Printer definition
@ 2011-05-02 19:10 Ed Reingold
  2011-05-03 15:10 ` Ed Reingold
  0 siblings, 1 reply; 6+ messages in thread
From: Ed Reingold @ 2011-05-02 19:10 UTC (permalink / raw)
  To: help-gnu-emacs

I cannot get the default printer/command working!  I tried the
following:

        /usr/local/emacs-23.3/bin/emacs -q -l em23-printer-test

where the file em23-printer-test contains the two lines

      (setq printer-name "HP4050HM_FDx")
      (setq lpr-command "lpr")

and then try to print a buffer, but nothing happens.  When I do

       lpr -PHP4050HM_FDx .login

in a shell, it works fine.  What am I doing wrong?  I have the same
problems
when trying to use ps-print.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Printer definition
  2011-05-02 19:10 Printer definition Ed Reingold
@ 2011-05-03 15:10 ` Ed Reingold
  2011-05-04  0:50   ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Ed Reingold @ 2011-05-03 15:10 UTC (permalink / raw)
  To: help-gnu-emacs

The problem is that, for some reason, the flag to the lpr command was
set to "-d"
instead of  "-P" even though Emacs knows it's a Unix-like system
(Solaris).  Debugging
this meant going through the ELisp code in lpr.el and ps-print.el,
something that I
should never have had to do.

On May 2, 2:10 pm, Ed Reingold <edward.reing...@gmail.com> wrote:
> I cannot get the default printer/command working!  I tried the
> following:
>
>         /usr/local/emacs-23.3/bin/emacs -q -l em23-printer-test
>
> where the file em23-printer-test contains the two lines
>
>       (setq printer-name "HP4050HM_FDx")
>       (setq lpr-command "lpr")
>
> and then try to print a buffer, but nothing happens.  When I do
>
>        lpr -PHP4050HM_FDx .login
>
> in a shell, it works fine.  What am I doing wrong?  I have the same
> problems
> when trying to use ps-print.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Printer definition
  2011-05-03 15:10 ` Ed Reingold
@ 2011-05-04  0:50   ` Stefan Monnier
  2011-05-06  0:26     ` Ed Reingold
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2011-05-04  0:50 UTC (permalink / raw)
  To: help-gnu-emacs

> The problem is that, for some reason, the flag to the lpr command was
> set to "-d"
> instead of  "-P" even though Emacs knows it's a Unix-like system
> (Solaris).

"lp -d<printer>" is a standard Unix command, and lpr.el apparently
thinks it's the right command to use for your system.  IIRC Solaris
indeed has an "lp" command (tho my experience with Solaris is from many
years ago), so normally all you have to do is (setq printer-name
"HP4050HM_FDx").  Have you tried to simply remove the (setq lpr-command
"lpr")?

Admittedly, maybe lpr-printer-switch should be automatically updated to
"-P" if you set lpr-command to "lpr".


        Stefan


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Printer definition
  2011-05-04  0:50   ` Stefan Monnier
@ 2011-05-06  0:26     ` Ed Reingold
  2011-05-06 16:40       ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Ed Reingold @ 2011-05-06  0:26 UTC (permalink / raw)
  To: help-gnu-emacs

The best thing would be to trap the error (the way it does with pr)
and signal the user.  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.

he problem is that, for some reason, the flag to the lpr command was
> > set to "-d"
> > instead of  "-P" even though Emacs knows it's a Unix-like system
> > (Solaris).
>
> "lp -d<printer>" is a standard Unix command, and lpr.el apparently
> thinks it's the right command to use for your system.  IIRC Solaris
> indeed has an "lp" command (tho my experience with Solaris is from many
> years ago), so normally all you have to do is (setq printer-name
> "HP4050HM_FDx").  Have you tried to simply remove the (setq lpr-command
> "lpr")?
>
> Admittedly, maybe lpr-printer-switch should be automatically updated to
> "-P" if you set lpr-command to "lpr".
>
>         Stefan



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Printer definition
  2011-05-06  0:26     ` Ed Reingold
@ 2011-05-06 16:40       ` Stefan Monnier
  2011-05-06 22:19         ` Ed Reingold
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2011-05-06 16:40 UTC (permalink / raw)
  To: help-gnu-emacs

> 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.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Printer definition
  2011-05-06 16:40       ` Stefan Monnier
@ 2011-05-06 22:19         ` Ed Reingold
  0 siblings, 0 replies; 6+ messages in thread
From: Ed Reingold @ 2011-05-06 22:19 UTC (permalink / raw)
  To: help-gnu-emacs

On May 6, 11:40 am, Stefan Monnier <monn...@iro.umontreal.ca> wrote:
> > 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.

I meant that when pr fails, the failure message gets printed (in my
debugging
I got the the flags wrong once time, which is how I discovered that).

I think that anytime call-process-region (or similar) is called and
fails, the failure
should sent on to the user.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-05-06 22:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-02 19:10 Printer definition Ed Reingold
2011-05-03 15:10 ` Ed Reingold
2011-05-04  0:50   ` Stefan Monnier
2011-05-06  0:26     ` Ed Reingold
2011-05-06 16:40       ` Stefan Monnier
2011-05-06 22:19         ` Ed Reingold

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.