From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: pjb@informatimago.com (Pascal J. Bourguignon) Newsgroups: gmane.emacs.help Subject: Re: identity function with an echo side effect Date: Wed, 11 Aug 2010 01:03:12 +0200 Organization: Informatimago Message-ID: <87eie6ax5b.fsf@kuiper.lan.informatimago.com> References: <324e9d4c-b083-42a3-aa88-4e7b918042e3@h32g2000yqm.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1291858005 4020 80.91.229.12 (9 Dec 2010 01:26:45 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 9 Dec 2010 01:26:45 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Dec 09 02:26:41 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PQVHK-0003Tt-Ac for geh-help-gnu-emacs@m.gmane.org; Thu, 09 Dec 2010 02:26:38 +0100 Original-Received: from localhost ([127.0.0.1]:39503 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PQVHJ-0001UR-KO for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Dec 2010 20:26:37 -0500 Original-Path: usenet.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help, comp.emacs, comp.emacs.xemacs, gnu.emacs, comp.lang.lisp Original-Lines: 71 Original-X-Trace: individual.net w5FQWNp/Vc9FEoF8zk7cig3ANCS4CvKfFMsuLWeV74ec1XMNEP Cancel-Lock: sha1:NjAzNDQ0OTcwM2E0YjAxNjA0NDYwYzlmNzdkYTBjM2U1NDBlOWNkZQ== sha1:+UyVl5FvLJndugxTrI6xAiAdO64= Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en X-Disabled: X-No-Archive: no User-Agent: Gnus/5.101 (Gnus v5.10.10) Emacs/23.2 (gnu/linux) Original-Xref: usenet.stanford.edu gnu.emacs.help:180561 comp.emacs:100329 comp.emacs.xemacs:82486 comp.lang.lisp:291087 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:76381 Archived-At: bolega 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/