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: Drew Adams
Subject: RE: basic help evaluating function in an alist
Date: Sat, 1 Dec 2012 15:12:02 -0800

> 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.




reply via email to

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