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

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

Re: A `my-ps-print-setting' function


From: Andreas Politz
Subject: Re: A `my-ps-print-setting' function
Date: Sun, 07 Sep 2008 21:40:35 +0200
User-agent: Mozilla-Thunderbird 2.0.0.16 (X11/20080724)

Rodolfo Medina wrote:
Rodolfo Medina <rodolfo.medina@gmail.com> writes:

[...] I wish to set some ps-print variables in an interactive way, i.e. be
prompted for the value that I want to set.



With the help that came from this list, I defined a `my-ps-print-setting'
function, that I'm reporting below.  Improvements are welcome: in particular
I wish it said: "please answer `r' or `l'" when prompting for a right or left
footer and [...]

Thank lisp you can make your own choices...

(defmacro defchoice (yes no)
  (let* ((name (format "%c-or-%c-p" yes no))
         (name-symbol (intern name)))
    `(defun ,name-symbol (prompt)
       ,(format "Ask user a \"%c or %c\" question.  Return t is answer is 
\"%c\"."
                yes no yes)
       (let* ((pprompt1 (propertize (format "%s (%c or %c) ?" prompt ,yes ,no) 
'face
                                    'minibuffer-prompt))
              (pprompt2 (concat (propertize (format "Please answer %c or %c.  " 
,yes ,no) 'face
                                            'minibuffer-prompt)
                                pprompt1))
              (answer (read-char-exclusive pprompt1)))
         (while (not (or (= answer ,yes)
                         (= answer ,no)))
           (setq answer (read-char-exclusive pprompt2)))
         (= answer ,yes)))))


(defchoice ?r ?l)
(r-or-l-p "Choose !")

-ap


reply via email to

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