all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: pjb@informatimago.com (Pascal J. Bourguignon)
To: help-gnu-emacs@gnu.org
Subject: Re: identity function with an echo side effect
Date: Wed, 11 Aug 2010 01:03:12 +0200	[thread overview]
Message-ID: <87eie6ax5b.fsf@kuiper.lan.informatimago.com> (raw)
In-Reply-To: 324e9d4c-b083-42a3-aa88-4e7b918042e3@h32g2000yqm.googlegroups.com

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	other threads:[~2010-08-10 23:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-10 20:56 identity function with an echo side effect bolega
2010-08-10 23:03 ` Pascal J. Bourguignon [this message]
2010-08-11  5:01   ` bolega
2010-08-11 14:19     ` Pascal J. Bourguignon
2010-08-11 17:42       ` bolega
2010-08-11 20:43         ` Pascal J. Bourguignon
2010-08-12  2:35         ` TheFlyingDutchman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87eie6ax5b.fsf@kuiper.lan.informatimago.com \
    --to=pjb@informatimago.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.