From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thien-Thi Nguyen Newsgroups: gmane.emacs.help Subject: Re: conditionals in elisp Date: Wed, 28 Oct 2009 10:10:04 +0100 Message-ID: <873a53rij7.fsf@ambire.localdomain> References: <87iqe1og0i.fsf@newsguy.com> <14A45A8A6D3A42A7ADA56DE8DB68C74E@us.oracle.com> <8763a1o0yx.fsf@newsguy.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1256722876 22143 80.91.229.12 (28 Oct 2009 09:41:16 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 28 Oct 2009 09:41:16 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Oct 28 10:41:10 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1N351h-0001Qs-F4 for geh-help-gnu-emacs@m.gmane.org; Wed, 28 Oct 2009 10:41:09 +0100 Original-Received: from localhost ([127.0.0.1]:49510 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N351g-0005o1-Mo for geh-help-gnu-emacs@m.gmane.org; Wed, 28 Oct 2009 05:41:08 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N350x-0005na-ML for help-gnu-emacs@gnu.org; Wed, 28 Oct 2009 05:40:23 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N350s-0005ml-Rd for help-gnu-emacs@gnu.org; Wed, 28 Oct 2009 05:40:22 -0400 Original-Received: from [199.232.76.173] (port=52432 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N350s-0005md-KK for help-gnu-emacs@gnu.org; Wed, 28 Oct 2009 05:40:18 -0400 Original-Received: from smtp-out13.alice.it ([85.33.2.18]:1486) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N350s-0001k2-4d for help-gnu-emacs@gnu.org; Wed, 28 Oct 2009 05:40:18 -0400 Original-Received: from fbcmmo06.fbc.local ([192.168.184.137]) by smtp-out13.alice.it with Microsoft SMTPSVC(6.0.3790.3959); Wed, 28 Oct 2009 10:13:07 +0100 Original-Received: from FBCMCL01B05.fbc.local ([192.168.69.86]) by fbcmmo06.fbc.local with Microsoft SMTPSVC(6.0.3790.3959); Wed, 28 Oct 2009 10:13:05 +0100 Original-Received: from ambire.localdomain ([79.24.23.233]) by FBCMCL01B05.fbc.local with Microsoft SMTPSVC(6.0.3790.3959); Wed, 28 Oct 2009 10:13:04 +0100 Original-Received: from ttn by ambire.localdomain with local (Exim 4.63) (envelope-from ) id 1N34Xc-0002Ns-AJ for help-gnu-emacs@gnu.org; Wed, 28 Oct 2009 10:10:04 +0100 In-Reply-To: (Drew Adams's message of "Tue, 27 Oct 2009 00:37:38 -0700") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) X-OriginalArrivalTime: 28 Oct 2009 09:13:04.0668 (UTC) FILETIME=[DB2EBDC0:01CA57AE] X-detected-operating-system: by monty-python.gnu.org: Windows 2000 SP4, XP SP1+ X-Greylist: delayed 1630 seconds by postgrey-1.27 at monty-python; Wed, 28 Oct 2009 05:40:17 EDT X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:69299 Archived-At: () "Drew Adams" () 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