help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: basic help evaluating function in an alist


From: Matt Price
Subject: Re: basic help evaluating function in an alist
Date: Sat, 1 Dec 2012 21:40:36 -0500

On Sat, Dec 1, 2012 at 6:12 PM, Drew Adams <drew.adams@oracle.com> wrote:
>> i'm trying to figure out what's wrong with this simple code:
>> (add-to-list 'my-winlist
>>              '(guide . (selected-window)))
>> (windmove-right)
>> (select-window(cdr(assoc 'guide my-winlist)) )
>
> Break it down.  Forget about `windmove-right'.  Just check the value of
> `my-winlist' after you added the element.
>
> (setq my-winlist ())
> (add-to-list 'my-winlist
>              '(guide . (selected-window)))
>
> `C-h v my-winlist' shows:
>
> ((guide selected-window))
>
> That's the same as ((guide . (selected-window)))
>
> Already you can see the problem: no window, just a list with the symbol
> `selected-window' as its sole element.
>
> If you want, try `M-: (cdr (assoc 'guide my-winlist))', to see that element:
> (selected-window).
>
> You need to evaluate `(selected-window)', not just use that list as the cdr of
> your element.  Here's what you need:
>
> (setq my-winlist ())
> (add-to-list 'my-winlist
>              (cons 'guide (selected-window)))
>
> `C-h v my-winlist' shows a list with one element, which is a dotted pair (aka
> cons cell), whose cdr is a window:
>
> ((guide . #<window 84 on *scratch*>))
>
> With backquote syntax you can express the same thing this way:
>
> (setq my-winlist ())
> (add-to-list 'my-winlist
>              `(guide ,(selected-window)))
>
> I recommend that you read this manual that comes with Emacs (use `C-h i'):
> `Emacs Lisp Intro'.  HTH.
>
that helps a lot.  I still don't quite understand what it is in the
syntax that causes the function (selected-window) to be evaluated in
one case and not the other, but I'll try to wrap my head around the
manual a little better  thanks to both of you!
matt



reply via email to

[Prev in Thread] Current Thread [Next in Thread]