From: ·········@gmail.com
Subject: emacs lisp programming help
Date: 
Message-ID: <2c75e627-536b-47b7-8569-20781b041336@v39g2000pro.googlegroups.com>
Hi,

in my .emacs. file I have some logic for setting my prefer font. I
tried something like this:

;; f-name and f-size-default are strings set to something
;; reasonable
(setq my-default-font (concat f-name f-size-default))
(add-to-list 'default-frame-alist '(font . my-default-font))

then when I start emacs I get logs like this

frame-notice-user-settings: Invalid font: my-default-font

It seems to be a lisp thing that I cannot grasp. Why is that the value
of my-default-font is not replaced in the last expression?

thanks,
 Rodrigo

From: Thomas A. Russ
Subject: Re: emacs lisp programming help
Date: 
Message-ID: <ymi7i4eq9wb.fsf@blackcat.isi.edu>
·········@gmail.com writes:

> Hi,
> 
> in my .emacs. file I have some logic for setting my prefer font. I
> tried something like this:
> 
> ;; f-name and f-size-default are strings set to something
> ;; reasonable
> (setq my-default-font (concat f-name f-size-default))
> (add-to-list 'default-frame-alist '(font . my-default-font))
> 
> then when I start emacs I get logs like this
> 
> frame-notice-user-settings: Invalid font: my-default-font
> 
> It seems to be a lisp thing that I cannot grasp. Why is that the value
> of my-default-font is not replaced in the last expression?

Because the last expression is quoted.  Quoting any expression in lisp
inhibits evaluation.  But what you want is actually only partial
evaluation of the cons cell, since you want the value of MY-DEFAULT-FONT
to be used, but the literal FONT as the key.  

So you need to go one level down in this and construct the cons cell
using the CONS function, quoting one argument but not the other:

(add-to-list 'default-frame-alist (cons 'font my-default-font))

Note also that the "cons-dot" is not used anymore, since we are creating
the cons with a function rather than reading it as a literal.

-- 
Thomas A. Russ,  USC/Information Sciences Institute
From: ·········@gmail.com
Subject: Re: emacs lisp programming help
Date: 
Message-ID: <84d212b2-33d4-4611-a731-173b95d35f3f@41g2000yqf.googlegroups.com>
Pascal's posting put me in right track for using building the cons
properly, exactly as suggested in the last posting.

Oh well, it's just my dumbness to properly understand how lisp works
on what respect references and actual values. I have read about it,
but I always end up lost.

many thanks,
 Rodrigo
From: Rainer Joswig
Subject: Re: emacs lisp programming help
Date: 
Message-ID: <joswig-993FDC.20322529012009@news-europe.giganews.com>
In article 
<····································@41g2000yqf.googlegroups.com>,
 ·········@gmail.com wrote:

> Pascal's posting put me in right track for using building the cons
> properly, exactly as suggested in the last posting.
> 
> Oh well, it's just my dumbness to properly understand how lisp works
> on what respect references and actual values. I have read about it,
> but I always end up lost.
> 
> many thanks,
>  Rodrigo

You can easily try things out in Emacs.
Use the "Interactive Emacs Lisp Mode" (ielm).

You will get into ielm via Meta-x ielm .

Then you can type Emacs Lisp expressions, evaluate them
and have the results printed:


ELISP> (cons 'foo 'bar)
(foo . bar)

ELISP> (car *)
foo
ELISP> 


This will help you with experimenting with Emacs Lisp code.

Emacs should also come with the Elisp manual.
c-h i  gives the overview of the varios manuals.
Choose the elisp manual.

The Elisp is a very useful reference. There should
also be another manual: "Emacs Lisp Intro".

-- 
http://lispm.dyndns.org/
From: ·········@gmail.com
Subject: Re: emacs lisp programming help
Date: 
Message-ID: <6ada867a-9642-4a40-8214-d9805caab37c@z28g2000prd.googlegroups.com>
gush! I was tired of ctrl-e in the scratch buffer. I was not aware of
this interactive mode!

many many thanks,
 Rodrigo
From: Xah Lee
Subject: Re: emacs lisp programming help
Date: 
Message-ID: <cd31048e-ac4a-4a85-8744-ed64ab7d30ea@r15g2000prd.googlegroups.com>
On Jan 29, 11:42 am, ·········@gmail.com wrote:
> gush! I was tired of ctrl-e in the scratch buffer. I was not aware of
> this interactive mode!

you might find this tutorial helful:

• Emacs Lisp Tutorial
  http://xahlee.org/emacs/elisp.html

> It seems to be a lisp thing that I cannot grasp. Why is that the value
> of my-default-font is not replaced in the last expression

Your confusion about this is a FAQ. Namely, about the cons, and the
irregular systax such as '(something) and (a . b). These are well
known problems. See:

• Fundamental Problems of Lisp
  http://xahlee.org/UnixResource_dir/writ/lisp_problems.html

Excerpt:

----------------------
Syntax Irregularities

Lisp family of languages, in particular, Common Lisp, Scheme Lisp,
Emacs Lisp, are well know for its syntax's regularity, namely,
“everything” is of the form “(f x1 x2 ...)”. However, it is little
talked about that there are several irregularities in its syntax. Here
are some examples of the syntax irregularity.

    * The comment syntax of semicolon to end of line “;”.
    * The dotted notation for cons cell “(1 . 2)”.
    * The single quote syntax used to hold evaluation, e.g. “'(1 2
3)”.
    * The backquote and comma syntax used to hold but evaluate parts
of expression, e.g. “(setq x 1) (setq myVariableAndValuePair `
(x ,x))”.
    * The “,@” for inserting a list as elements into another list.
e.g. “(setq myListX (list 1 2)) (setq myListY (list 3 4)) (setq
myListXY `(,@ myListX ,@ myListY))”
    * There are various others in Common Lisp or Scheme Lisp. For
example, the char “#” and “#|”. In Scheme's R6RS, it has introduced a
few new ones.

In the following, i detail how these irregularities hamper the power
of regular syntax, and some powerful features and language
developments that lisp have missed that may be due to it.

Confusing

Lisp's irregular syntax are practically confusing. For example, the
difference between “(list 1 2 3)”, “'(1 2 3)”, “(quote (1 2 3))” is a
frequently asked question. The use of “` , ,@” etc are esoteric. If
all these semantics use the regular syntactical form “(f args)”, then
much confusion will be reduced and people will understand and use
these features better.

-----------------------------

  Xah
∑ http://xahlee.org/

☄
From: Kaz Kylheku
Subject: Re: emacs lisp programming help
Date: 
Message-ID: <20090204132950.77@gmail.com>
On 2009-01-29, ·········@gmail.com <·········@gmail.com> wrote:
> Pascal's posting put me in right track for using building the cons
> properly, exactly as suggested in the last posting.
>
> Oh well, it's just my dumbness to properly understand how lisp works
> on what respect references and actual values. I have read about it,
> but I always end up lost.

As a rule of thumb, if you can't grok pointers, you're probably
not fit for software development, sorry.

If there is one single litmus test that a career counsellor could apply to
separate the would-be devleopers from the non-would-be developer, that might be
it.

Pointers do not get any easier to understand than they do in Lisp.
The bar really does not go any lower.  If you can't clear six inches, maybe
hurdles is not your sport; try shotput.
From: Pascal J. Bourguignon
Subject: Re: emacs lisp programming help
Date: 
Message-ID: <87ljsuyo9a.fsf@galatea.local>
·········@gmail.com writes:
> in my .emacs. file I have some logic for setting my prefer font. I

In general, emacs questions (even emacs lisp) would be better answered
in one of the emacs newsgroups, such as news:gnu.emacs.help.  However,
this one is not specific to emacs, so we'll answer here:


> tried something like this:
>
> ;; f-name and f-size-default are strings set to something
> ;; reasonable
> (setq my-default-font (concat f-name f-size-default))
> (add-to-list 'default-frame-alist '(font . my-default-font))
>
> then when I start emacs I get logs like this
>
> frame-notice-user-settings: Invalid font: my-default-font
>
> It seems to be a lisp thing that I cannot grasp. Why is that the value
> of my-default-font is not replaced in the last expression?

What does the quote do?  What does 'x evaluate to?
And what does '(a b c) evaluate to?
And what does '(a . b) evaluate to?
So what does '(font . my-default-font) evaluate to?
What other mean to create a cons cell do you know?

-- 
__Pascal Bourguignon__