From: Oliver Scholz <alkibiades@gmx.de>
Subject: Re: trouble writing a conditional, or with lambda
Date: Sat, 24 May 2003 18:08:28 +0200 [thread overview]
Message-ID: <usmr4z5s3.fsf@ID-87814.user.dfncis.de> (raw)
In-Reply-To: m3d6i8cond.fsf@russel.teuto37
Florian von Savigny <florian265@uboot.com> 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é!
next prev parent reply other threads:[~2003-05-24 16:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-05-24 16:09 trouble writing a conditional, or with lambda Florian von Savigny
2003-05-24 15:37 ` Thomas Gehrlein
2003-05-24 16:08 ` Oliver Scholz [this message]
2003-05-24 16:14 ` lawrence mitchell
2003-05-25 12:04 ` Florian von Savigny
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=usmr4z5s3.fsf@ID-87814.user.dfncis.de \
--to=alkibiades@gmx.de \
/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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.