From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tim X Newsgroups: gmane.emacs.help Subject: Re: Detect if Emacs is running in -nw mode Date: Mon, 31 Mar 2008 18:11:44 +1000 Organization: Rapt Technologies Message-ID: <87r6dr5n3z.fsf@lion.rapttech.com.au> References: <3P2dnatDgO4bJnLanZ2dnUVZ8vOdnZ2d@giganews.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1206952898 22337 80.91.229.12 (31 Mar 2008 08:41:38 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 31 Mar 2008 08:41:38 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Mar 31 10:42:09 2008 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 1JgFac-00039R-Hz for geh-help-gnu-emacs@m.gmane.org; Mon, 31 Mar 2008 10:42:02 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JgFa0-0000Yl-H4 for geh-help-gnu-emacs@m.gmane.org; Mon, 31 Mar 2008 04:41:24 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!sn-xt-sjc-03!sn-xt-sjc-01!sn-post-sjc-02!sn-post-sjc-01!supernews.com!corp.supernews.com!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) Cancel-Lock: sha1:aM3n/uSdt64HQXHl0J95nJ9AfCI= Original-X-Complaints-To: abuse@supernews.com Original-Lines: 98 Original-Xref: shelby.stanford.edu gnu.emacs.help:157518 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:52889 Archived-At: Christian Herenz writes: > Rupert Swarbrick schrieb: > >> (unless (function-returning-nil) 1 2 3) >> >> evaluates to 3. Not that that matters in this situation. >> >> Phew. That was more than I intended to write! Hope it makes things a >> little clearer. >> >> Rupert > > Yeah-- You wrote much, and I think you missed the point a little bit.. > > (unless nil (do-stuff) (do-other-stuff)) ... this would only do-stuff? > > (unless nil ((do-stuff) (do-other-stuff)) would do-stuff and do-other-stuff? > > That was my actual question. > > Greets, > Christian When working with any form of lisp, code formatting is the secret. In fact, its probably more important in lisp languages because unlike other languages, code and data are pretty much the same thing. So, in your current situation .... (unless condition body) means unless the condition is true, execute body. Now body can consist of more than one form, i.e. (unless condition (do-thing-1 arg1) (do-thing-2) (do-thing-3 arg1 arg2)) would execute 'do-thing-1' with one argument arg1 'do-thing-2' with no arguments 'do-thing-3' with two arguments arg1 and arg2 All of the body forms will be executed if any of them are executed and you can have as many as you like. If you want to execute some forms if the condition is true and execute other forms if it is not, then you want either 'if' or 'cond'. Note that 'if' only allows for one form in the first part e.g. (if window-system (do-true-thing) (do-false-thing)) You can use progn to add morre forms to the first part, but that is generally considered poor lisp style e.g. (if window-system (progn (do-thing-1) (do-thing-2)) (do-other-else-thing Note that the else part can either be absent or contain multiple forms to be evaluated. In the case where you want to execute multiple forms for the 'true' part, you often see a cond used (cond = conditional). cond is particularly useful wehn you have more than a true/false situation. Often, the last condition in a cond is 't', which evaluates to true - think of it as the 'catch-all'. If none of the other tests match, this one will. The cond can be useful if you run on multiple platforms e.g. (cond ((eq window-system 'x) (do-something-for-x-1) (do-something-for-x-2)) ((eq eindow-system 'windows) (do-soemthing-for-windows-1) (do-something-for-windows-2)) (t (do-this-if-not-x-or-windows-1) (do-this-if-not-x-or-windows-2))) I highly recommend you read the Introduction to Emacs Lisp as this will make it clear. Tim -- tcross (at) rapttech dot com dot au