* How to define a `multiple prompt' function?
@ 2008-09-03 0:21 Rodolfo Medina
2008-09-03 4:08 ` Barry Margolin
2008-09-03 19:43 ` How to define a `multiple prompt' function? Evans Winner
0 siblings, 2 replies; 19+ messages in thread
From: Rodolfo Medina @ 2008-09-03 0:21 UTC (permalink / raw)
To: help-gnu-emacs
I wish to define a function that prompts me more than once: let's call it
`my-function': when I type `M-x my-function', in the echo area I see (just an
example):
Hi, how are you today?
. Then I type, e.g., `fine RET', and again it prompts me with:
I see. And, what did you do yesterday?
... and so on. Then I'm going to put some `if... else' conditions over my
possible answers. Can anybody please provide some hints about how to elisp
this?
Thanks for any help
Rodolfo
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: How to define a `multiple prompt' function?
2008-09-03 0:21 How to define a `multiple prompt' function? Rodolfo Medina
@ 2008-09-03 4:08 ` Barry Margolin
2008-09-03 20:31 ` ps-print variables interactive setting (was: How to define a `multiple prompt' function?) Rodolfo Medina
2008-09-03 19:43 ` How to define a `multiple prompt' function? Evans Winner
1 sibling, 1 reply; 19+ messages in thread
From: Barry Margolin @ 2008-09-03 4:08 UTC (permalink / raw)
To: help-gnu-emacs
In article <87ej42m64o.fsf@gmail.com>,
Rodolfo Medina <rodolfo.medina@gmail.com> wrote:
> I wish to define a function that prompts me more than once: let's call it
> `my-function': when I type `M-x my-function', in the echo area I see (just an
> example):
>
> Hi, how are you today?
>
> . Then I type, e.g., `fine RET', and again it prompts me with:
>
> I see. And, what did you do yesterday?
>
> ... and so on. Then I'm going to put some `if... else' conditions over my
> possible answers. Can anybody please provide some hints about how to elisp
> this?
>
> Thanks for any help
> Rodolfo
(defun my-function ()
(interactive)
(let* ((response (read-from-minibuffer "Hi, how are you today? "))
(new-prompt (format "I see, you're %s? And where did you go
yesterday?" response))
(response2 (read-from-minibuffer new-prompt)))
(message "I hope you enjoyed %s" response2)))
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: How to define a `multiple prompt' function?
2008-09-03 0:21 How to define a `multiple prompt' function? Rodolfo Medina
2008-09-03 4:08 ` Barry Margolin
@ 2008-09-03 19:43 ` Evans Winner
1 sibling, 0 replies; 19+ messages in thread
From: Evans Winner @ 2008-09-03 19:43 UTC (permalink / raw)
To: help-gnu-emacs
Rodolfo Medina <rodolfo.medina@gmail.com> writes:
I wish to define a function that prompts me more than
once: let's call it `my-function': when I type `M-x
my-function', in the echo area I see (just an example):
Hi, how are you today?
. Then I type, e.g., `fine RET', and again it prompts me with:
I see. And, what did you do yesterday?
... and so on. Then I'm going to put some `if... else'
conditions over my possible answers. Can anybody please
provide some hints about how to elisp this?
'read-from-minibuffer might be what you want.
(format "Your name is: %s"
(read-from-minibuffer "Who are you? "))
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: ps-print variables interactive setting
2008-09-03 20:31 ` ps-print variables interactive setting (was: How to define a `multiple prompt' function?) Rodolfo Medina
@ 2008-09-03 19:51 ` Lennart Borgman (gmail)
2008-09-03 22:32 ` Andreas Politz
` (2 subsequent siblings)
3 siblings, 0 replies; 19+ messages in thread
From: Lennart Borgman (gmail) @ 2008-09-03 19:51 UTC (permalink / raw)
To: Rodolfo Medina; +Cc: help-gnu-emacs
Rodolfo Medina wrote:
> (defun my-manage-ps-font-size ()
> (interactive)
> (let* ((prompt1 (read-from-minibuffer "Font size? "))
> (prompt2 (format "(quote (7 . %s))" prompt1))
> )
> (setq ps-font-size prompt2)
> )
> )
>
>
> , but it seems that the variable's value is put between "" and so it is not
> accepted. I need help in this point. Thanks to anyone still helping.
Maybe like this
(defun my-manage-ps-font-size ()
(interactive)
(let ((font-size (read-number "Font size? ")))
(setq ps-font-size (cons 7 font-size))))
^ permalink raw reply [flat|nested] 19+ messages in thread
* ps-print variables interactive setting (was: How to define a `multiple prompt' function?)
2008-09-03 4:08 ` Barry Margolin
@ 2008-09-03 20:31 ` Rodolfo Medina
2008-09-03 19:51 ` ps-print variables interactive setting Lennart Borgman (gmail)
` (3 more replies)
0 siblings, 4 replies; 19+ messages in thread
From: Rodolfo Medina @ 2008-09-03 20:31 UTC (permalink / raw)
To: help-gnu-emacs
Rodolfo Medina <rodolfo.medina@gmail.com> wrote:
>> I wish to define a function that prompts me more than once: let's call it
>> `my-function': when I type `M-x my-function', in the echo area I see (just an
>> example):
>>
>> Hi, how are you today?
>>
>> . Then I type, e.g., `fine RET', and again it prompts me with:
>>
>> I see. And, what did you do yesterday?
>>
>> ... and so on. Then I'm going to put some `if... else' conditions over my
>> possible answers. Can anybody please provide some hints about how to elisp
>> this?
Barry Margolin <barmar@alum.mit.edu> writes:
> (defun my-function ()
> (interactive)
> (let* ((response (read-from-minibuffer "Hi, how are you today? "))
> (new-prompt (format "I see, you're %s? And where did you go
> yesterday?" response))
> (response2 (read-from-minibuffer new-prompt)))
> (message "I hope you enjoyed %s" response2)))
Thanks, that works.
I wish to set some ps-print variables in an interactive way, i.e. be prompted
for the value that I want to set. So, following Barry's hint, I put:
(defun my-manage-ps-font-size ()
(interactive)
(let* ((prompt1 (read-from-minibuffer "Font size? "))
(prompt2 (format "(quote (7 . %s))" prompt1))
)
(setq ps-font-size prompt2)
)
)
, but it seems that the variable's value is put between "" and so it is not
accepted. I need help in this point. Thanks to anyone still helping.
Rodolfo
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: ps-print variables interactive setting
2008-09-03 20:31 ` ps-print variables interactive setting (was: How to define a `multiple prompt' function?) Rodolfo Medina
2008-09-03 19:51 ` ps-print variables interactive setting Lennart Borgman (gmail)
@ 2008-09-03 22:32 ` Andreas Politz
2008-09-04 17:24 ` `are-you-fine' function definition (was: ps-print variables interactive setting) Rodolfo Medina
2008-09-04 21:47 ` ps-right-footer interactive setting (was: ps-print variables interactive setting) Rodolfo Medina
2008-09-07 16:44 ` A `my-ps-print-setting' function (was: ps-print variables interactive setting) Rodolfo Medina
3 siblings, 1 reply; 19+ messages in thread
From: Andreas Politz @ 2008-09-03 22:32 UTC (permalink / raw)
To: help-gnu-emacs
Rodolfo Medina wrote:
> Rodolfo Medina <rodolfo.medina@gmail.com> wrote:
>
>>> I wish to define a function that prompts me more than once: let's call it
>>> `my-function': when I type `M-x my-function', in the echo area I see (just an
>>> example):
>>>
>>> Hi, how are you today?
>>>
>>> . Then I type, e.g., `fine RET', and again it prompts me with:
>>>
>>> I see. And, what did you do yesterday?
>>>
>>> ... and so on. Then I'm going to put some `if... else' conditions over my
>>> possible answers. Can anybody please provide some hints about how to elisp
>>> this?
>
>
>
> Barry Margolin <barmar@alum.mit.edu> writes:
>
>> (defun my-function ()
>> (interactive)
>> (let* ((response (read-from-minibuffer "Hi, how are you today? "))
>> (new-prompt (format "I see, you're %s? And where did you go
>> yesterday?" response))
>> (response2 (read-from-minibuffer new-prompt)))
>> (message "I hope you enjoyed %s" response2)))
>
>
> Thanks, that works.
> I wish to set some ps-print variables in an interactive way, i.e. be prompted
> for the value that I want to set. So, following Barry's hint, I put:
>
>
> (defun my-manage-ps-font-size ()
> (interactive)
> (let* ((prompt1 (read-from-minibuffer "Font size? "))
> (prompt2 (format "(quote (7 . %s))" prompt1))
> )
> (setq ps-font-size prompt2)
> )
> )
>
>
> , but it seems that the variable's value is put between "" and so it is not
> accepted. I need help in this point. Thanks to anyone still helping.
>
> Rodolfo
Take a look at the documentation of the interactive call, it let's you
read any kind of data from the minibuffer.
(defun my-manage-ps-font-size(size string)
(interactive "nFont size ? \nsErase all memory ? ")
(setq ps-font-size (cons 7 size)))
This reads a number and a string.
-ap
^ permalink raw reply [flat|nested] 19+ messages in thread
* `are-you-fine' function definition (was: ps-print variables interactive setting)
2008-09-03 22:32 ` Andreas Politz
@ 2008-09-04 17:24 ` Rodolfo Medina
2008-09-05 2:18 ` `are-you-fine' function definition Kevin Rodgers
[not found] ` <mailman.18482.1220581140.18990.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 19+ messages in thread
From: Rodolfo Medina @ 2008-09-04 17:24 UTC (permalink / raw)
To: help-gnu-emacs
Rodolfo Medina wrote:
>>>> I wish to define a function that prompts me more than once
>>>>
>>>> [...]
>>>>
>>>> Then I'm going to put some `if... else' conditions over my
>>>> possible answers. Can anybody please provide some hints about how to
>>>> elisp this?
Barry Margolin <barmar@alum.mit.edu> writes:
>>> (defun my-function ()
>>> (interactive)
>>> (let* ((response (read-from-minibuffer "Hi, how are you today? "))
>>> (new-prompt (format "I see, you're %s? And where did you go
>>> yesterday?" response))
>>> (response2 (read-from-minibuffer new-prompt)))
>>> (message "I hope you enjoyed %s" response2)))
"Lennart Borgman (gmail)" <lennart.borgman@gmail.com> writes:
> Maybe like this
>
> (defun my-manage-ps-font-size ()
> (interactive)
> (let ((font-size (read-number "Font size? ")))
> (setq ps-font-size (cons 7 font-size))))
Andreas Politz <politza@fh-trier.de> writes:
> Take a look at the documentation of the interactive call, it let's you
> read any kind of data from the minibuffer.
>
> (defun my-manage-ps-font-size(size string)
> (interactive "nFont size ? \nsErase all memory ? ")
> (setq ps-font-size (cons 7 size)))
>
> This reads a number and a string.
Thanks very much to all who helped. With their help I'm building a
`my-ps-print-buffer' function, that I'll report so that it may be useful to
others: now I need something like this: the function says:
Are you fine today?
. If I say `y', it says: `Oh, good.'; otherwise it says: `Why don't you see a
doctor?'
I tried a lot but don't manage by myself.
Please help in this regard
Thanks again
Rodolfo
^ permalink raw reply [flat|nested] 19+ messages in thread
* ps-right-footer interactive setting (was: ps-print variables interactive setting)
2008-09-03 20:31 ` ps-print variables interactive setting (was: How to define a `multiple prompt' function?) Rodolfo Medina
2008-09-03 19:51 ` ps-print variables interactive setting Lennart Borgman (gmail)
2008-09-03 22:32 ` Andreas Politz
@ 2008-09-04 21:47 ` Rodolfo Medina
2008-09-05 1:19 ` Barry Margolin
2008-09-07 16:44 ` A `my-ps-print-setting' function (was: ps-print variables interactive setting) Rodolfo Medina
3 siblings, 1 reply; 19+ messages in thread
From: Rodolfo Medina @ 2008-09-04 21:47 UTC (permalink / raw)
To: help-gnu-emacs
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.
Now I'm working on the ps-right-footer variable. I wish to be prompted for a
page number so that the variable is set to:
(list <page number>)
. I did:
(defun my-ps-right-footer ()
(interactive)
(let ((my-page-number (read-number "page number? ")))
(setq ps-print-footer t)
(setq ps-right-footer (list 'my-page-number))
)
)
, but it doesn't work. Any suggestion?
Thanks
Rodolfo
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: ps-right-footer interactive setting (was: ps-print variables interactive setting)
2008-09-04 21:47 ` ps-right-footer interactive setting (was: ps-print variables interactive setting) Rodolfo Medina
@ 2008-09-05 1:19 ` Barry Margolin
2008-09-05 10:21 ` ps-right-footer interactive setting Rodolfo Medina
0 siblings, 1 reply; 19+ messages in thread
From: Barry Margolin @ 2008-09-05 1:19 UTC (permalink / raw)
To: help-gnu-emacs
In article <87aben37np.fsf@gmail.com>,
Rodolfo Medina <rodolfo.medina@gmail.com> 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.
>
>
>
> Now I'm working on the ps-right-footer variable. I wish to be prompted for a
> page number so that the variable is set to:
>
> (list <page number>)
>
> . I did:
>
> (defun my-ps-right-footer ()
> (interactive)
> (let ((my-page-number (read-number "page number? ")))
> (setq ps-print-footer t)
> (setq ps-right-footer (list 'my-page-number))
> )
> )
>
> , but it doesn't work. Any suggestion?
>
> Thanks
> Rodolfo
It should be (list my-page number). Quoting prevents the variable from
being evaluated.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: `are-you-fine' function definition
2008-09-04 17:24 ` `are-you-fine' function definition (was: ps-print variables interactive setting) Rodolfo Medina
@ 2008-09-05 2:18 ` Kevin Rodgers
[not found] ` <mailman.18482.1220581140.18990.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 19+ messages in thread
From: Kevin Rodgers @ 2008-09-05 2:18 UTC (permalink / raw)
To: help-gnu-emacs
Rodolfo Medina wrote:
> Thanks very much to all who helped. With their help I'm building a
> `my-ps-print-buffer' function, that I'll report so that it may be useful to
> others: now I need something like this: the function says:
>
> Are you fine today?
>
> . If I say `y', it says: `Oh, good.'; otherwise it says: `Why don't you see a
> doctor?'
(if (equal (read-string "Are you fine today? ") "y")
(message "Oh, good.")
(message "Why don't you see a doctor?"))
You might want to change the (equal ...) test to one of these:
(y-or-n-p "Are you fine today? ")
(yes-or-no-p "Are you fine today? ")
(let ((case-fold-search t))
(string-match "\\`y\\(es\\)?\\'" (read-string "Are you fine today? ")))
--
Kevin Rodgers
Denver, Colorado, USA
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: ps-right-footer interactive setting
2008-09-05 1:19 ` Barry Margolin
@ 2008-09-05 10:21 ` Rodolfo Medina
2008-09-05 19:21 ` Chetan
0 siblings, 1 reply; 19+ messages in thread
From: Rodolfo Medina @ 2008-09-05 10:21 UTC (permalink / raw)
To: help-gnu-emacs
Rodolfo Medina <rodolfo.medina@gmail.com> wrote:
>> Now I'm working on the ps-right-footer variable. I wish to be prompted for
>> a page number so that the variable is set to:
>>
>> (list <page number>)
>>
>> . I did:
>>
>> (defun my-ps-right-footer ()
>> (interactive)
>> (let ((my-page-number (read-number "page number? ")))
>> (setq ps-print-footer t)
>> (setq ps-right-footer (list 'my-page-number))
>> )
>> )
>>
>> , but it doesn't work. Any suggestion?
Barry Margolin <barmar@alum.mit.edu> writes:
> It should be (list my-page number). Quoting prevents the variable from
> being evaluated.
Unfortunately it doesn't work either:
(defun my-ps-right-footer ()
(interactive)
(let ((my-page-number (read-number "page number? ")))
(setq ps-print-footer t)
(setq ps-right-footer (list my-page-number))
)
)
produces a ps print error. I can't find a solution. Thanks for furhter
suggestions.
Rodolfo
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: ps-right-footer interactive setting
2008-09-05 10:21 ` ps-right-footer interactive setting Rodolfo Medina
@ 2008-09-05 19:21 ` Chetan
2008-09-06 16:28 ` Rodolfo Medina
0 siblings, 1 reply; 19+ messages in thread
From: Chetan @ 2008-09-05 19:21 UTC (permalink / raw)
To: help-gnu-emacs
Rodolfo Medina <rodolfo.medina@gmail.com> writes:
> Rodolfo Medina <rodolfo.medina@gmail.com> wrote:
>
>>> Now I'm working on the ps-right-footer variable. I wish to be prompted for
>>> a page number so that the variable is set to:
>>>
>>> (list <page number>)
>>>
>>> . I did:
>>>
>>> (defun my-ps-right-footer ()
>>> (interactive)
>>> (let ((my-page-number (read-number "page number? ")))
>>> (setq ps-print-footer t)
>>> (setq ps-right-footer (list 'my-page-number))
>>> )
>>> )
>>>
>>> , but it doesn't work. Any suggestion?
>
>
>
> Barry Margolin <barmar@alum.mit.edu> writes:
>
>> It should be (list my-page number). Quoting prevents the variable from
>> being evaluated.
>
>
>
> Unfortunately it doesn't work either:
>
> (defun my-ps-right-footer ()
> (interactive)
> (let ((my-page-number (read-number "page number? ")))
> (setq ps-print-footer t)
> (setq ps-right-footer (list my-page-number))
> )
> )
>
> produces a ps print error. I can't find a solution. Thanks for furhter
> suggestions.
> Rodolfo
It is a postscript string...
(list (concat "(" (number-to-string my-page-number) ")"))
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: `are-you-fine' function definition
[not found] ` <mailman.18482.1220581140.18990.help-gnu-emacs@gnu.org>
@ 2008-09-06 16:27 ` Rodolfo Medina
2008-09-06 16:32 ` `y-or-n-p' function definition (was: `are-you-fine' function definition) Rodolfo Medina
0 siblings, 1 reply; 19+ messages in thread
From: Rodolfo Medina @ 2008-09-06 16:27 UTC (permalink / raw)
To: help-gnu-emacs
Rodolfo Medina wrote:
>> now I need something like this: the function says:
>>
>> Are you fine today?
>>
>> . If I say `y', it says: `Oh, good.'; otherwise it says: `Why don't you
>> see a doctor?'
Kevin Rodgers <kevin.d.rodgers@gmail.com> writes:
> (if (equal (read-string "Are you fine today? ") "y")
> (message "Oh, good.")
> (message "Why don't you see a doctor?"))
>
> You might want to change the (equal ...) test to one of these:
>
> (y-or-n-p "Are you fine today? ")
>
> (yes-or-no-p "Are you fine today? ")
>
> (let ((case-fold-search t))
> (string-match "\\`y\\(es\\)?\\'" (read-string "Are you fine today? ")))
Thanks, the `y-or-n-p' function is perfect for what I was looking for. But
now I wish to have something like `y-or-n-p' that asks me if I want right or
left ps footer, like this:
Right or left? (r/l)
. If I could access the `y-or-n-p' defun, then I could try to adapt it to an
`r-or-l-p' version, but can't find it anywhere. Please any suggestion?
Thanks
Rodolfo
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: ps-right-footer interactive setting
2008-09-05 19:21 ` Chetan
@ 2008-09-06 16:28 ` Rodolfo Medina
0 siblings, 0 replies; 19+ messages in thread
From: Rodolfo Medina @ 2008-09-06 16:28 UTC (permalink / raw)
To: help-gnu-emacs
Rodolfo Medina <rodolfo.medina@gmail.com> writes:
>>>> Now I'm working on the ps-right-footer variable. I wish to be prompted
>>>> for a page number so that the variable is set to:
>>>>
>>>> (list <page number>)
>>>>
>>>> . I did:
>>>>
>>>> (defun my-ps-right-footer ()
>>>> (interactive)
>>>> (let ((my-page-number (read-number "page number? ")))
>>>> (setq ps-print-footer t)
>>>> (setq ps-right-footer (list 'my-page-number))
>>>> )
>>>> )
>>>>
>>>> , but it doesn't work. Any suggestion?
Barry Margolin <barmar@alum.mit.edu> writes:
>>> It should be (list my-page number). Quoting prevents the variable from
>>> being evaluated.
Rodolfo:
>> Unfortunately it doesn't work either:
>>
>> (defun my-ps-right-footer ()
>> (interactive)
>> (let ((my-page-number (read-number "page number? ")))
>> (setq ps-print-footer t)
>> (setq ps-right-footer (list my-page-number))
>> )
>> )
>>
>> produces a ps print error. I can't find a solution. Thanks for furhter
>> suggestions.
Chetan <Chet.xspam@xspam.sbcglobal.net> writes:
> It is a postscript string...
> (list (concat "(" (number-to-string my-page-number) ")"))
Thanks, this worked!
Rodolfo
^ permalink raw reply [flat|nested] 19+ messages in thread
* `y-or-n-p' function definition (was: `are-you-fine' function definition)
2008-09-06 16:27 ` Rodolfo Medina
@ 2008-09-06 16:32 ` Rodolfo Medina
2008-09-08 10:14 ` `y-or-n-p' function definition Nikolaj Schumacher
0 siblings, 1 reply; 19+ messages in thread
From: Rodolfo Medina @ 2008-09-06 16:32 UTC (permalink / raw)
To: help-gnu-emacs; +Cc: kevin.d.rodgers
Rodolfo Medina wrote:
>> now I need something like this: the function says:
>>
>> Are you fine today?
>>
>> . If I say `y', it says: `Oh, good.'; otherwise it says: `Why don't you
>> see a doctor?'
Kevin Rodgers <kevin.d.rodgers@gmail.com> writes:
> (if (equal (read-string "Are you fine today? ") "y")
> (message "Oh, good.")
> (message "Why don't you see a doctor?"))
>
> You might want to change the (equal ...) test to one of these:
>
> (y-or-n-p "Are you fine today? ")
>
> (yes-or-no-p "Are you fine today? ")
>
> (let ((case-fold-search t))
> (string-match "\\`y\\(es\\)?\\'" (read-string "Are you fine today? ")))
Thanks, the `y-or-n-p' function is perfect for what I was looking for. But
now I wish to have something like `y-or-n-p' that asks me if I want right or
left ps footer, like this:
Right or left? (r/l)
. If I could access the `y-or-n-p' defun, then I could try to adapt it to an
`r-or-l-p' version, but can't find it anywhere. Please any suggestion?
Thanks
Rodolfo
^ permalink raw reply [flat|nested] 19+ messages in thread
* A `my-ps-print-setting' function (was: ps-print variables interactive setting)
2008-09-03 20:31 ` ps-print variables interactive setting (was: How to define a `multiple prompt' function?) Rodolfo Medina
` (2 preceding siblings ...)
2008-09-04 21:47 ` ps-right-footer interactive setting (was: ps-print variables interactive setting) Rodolfo Medina
@ 2008-09-07 16:44 ` Rodolfo Medina
2008-09-07 19:40 ` A `my-ps-print-setting' function Andreas Politz
3 siblings, 1 reply; 19+ messages in thread
From: Rodolfo Medina @ 2008-09-07 16:44 UTC (permalink / raw)
To: help-gnu-emacs
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 the answer is neither r nor l. Besides, I wish to have
automatically odd page numbers in the right footer and even page numbers in
the left footer. But I'm starting a new thread for that.
bye
Rodolfo
(defun my-ps-print-setting ()
"Prompts for some ps print settings.
Other settings are inside the function definition
and can be changed at pleasure."
(interactive)
(if (equal (y-or-n-p "Do you want footer? ") t)
(let (key val)
(while (progn
(setq key
(let ((cursor-in-echo-area t))
(read-char
(format "right or left? "))))
(not (memq key '(?r ?l)))))
(if (eq key ?r)
(if (equal (y-or-n-p "So, you want right footer. \
Do you want the default footer? ") nil)
(let ((my-page-number (read-string
"Enter the footer you want: ")))
(setq ps-right-footer (list (concat "(" my-page-number ")"))
ps-print-footer t
ps-print-footer-frame nil
ps-top-margin 20
ps-bottom-margin 5
ps-left-margin 10
ps-right-margin 7
ps-print-header nil
ps-show-n-of-n nil
ps-print-footer-frame nil
ps-footer-lines 1
ps-left-footer (quote ( ))
ps-footer-offset -10))
(setq ps-right-footer (quote ("/pagenumberstring load"))
ps-print-footer t
ps-print-footer-frame nil
ps-top-margin 20
ps-bottom-margin 5
ps-left-margin 10
ps-right-margin 7
ps-print-header nil
ps-show-n-of-n nil
ps-print-footer-frame nil
ps-footer-lines 1
ps-left-footer (quote ( ))
ps-footer-offset -10))
(if (equal (y-or-n-p "So, you want left footer. \
Do you want the default footer? ") nil)
(let ((my-page-number (read-string
"Enter the footer you want: ")))
(setq ps-left-footer (list (concat "(" my-page-number ")"))
ps-print-footer t
ps-print-footer-frame nil
ps-top-margin 20
ps-bottom-margin 5
ps-left-margin 10
ps-right-margin 7
ps-print-header nil
ps-show-n-of-n nil
ps-print-footer-frame nil
ps-footer-lines 1
ps-right-footer (quote ( ))
ps-footer-offset -10))
(setq ps-left-footer (quote ("/pagenumberstring load"))
ps-print-footer t
ps-print-footer-frame nil
ps-top-margin 20
ps-bottom-margin 5
ps-left-margin 10
ps-right-margin 7
ps-print-header nil
ps-show-n-of-n nil
ps-print-footer-frame nil
ps-footer-lines 1
ps-right-footer (quote ( ))
ps-footer-offset -10))
))
(setq ps-print-footer nil
; ps-top-margin 10
ps-top-margin 5
ps-bottom-margin 0
ps-left-margin 10
ps-right-margin 0
ps-print-header nil
ps-print-footer nil))
(let ((font-size (read-number "What font size do you want? ")))
(setq ps-font-size (cons 7 font-size)))
(if (equal ps-font-size '(7 . 9.5))
(setq-default fill-column 101))
(if (equal ps-font-size '(7 . 12))
(setq-default fill-column 78))
)
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: A `my-ps-print-setting' function
2008-09-07 16:44 ` A `my-ps-print-setting' function (was: ps-print variables interactive setting) Rodolfo Medina
@ 2008-09-07 19:40 ` Andreas Politz
2008-09-08 1:18 ` defchoice macro (was: A `my-ps-print-setting' function) Rodolfo Medina
0 siblings, 1 reply; 19+ messages in thread
From: Andreas Politz @ 2008-09-07 19:40 UTC (permalink / raw)
To: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 19+ messages in thread
* defchoice macro (was: A `my-ps-print-setting' function)
2008-09-07 19:40 ` A `my-ps-print-setting' function Andreas Politz
@ 2008-09-08 1:18 ` Rodolfo Medina
0 siblings, 0 replies; 19+ messages in thread
From: Rodolfo Medina @ 2008-09-08 1:18 UTC (permalink / raw)
To: help-gnu-emacs
Rodolfo Medina <rodolfo.medina@gmail.com> writes:
>> 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 [...]
Andreas Politz <politza@fh-trier.de> writes:
> 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 !")
Fantastic. The `r-or-l-p' function so defined is even better than `y-or-n-p',
because if I put, e.g.:
(defun my-test ()
(interactive)
(y-or-n-p "y or n? "))
(defun my-test2 ()
(interactive)
(r-or-l-p "l or r? "))
, with my-test the text in the echo area does not disappear after answering,
whereas it does with my-test2, which is better.
Only two things:
1) the cursor should appear in the echo area, so I imagine that your macro
definition should contain some `(let ((cursor-in-echo-area t)))' condition
somewhere;
2) keys like up, down, right, left, next, prior, end have problems.
Would it be hard to fix those two things?
Thanks, bye
Rodolfo
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: `y-or-n-p' function definition
2008-09-06 16:32 ` `y-or-n-p' function definition (was: `are-you-fine' function definition) Rodolfo Medina
@ 2008-09-08 10:14 ` Nikolaj Schumacher
0 siblings, 0 replies; 19+ messages in thread
From: Nikolaj Schumacher @ 2008-09-08 10:14 UTC (permalink / raw)
To: Rodolfo Medina; +Cc: help-gnu-emacs, kevin.d.rodgers
Rodolfo Medina <rodolfo.medina@gmail.com> wrote:
> Thanks, the `y-or-n-p' function is perfect for what I was looking for. But
> now I wish to have something like `y-or-n-p' that asks me if I want right or
> left ps footer, like this:
>
> Right or left? (r/l)
Try `read-char'.
> If I could access the `y-or-n-p' defun, then I could try to adapt it to an
> `r-or-l-p' version, but can't find it anywhere.
As `describe-function' will tell you, that function is in the C
sources. So you won't be able to adapt it for lisp code.
regards,
Nikolaj Schumacher
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2008-09-08 10:14 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-03 0:21 How to define a `multiple prompt' function? Rodolfo Medina
2008-09-03 4:08 ` Barry Margolin
2008-09-03 20:31 ` ps-print variables interactive setting (was: How to define a `multiple prompt' function?) Rodolfo Medina
2008-09-03 19:51 ` ps-print variables interactive setting Lennart Borgman (gmail)
2008-09-03 22:32 ` Andreas Politz
2008-09-04 17:24 ` `are-you-fine' function definition (was: ps-print variables interactive setting) Rodolfo Medina
2008-09-05 2:18 ` `are-you-fine' function definition Kevin Rodgers
[not found] ` <mailman.18482.1220581140.18990.help-gnu-emacs@gnu.org>
2008-09-06 16:27 ` Rodolfo Medina
2008-09-06 16:32 ` `y-or-n-p' function definition (was: `are-you-fine' function definition) Rodolfo Medina
2008-09-08 10:14 ` `y-or-n-p' function definition Nikolaj Schumacher
2008-09-04 21:47 ` ps-right-footer interactive setting (was: ps-print variables interactive setting) Rodolfo Medina
2008-09-05 1:19 ` Barry Margolin
2008-09-05 10:21 ` ps-right-footer interactive setting Rodolfo Medina
2008-09-05 19:21 ` Chetan
2008-09-06 16:28 ` Rodolfo Medina
2008-09-07 16:44 ` A `my-ps-print-setting' function (was: ps-print variables interactive setting) Rodolfo Medina
2008-09-07 19:40 ` A `my-ps-print-setting' function Andreas Politz
2008-09-08 1:18 ` defchoice macro (was: A `my-ps-print-setting' function) Rodolfo Medina
2008-09-03 19:43 ` How to define a `multiple prompt' function? Evans Winner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).