RE: An elisp question
  Home FAQ Contact Sign in
gnu.emacs.help only
 
Advanced search
POPULAR GROUPS

more...

gnu.emacs.help Profile…
 Up
RE: An elisp question         


Author: Drew Adams
Date: Sep 16, 2008 13:09

> 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"))) ...
Show full article (1.19Kb)
7 Comments
Re: An elisp question         


Author: Joost Kremers
Date: Sep 16, 2008 13:20

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)
2 Comments
RE: An elisp question         


Author: Drew Adams
Date: Sep 16, 2008 13:51

>> (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').
1 Comment
Re: An elisp question         


Author: Oleksandr Gavenko
Date: Sep 17, 2008 11:29

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!
Show full article (0.73Kb)
no comments
Re: An elisp question         


Author: Joost Kremers
Date: Sep 17, 2008 14:05

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)
no comments
Re: An elisp question         


Author: Bastien
Date: Sep 18, 2008 01:06

Oleksandr Gavenko 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
no comments
Re: An elisp question         


Author: Nikolaj Schumacher
Date: Sep 19, 2008 09:13

Oleksandr Gavenko 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
1 Comment
Re: An elisp question         


Author: Oleksandr Gavenko
Date: Sep 19, 2008 11:17

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!
no comments