[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [h-e-w] Adding to ps-print-hook problems
From: |
Harig, Mark A. |
Subject: |
RE: [h-e-w] Adding to ps-print-hook problems |
Date: |
Mon, 16 Sep 2002 20:06:21 -0400 |
-----Original Message-----
From: Jeff Rancier [mailto:address@hidden
Sent: Monday, September 16, 2002 4:52 PM
To: address@hidden; David Vanderschel; Peter Davis
Subject: Re: [h-e-w] Adding to ps-print-hook problems
I changed the fourth argument to non-nil, so the value returned wasn't a
string, but a lisp object, and that worked:
(defun jbr-ps-print-n-up-hook ()
(let ((number-of-pages
(read-from-minibuffer
"N-up number of pages: " "1" nil t nil nil nil)))
(if number-of-pages
(setq ps-n-up-printing number-of-pages))))
(add-hook 'ps-print-hook 'jbr-ps-print-n-up-hook)
I'm assuming that based on the following operation (the setq), the
interpreter cast the *generic* object type to the correct type? Integer
or numeric?
Jeff
=========
You might consider using 'read-no-blanks-input' since no
spaces should be allowed in the number, and the function
is simpler:
(defun jbr-ps-print-n-up-hook ()
(let ((number-of-pages
(read-no-blanks-input "N-up number of pages: " "1")))
(if number-of-pages
(setq ps-n-up-printing number-of-pages))))
According to ps-print.el:
;; The variable `ps-n-up-printing' specifies the number of pages per
sheet of
;; paper. The value specified must be between 1 and 100. The default
is 1.
;;
;; NOTE: some PostScript printer may crash printing if
`ps-n-up-printing' is
;; set to a high value (for example, 23). If this happens, set a lower
value.
;;
So, a more robust version of the function would check to verify that
the value is greater than 0 and less than 101. Or, it might be
acceptable
to constrain the value to be between 1 and 10, inclusive.
(defun jbr-ps-print-n-up-hook ()
(let ((number-of-pages
(read-no-blanks-input "N-up number of pages: " "1")))
(if (integerp number-of-pages)
(if (and (> number-of-pages 0) (< number-of-pages 11))
(setq ps-n-up-printing number-of-pages)
(print "Outside of valid range: 1 to 10" t))
(print "Not an integer" t))))
----