* RE: An elisp question
2008-09-16 20:17 An elisp question Rodolfo Medina
@ 2008-09-16 20:09 ` Drew Adams
[not found] ` <mailman.19376.1221595777.18990.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 9+ messages in thread
From: Drew Adams @ 2008-09-16 20:09 UTC (permalink / raw)
To: 'Rodolfo Medina', help-gnu-emacs
> I have a set of `setq' conditions that I wish to group into a
> function and put inside another function:
>
> (defun my-test ()
> (interactive)
> (if (equal (y-or-n-p "Yes or no? ") t)
> (setq ps-print-footer t
> ps-print-footer-frame nil
> ps-top-margin 18
> ps-bottom-margin 5
> ps-left-margin 9
> 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 0
> )
> (message "hallo")))
>
> How can I group all those `setq' conditions into a function
> and put that function name in place of them in `my-test'
> definition?
(defun foo ()
(setq ps-print-footer t
ps-print-footer-frame nil
ps-top-margin 18
ps-bottom-margin 5
ps-left-margin 9
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 0))
(defun my-test ()
(interactive)
(if (equal (y-or-n-p "Yes or no? ") t)
(foo)
(message "hallo")))
Is this some kind of homework assignment? ;-)
^ permalink raw reply [flat|nested] 9+ messages in thread
* An elisp question
@ 2008-09-16 20:17 Rodolfo Medina
2008-09-16 20:09 ` Drew Adams
[not found] ` <mailman.19376.1221595777.18990.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 9+ messages in thread
From: Rodolfo Medina @ 2008-09-16 20:17 UTC (permalink / raw)
To: help-gnu-emacs
I have a set of `setq' conditions that I wish to group into a function and put
inside another function:
(defun my-test ()
(interactive)
(if (equal (y-or-n-p "Yes or no? ") t)
(setq ps-print-footer t
ps-print-footer-frame nil
ps-top-margin 18
ps-bottom-margin 5
ps-left-margin 9
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 0
)
(message "hallo")))
How can I group all those `setq' conditions into a function and put that
function name in place of them in `my-test' definition?
Thanks for any help
Rodolfo
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: An elisp question
[not found] ` <mailman.19376.1221595777.18990.help-gnu-emacs@gnu.org>
@ 2008-09-16 20:20 ` Joost Kremers
2008-09-16 20:51 ` Drew Adams
[not found] ` <mailman.19377.1221598264.18990.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 9+ messages in thread
From: Joost Kremers @ 2008-09-16 20:20 UTC (permalink / raw)
To: help-gnu-emacs
Drew Adams wrote:
> (defun my-test ()
> (interactive)
> (if (equal (y-or-n-p "Yes or no? ") t)
(if (y-or-n-p "Yes or no? ")
will do just fine.
> (foo)
> (message "hallo")))
--
Joost Kremers joostkremers@yahoo.com
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: An elisp question
2008-09-16 20:20 ` Joost Kremers
@ 2008-09-16 20:51 ` Drew Adams
[not found] ` <mailman.19377.1221598264.18990.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 9+ messages in thread
From: Drew Adams @ 2008-09-16 20:51 UTC (permalink / raw)
To: 'Joost Kremers', help-gnu-emacs
> > (defun my-test ()
> > (interactive)
> > (if (equal (y-or-n-p "Yes or no? ") t)
>
> (if (y-or-n-p "Yes or no? ")
>
> will do just fine.
>
> > (foo)
> > (message "hallo")))
Duh. (I didn't try to do more than answer his question.)
Really, the right answer to the OP is to take a look at the manual "Emacs Lisp
Introduction" (aka "An Introduction to Programming in Emacs Lisp") in Info (`C-h
i').
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: An elisp question
[not found] ` <mailman.19377.1221598264.18990.help-gnu-emacs@gnu.org>
@ 2008-09-17 18:29 ` Oleksandr Gavenko
2008-09-17 21:05 ` Joost Kremers
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Oleksandr Gavenko @ 2008-09-17 18:29 UTC (permalink / raw)
To: help-gnu-emacs
Drew Adams пишет:
>>> (defun my-test ()
>>> (interactive)
>>> (if (equal (y-or-n-p "Yes or no? ") t)
>> (if (y-or-n-p "Yes or no? ")
>>
>> will do just fine.
>>
>>> (foo)
>>> (message "hallo")))
>
> Duh. (I didn't try to do more than answer his question.)
>
> Really, the right answer to the OP is to take a look at the manual "Emacs Lisp
> Introduction" (aka "An Introduction to Programming in Emacs Lisp") in Info (`C-h
> i').
>
Comment please!
In elisp intro (Created on March, 10 2004 by texi2html 1.64)
I not find match of "yes-or-no-p" func and so special example for you say.
In elisp.html (edition 2.8) on "20.6 Yes-or-No Queries" also there no
special warning about use of "Yes-or-No".
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: An elisp question
2008-09-17 18:29 ` Oleksandr Gavenko
@ 2008-09-17 21:05 ` Joost Kremers
2008-09-18 8:06 ` Bastien
` (2 subsequent siblings)
3 siblings, 0 replies; 9+ messages in thread
From: Joost Kremers @ 2008-09-17 21:05 UTC (permalink / raw)
To: help-gnu-emacs
Oleksandr Gavenko wrote:
> In elisp.html (edition 2.8) on "20.6 Yes-or-No Queries" also there no
> special warning about use of "Yes-or-No".
the point is that Y-OR-N-P returns either t or nil, so you don't need to
explicitly compare it to T, you can just use it directly as the test for
IF. you wrote:
(if (equal (y-or-n-p "Yes or no? ") t)
...
but it's more concise to write:
(if (y-or-n-p "Yes or no? ")
...
(btw, if you want to test if a value is t, you can use eq, there's no need
to use equal.)
--
Joost Kremers joostkremers@yahoo.com
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: An elisp question
2008-09-17 18:29 ` Oleksandr Gavenko
2008-09-17 21:05 ` Joost Kremers
@ 2008-09-18 8:06 ` Bastien
2008-09-19 16:13 ` Nikolaj Schumacher
[not found] ` <mailman.19562.1221840826.18990.help-gnu-emacs@gnu.org>
3 siblings, 0 replies; 9+ messages in thread
From: Bastien @ 2008-09-18 8:06 UTC (permalink / raw)
To: help-gnu-emacs
Oleksandr Gavenko <gavenkoa@gmail.com> writes:
> Comment please!
>
> In elisp intro (Created on March, 10 2004 by texi2html 1.64)
> I not find match of "yes-or-no-p" func and so special example for you say.
>
> In elisp.html (edition 2.8) on "20.6 Yes-or-No Queries" also there no
> special warning about use of "Yes-or-No".
I found this page on EmacsWiki:
http://www.emacswiki.org/cgi-bin/wiki/YesOrNoP
--
Bastien
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: An elisp question
2008-09-17 18:29 ` Oleksandr Gavenko
2008-09-17 21:05 ` Joost Kremers
2008-09-18 8:06 ` Bastien
@ 2008-09-19 16:13 ` Nikolaj Schumacher
[not found] ` <mailman.19562.1221840826.18990.help-gnu-emacs@gnu.org>
3 siblings, 0 replies; 9+ messages in thread
From: Nikolaj Schumacher @ 2008-09-19 16:13 UTC (permalink / raw)
To: gavenkoa; +Cc: help-gnu-emacs
Oleksandr Gavenko <gavenkoa@gmail.com> wrote:
> In elisp intro (Created on March, 10 2004 by texi2html 1.64)
> I not find match of "yes-or-no-p" func and so special example for you say.
>
> In elisp.html (edition 2.8) on "20.6 Yes-or-No Queries" also there no special
> warning about use of "Yes-or-No".
I think this is a misunderstanding. Drew meant the answer on "how to
call a function" was to be found in the elisp intro. The yes-or-no-p
thing was just an additional note.
Incidentally, if anything, testing for t is more correct. :) The doc for
`y-or-n-p' clearly states, it will return t for "yes". It could be
extended to return 'cancel without changing the interface. Using any
non-nil value as "yes" is indeed an assumption. (Not that it's likely
to break, or that I haven't made that assumption myself...)
regards,
Nikolaj Schumacher
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: An elisp question
[not found] ` <mailman.19562.1221840826.18990.help-gnu-emacs@gnu.org>
@ 2008-09-19 18:17 ` Oleksandr Gavenko
0 siblings, 0 replies; 9+ messages in thread
From: Oleksandr Gavenko @ 2008-09-19 18:17 UTC (permalink / raw)
To: help-gnu-emacs
Nikolaj Schumacher пишет:
>
> Incidentally, if anything, testing for t is more correct. :) The doc for
> `y-or-n-p' clearly states, it will return t for "yes". It could be
> extended to return 'cancel without changing the interface. Using any
> non-nil value as "yes" is indeed an assumption. (Not that it's likely
> to break, or that I haven't made that assumption myself...)
Thanks, yes for some functions there may by side effect with
non-nil as true!
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2008-09-19 18:17 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-16 20:17 An elisp question Rodolfo Medina
2008-09-16 20:09 ` Drew Adams
[not found] ` <mailman.19376.1221595777.18990.help-gnu-emacs@gnu.org>
2008-09-16 20:20 ` Joost Kremers
2008-09-16 20:51 ` Drew Adams
[not found] ` <mailman.19377.1221598264.18990.help-gnu-emacs@gnu.org>
2008-09-17 18:29 ` Oleksandr Gavenko
2008-09-17 21:05 ` Joost Kremers
2008-09-18 8:06 ` Bastien
2008-09-19 16:13 ` Nikolaj Schumacher
[not found] ` <mailman.19562.1221840826.18990.help-gnu-emacs@gnu.org>
2008-09-19 18:17 ` Oleksandr Gavenko
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).