unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* (list) and '(list)
@ 2007-04-26 15:17 A Soare
  2007-04-27 10:25 ` Kai Grossjohann
       [not found] ` <mailman.2588.1177669955.7795.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 10+ messages in thread
From: A Soare @ 2007-04-26 15:17 UTC (permalink / raw)
  To: Emacs   Help  [help-gnu-emacs]

Can somebody tell me if there already is a code that makes the distintion between a list that evaluates as a function like

(function ...

and between a list that evaluates to itself :

'(list ... , and its aliases like (quote (list ... etc

^ permalink raw reply	[flat|nested] 10+ messages in thread
[parent not found: <mailman.2557.1177600988.7795.help-gnu-emacs@gnu.org>]
* Re: (list) and '(list)
@ 2007-04-27 10:37 A Soare
  0 siblings, 0 replies; 10+ messages in thread
From: A Soare @ 2007-04-27 10:37 UTC (permalink / raw)
  To: Kai Grossjohann; +Cc: Emacs   Help  [help-gnu-emacs]

> The following message is a courtesy copy of an article
> that has been posted to gmane.emacs.help as well.
> 
> A Soare <alinsoar@voila.fr> writes:
> 
> > Can somebody tell me if there already is a code that makes the
> > distintion between a list that evaluates as a function like
> >
> > (function ...
> >
> > and between a list that evaluates to itself :
> >
> > '(list ... , and its aliases like (quote (list ... etc
> 
> Like the others who responded, it is not clear to me what you want.
> 
> Lisp normally reads code and then evaluates (evals) it.  During
> reading, it performs some (few) conversions such as 'foo to (quote
> foo).  During evaluation, the magic happens:
> 
> - If we are looking at a number or a string, return that number or
>   string.  (Numbers and strings are said to be self-evaluating because
>   they evaluate to themselves.)  If we are looking at some special
>   symbols (like t and nil), return those values.  (t and nil are also
>   self-evaluating.)
> 
> - If we are looking at a list, look at the first element of the list.
>   If it is a function, then eval all other elements of the list, then
>   use the results as arguments to the function (call the function).
>   Then return the result of the function call.
> 
> - The first element can also be a special form.  In this case, the
>   other elements of the list are NOT evaled but instead passed to the
>   special form verbatim.
> 
>   Popular special forms: defun, quote, if, setq
> 
> So in a strict sense, what you can do is:
> 



>   (setq unevaled (read STREAM))
>   (setq evaled (eval unevaled))
>   (equal unevaled evaled)

That is what I wanted to know. Giving a string/[part of a buffer] that represents a LISP code, to say if a list inside it defines a function or a symbol (that evaluates to itself).

That code solves my problem. Thank you very much.


Alin Soare.

^ permalink raw reply	[flat|nested] 10+ messages in thread
* Re: (list) and '(list)
@ 2007-04-30 18:15 A Soare
  0 siblings, 0 replies; 10+ messages in thread
From: A Soare @ 2007-04-30 18:15 UTC (permalink / raw)
  To: Emacs   Help  [help-gnu-emacs]

Now the utility of my question is the following.

I rewrote the indentation of lisp code (I am still working on, but the base is done). There are still problems. Look one:

(+ 1 2 3
   4 5 6)

This is a list that calls a function. Now this case:

(setq a '(a b c
            d e f)

With the current indentation, we would have:

(setq a '(a b c
            d e f)

I do not like this. I want to indent for the quoted lists so:

(setq a '(a b c
            d e f)


So I need the simplesc code that detects whether a list is commented or not.


Alin Soare.

^ permalink raw reply	[flat|nested] 10+ messages in thread
* Re: (list) and '(list)
@ 2007-04-30 18:53 A Soare
  0 siblings, 0 replies; 10+ messages in thread
From: A Soare @ 2007-04-30 18:53 UTC (permalink / raw)
  To: Emacs   Help  [help-gnu-emacs]


I will use something like that:

(memq (caar (read-from-string "(function (list list))")) '(function quote))

This is an answer to my problem.

If you have better solutions, please tell me.


Alin Soare.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2007-04-30 18:53 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-26 15:17 (list) and '(list) A Soare
2007-04-27 10:25 ` Kai Grossjohann
     [not found] ` <mailman.2588.1177669955.7795.help-gnu-emacs@gnu.org>
2007-04-27 10:39   ` David Kastrup
2007-04-27 11:05   ` Pascal Bourguignon
2007-04-30 12:49     ` Kai Grossjohann
     [not found] <mailman.2557.1177600988.7795.help-gnu-emacs@gnu.org>
2007-04-26 21:55 ` Pascal Bourguignon
2007-04-27  0:58 ` Tim X
  -- strict thread matches above, loose matches on Subject: below --
2007-04-27 10:37 A Soare
2007-04-30 18:15 A Soare
2007-04-30 18:53 A Soare

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).