From: Thien-Thi Nguyen <ttn@gnuvola.org>
To: help-gnu-emacs@gnu.org
Subject: Re: conditionals in elisp
Date: Wed, 28 Oct 2009 10:10:04 +0100 [thread overview]
Message-ID: <873a53rij7.fsf@ambire.localdomain> (raw)
In-Reply-To: <CA26EDA5A25944368E32544640513F79@us.oracle.com> (Drew Adams's message of "Tue, 27 Oct 2009 00:37:38 -0700")
() "Drew Adams" <drew.adams@oracle.com>
() Tue, 27 Oct 2009 00:37:38 -0700
Learning from examples is fine - very good, in fact. Others have already
provided you examples, so I hope that helped. The quick and easy answer
would have been to just give you a couple examples to learn from. You can
evaluate each expression by typing it after `M-:' and hitting Enter.
(if) raises an error: wrong number of arguments - 0
(if nil) raises an error: wrong number of args - 1
(if nil 3) -> nil
(if t 3) -> 3
(if nil 3 4) -> 4
(if t 3 4) -> 3
(if nil 3 4 5) -> 5
(if t 3 4 5) -> 3
(if nil 3 4 5 6) -> 6
(if "anything but nil" 3) -> 3
(if "nil" 3) -> 3
(if 99 3 "anything") -> 3
(if nil 3 (setq a 5) a) -> 5
If these (nicely formatted) examples are useful, they could be added to
the documentation.
Also (to Harry Putnam): You can help avoid misunderstanding from other
list members by stating explicitly "i read the Emacs Lisp manual node
"Conditionals" and couldn't understand it".
In any case, in addition to M-:, the *scratch* buffer is also a nice
place to interact with Emacs. There, the values of the expressions are
inserted into the buffer and so are less fleeting than the output of
M-: in the echo area.
To play:
- C-x b *scratch* RET
- M-x lisp-interaction-mode RET
- type an expression:
(if 99 3 "anything")
- make sure cursor is immediately after the close-paren:
(if 99 3 "anything")-!- ;;; -!- represents the cursor
- type C-j; emacs displays evaluates the expression and inserts it;
you see:
(if 99 3 "anything")
3
-!-
Another benefit of experimenting via the *scratch* buffer is that if
something perplexes you there, it is very easy to mail the relevant
fragment when asking for help.
Overall, being explicit when asking for help is helpful to everyone.
thi
next prev parent reply other threads:[~2009-10-28 9:10 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-27 0:08 conditionals in elisp Harry Putnam
2009-10-27 0:25 ` Richard Riley
2009-10-27 1:03 ` Drew Adams
2009-10-27 5:33 ` Harry Putnam
2009-10-27 7:37 ` Drew Adams
2009-10-28 9:10 ` Thien-Thi Nguyen [this message]
2009-10-28 14:03 ` Drew Adams
[not found] ` <mailman.9621.1256738653.2239.help-gnu-emacs@gnu.org>
2009-10-28 15:42 ` LanX
2009-10-28 20:42 ` Harry Putnam
2009-10-28 16:19 ` Harry Putnam
[not found] ` <mailman.9630.1256746811.2239.help-gnu-emacs@gnu.org>
2009-11-02 19:31 ` Joseph Brenner
2009-10-27 5:50 ` tomas
[not found] <mailman.9533.1256602126.2239.help-gnu-emacs@gnu.org>
2009-10-27 0:19 ` Pascal J. Bourguignon
2009-10-27 2:52 ` LanX
2009-10-27 10:36 ` Pascal J. Bourguignon
2009-10-27 12:09 ` Richard Riley
2009-10-27 17:03 ` Sean Sieger
2009-10-28 12:07 ` Richard Riley
[not found] ` <mailman.9555.1256645401.2239.help-gnu-emacs@gnu.org>
2009-10-27 12:31 ` Pascal J. Bourguignon
2009-10-27 13:02 ` Richard Riley
[not found] ` <mailman.9557.1256648714.2239.help-gnu-emacs@gnu.org>
2009-10-27 16:04 ` Pascal J. Bourguignon
2009-10-27 17:26 ` Harry Putnam
[not found] ` <mailman.9572.1256664440.2239.help-gnu-emacs@gnu.org>
2009-10-27 18:37 ` Pascal J. Bourguignon
2009-10-27 19:40 ` Harry Putnam
[not found] ` <mailman.9577.1256672457.2239.help-gnu-emacs@gnu.org>
2009-10-27 21:14 ` Pascal J. Bourguignon
2009-10-28 14:05 ` David Kastrup
2009-10-28 15:55 ` Harry Putnam
2009-10-28 17:45 ` Pascal J. Bourguignon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=873a53rij7.fsf@ambire.localdomain \
--to=ttn@gnuvola.org \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).