From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Oliver Scholz Newsgroups: gmane.emacs.help Subject: Re: trouble writing a conditional, or with lambda Date: Sat, 24 May 2003 18:08:28 +0200 Sender: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: main.gmane.org 1053792671 24420 80.91.224.249 (24 May 2003 16:11:11 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sat, 24 May 2003 16:11:11 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Sat May 24 18:11:08 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19JbbX-0006KK-00 for ; Sat, 24 May 2003 18:10:43 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.20) id 19Jbb9-0003og-63 for gnu-help-gnu-emacs@m.gmane.org; Sat, 24 May 2003 12:10:19 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!headwall.stanford.edu!fu-berlin.de!uni-berlin.de!dialin-145-254-134-133.arcor-ip.NET!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 73 Original-NNTP-Posting-Host: dialin-145-254-134-133.arcor-ip.net (145.254.134.133) Original-X-Trace: fu-berlin.de 1053792527 1885845 145.254.134.133 (16 [87814]) X-Attribution: os X-Face: "HgH2sgK|bfH$; PiOJI6|qUCf.ve<51_Od(%ynHr?=>znn#~#oS>",F%B8&\vus),2AsPYb -n>PgddtGEn}s7kH?7kH{P_~vu?]OvVN^qD(L)>G^gDCl(U9n{:d>'DkilN!_K"eNzjrtI4Ya6;Td% IZGMbJ{lawG+'J>QXPZD&TwWU@^~A}f^zAb[Ru;CT(UA]c& User-Agent: Gnus/5.090019 (Oort Gnus v0.19) Emacs/21.3.50 (windows-nt) Cancel-Lock: sha1:1hZ48Cpkfk8vaXgy/0R2FS7Rbbw= Original-Xref: shelby.stanford.edu gnu.emacs.help:113656 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:10152 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:10152 Florian von Savigny writes: > Sigh ... > > > some basic lisp, I'm afraid, but I did consult the manual and tested > in lisp-interaction-mode, but did not get any the wiser. > > I'm trying to get a function to work differently depending on whether > emacs runs under X or on a terminal: > > (if (eq window-system nil) > ; running under a terminal > (lambda () > (split-window) > (switch-to-buffer "*foo*") > ) > ; running under a window system > (lambda () > (select-frame (make-frame)) > (set-frame-size (selected-frame) 50 24) > (set-frame-position (selected-frame) 150 120) > )) Two notes: 1) You should not check the variable `window-system', if you can avoid it. Better check for the specific feature you need. In this case you could probably use the function `display-multi-frame-p'. 2) The expression above does not call `split-window', `select-frame' and the like, it just returns an /anonymous function/ (aka "lambda-function"). You could call `funcall' the return value of your expression, but this is probably not what you want. I think, this is more likely to do what you want to achieve: (if (display-multi-frame-p) ;; Running under a terminal (progn (split-window) (switch-to-buffer "*foo*")) ;; running under a window system ;; (`progn' is not necessary here, because `if' accepts more than ;; three arguments. All arguments from the third one onward ;; constitute the THEN clause.) (select-frame (make-frame)) (set-frame-size (selected-frame) 50 24) (set-frame-position (selected-frame) 150 120)) > It seems that everything in the lambda expressions is ignored > (i.e. nothing happens). I used these lambda expressions because > simply putting a body of functions got error messages about "Invalid > function"s. But it seems I don't get these right. > > > (lambda ( > (split-window) > (switch-to-buffer "*foo*") > )) > > also seems to be valid syntax, but is also ignored. No, it is not valid syntax. But it is not evaluated either, therefore you don't get an error. You could have a look at the "Introduction to Emacs Lisp" by Robert Chassell, which explains some basics of Emacs Lisp. Oliver -- 5 Prairial an 211 de la Révolution Liberté, Egalité, Fraternité!