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

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

Re: identity function with an echo side effect


From: Pascal J. Bourguignon
Subject: Re: identity function with an echo side effect
Date: Wed, 08 Dec 2010 15:24:06 -0000
User-agent: Gnus/5.101 (Gnus v5.10.10) Emacs/23.2 (gnu/linux)

bolega <gnuist006@gmail.com> writes:

> After searching google groups and emacs apropos extensively, I could
> not find a function, perhaps I am missing one that can return
> identically return its argument and has a small side effect of echoing
> the argument in some place such as for example
>
> the mini buffer or the point at which C-x C-e is typed.
>
> For example, calling this function "echo" , usage would look like
> this :
>
> (cdr ( echo (cdr (echo (cdr (echo '(a b c d)))))))
>
> echo:
> '(a b c d) or (a b c d)  (I am not sure which would be appropriate)
> (b c d)
> (c d)
>
> result:
> (d)
>
> Is there a need for quotes to prevent evaluation of alphabets at any
> phase ?

In Common Lisp, you can use PRINT for this.


CL-USER> (cdr (print (cdr (print (cdr (print '(a b c d)))))))

(A B C D) 
(B C D) 
(C D) 
(D)
CL-USER> 



In emacs lisp too, but the output of print goes to the *Message* buffer.

M-x ielm RET
ELISP> (cdr (print (cdr (print (cdr (print '(a b c d)))))))
(d)

and you get:

(a b c d)

(b c d)

(c d)

in the minibuffer and in *Message*.


Or, in an emacs lisp buffer:

(cdr (print (cdr (print (cdr (print '(a b c d))))))) C-u C-x C-e

inserts:

(a b c d)

(b c d)

(c d)
(d)


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/


reply via email to

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