From: lpillman
Subject: using let
Date: 
Message-ID: <3B27BFCB.A8B9F1CA@best.com>
i'm a lisp newbie, so bear with me. i've read a lot of web 
pages, manuals, etc. and must be missing someting VERY 
simple. 

i can't get the following to work (adding font-lock
support for an emacs mode and i need %size, $page, etc):

(defvar mgp-font-lock-keywords
  (let (keywords '("size\\|page"))
   (list (concat "\\%\\(" keywords  "\\)")
	    1 'font-lock-keyword-face)
   )
"keywords for mgp-font-lock")

thanks,

- brett

From: Barry Margolin
Subject: Re: using let
Date: 
Message-ID: <joPV6.39$5G3.507@burlma1-snr2>
In article <·················@best.com>, lpillman  <········@best.com> wrote:
>i'm a lisp newbie, so bear with me. i've read a lot of web 
>pages, manuals, etc. and must be missing someting VERY 
>simple. 
>
>i can't get the following to work (adding font-lock
>support for an emacs mode and i need %size, $page, etc):
>
>(defvar mgp-font-lock-keywords
>  (let (keywords '("size\\|page"))
>   (list (concat "\\%\\(" keywords  "\\)")
>	    1 'font-lock-keyword-face)
>   )
>"keywords for mgp-font-lock")

The syntax of LET is:

(let ((<var1> <val1>)
      (<var2> <val2>)
      ...)
  <body>)

Compare this syntax to what you wrote, paying careful attention to the
number of parentheses.

(For the pedants out there, I know I've left out a special case; once he's
mastered the basic syntax, we can let him in on the shortcuts.)

-- 
Barry Margolin, ······@genuity.net
Genuity, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
From: lpillman
Subject: Re: using let
Date: 
Message-ID: <3B27C51F.F423D82C@best.com>
Barry Margolin wrote:
> 
> In article <·················@best.com>, lpillman  <········@best.com> wrote:
> >i'm a lisp newbie, so bear with me. i've read a lot of web
> >pages, manuals, etc. and must be missing someting VERY
> >simple.
> >
> >i can't get the following to work (adding font-lock
> >support for an emacs mode and i need %size, $page, etc):
> >
> >(defvar mgp-font-lock-keywords
> >  (let (keywords '("size\\|page"))
> >   (list (concat "\\%\\(" keywords  "\\)")
> >           1 'font-lock-keyword-face)
> >   )
> >"keywords for mgp-font-lock")
> 
> The syntax of LET is:
> 
> (let ((<var1> <val1>)
>       (<var2> <val2>)
>       ...)
>   <body>)
> 
> Compare this syntax to what you wrote, paying careful attention to the
> number of parentheses.

okay, but even if i surround my one variable mapping like so (i didn't
think you needed the surrounding () for only one mapping) it still 
doesn't work.

(defvar mgp-font-lock-keywords
  (let (
	(keywords '("size\\|page"))
	(list (concat "\\%\\(" keywords  "\\)")
	      1 'font-lock-keyword-face)
	)
    )
"keywords for mgp-font-lock")
From: Christopher Stacy
Subject: Re: using let
Date: 
Message-ID: <ubsnsrtm6.fsf@spacy.Boston.MA.US>
Look at Barry's example again (you didn't do all that he suggested).
From: Barry Margolin
Subject: Re: using let
Date: 
Message-ID: <sf4W6.6$4O4.86@burlma1-snr2>
In article <·················@best.com>, lpillman  <········@best.com> wrote:
>Barry Margolin wrote:
>> 
>> In article <·················@best.com>, lpillman  <········@best.com> wrote:
>> >i'm a lisp newbie, so bear with me. i've read a lot of web
>> >pages, manuals, etc. and must be missing someting VERY
>> >simple.
>> >
>> >i can't get the following to work (adding font-lock
>> >support for an emacs mode and i need %size, $page, etc):
>> >
>> >(defvar mgp-font-lock-keywords
>> >  (let (keywords '("size\\|page"))
>> >   (list (concat "\\%\\(" keywords  "\\)")
>> >           1 'font-lock-keyword-face)
>> >   )
>> >"keywords for mgp-font-lock")
>> 
>> The syntax of LET is:
>> 
>> (let ((<var1> <val1>)
>>       (<var2> <val2>)
>>       ...)
>>   <body>)
>> 
>> Compare this syntax to what you wrote, paying careful attention to the
>> number of parentheses.
>
>okay, but even if i surround my one variable mapping like so (i didn't
>think you needed the surrounding () for only one mapping) it still 
>doesn't work.

The reason why you need the extra () for one binding is because of the
special case that I omitted.  Instead of (<varN> <valN>) you're allowed to
write just <varN>, and it's a shortcut for (<varN> nil).  So your original
code was actually binding *two* variables; it was equivalent to:

  (let ((keywords nil)
        (quote ("size\\|page")))
    ...)

>(defvar mgp-font-lock-keywords
>  (let (
>	(keywords '("size\\|page"))
>	(list (concat "\\%\\(" keywords  "\\)")
>	      1 'font-lock-keyword-face)
>	)
>    )
>"keywords for mgp-font-lock")

Look at where you have LIST now.  It's in the place where the second
variable binding would be, rather than the body.

P.S. Please see any Lisp textbook for the accepted way to lay out
indentation and parentheses.  A line should never end with an open
parenthesis or begin with a close paren.

-- 
Barry Margolin, ······@genuity.net
Genuity, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.