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: emacs lisp programming help Date: Thu, 29 Jan 2009 20:37:58 +0100 Organization: Informatimago Message-ID: <87tz7hx5rd.fsf@galatea.local> References: <2c75e627-536b-47b7-8569-20781b041336@v39g2000pro.googlegroups.com> <87ljsuyo9a.fsf@galatea.local> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1233258098 25621 80.91.229.12 (29 Jan 2009 19:41:38 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 29 Jan 2009 19:41:38 +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 Jan 29 20:42:51 2009 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.50) id 1LScmh-0007Yo-62 for geh-help-gnu-emacs@m.gmane.org; Thu, 29 Jan 2009 20:42:43 +0100 Original-Received: from localhost ([127.0.0.1]:41960 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LSclP-0000eW-2H for geh-help-gnu-emacs@m.gmane.org; Thu, 29 Jan 2009 14:41:23 -0500 Original-Path: news.stanford.edu!headwall.stanford.edu!news.glorb.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!cleanfeed1-b.proxad.net!nnrp14-2.free.fr!not-for-mail Original-Newsgroups: gnu.emacs.help 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.1008 (Gnus v5.10.8) Emacs/22.3 (darwin) Cancel-Lock: sha1:MDliNjg1MmVkYTlkYzQ0MmFhYmJmYzE0MzQzNDcyZTNhYWJhN2IzYQ== Original-Lines: 75 Original-NNTP-Posting-Date: 29 Jan 2009 20:38:00 MET Original-NNTP-Posting-Host: 88.182.134.169 Original-X-Trace: 1233257880 news-2.free.fr 29531 88.182.134.169:60876 Original-X-Complaints-To: abuse@proxad.net Original-Xref: news.stanford.edu gnu.emacs.help:166446 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:61764 Archived-At: ramestica@gmail.com writes: > On Jan 29, 1:13 pm, p...@informatimago.com (Pascal J. Bourguignon) > wrote: >> In general, emacs questions (even emacs lisp) would be > > I was about to do that but then I hesitated and look for a forum with > the word 'lisp' on it. > >> What does the quote do?  What does 'x evaluate to? >> And what does '(a b c) evaluate to? >> And what does '(a . b) evaluate to? >> So what does '(font . my-default-font) evaluate to? > > I cannot really answer these questions. I do not know. You can either know it by learning more emacs lisp, http://www.gnu.org/software/emacs/manual/elisp.html http://www.delorie.com/gnu/docs/emacs-lisp-intro/emacs-lisp-intro_toc.html or by asking emacs itself to give you the answer. Go in the *scratch* buffer, put it in emacs-lisp-mode (type M-x emacs-lisp-mode RET) then type: 'x C-u C-x C-e '(a b c) C-u C-x C-e '(a . b) C-u C-x C-e '(font . my-default-font) C-u C-x C-e and compare with: (setq x 42) C-x C-e x C-u C-x C-e (a b c) C-u C-x C-e (type q to get out of the debugger) (list 'a 'b 'c) C-u C-x C-e (a . b) (cons 'a 'b) With C-x C-e, the previous s-exp is evaluated and the result is printed in the mini buffer. With C-u C-x C-e, the result is inserted at the point in the current buffer. An alternative is to call up the REPL: M-x ielm RET and then you can type your emacs lisp expressions and just type RET to get the result: 'x RET '(a b c) RET (list 'a 'b 'c) RET etc... Notice that you can use C-x C-u in almost all the modes, so if you need to insert repeatitive code, you can quickly do it by writting a lisp expression to do so; (dolist (color '(red green blue)) (insert (format "this->setPlane(Color::%s,other->getPlane(Color::%s));\n" color color))) C-x C-e inserts: this->setPlane(Color::red,other->getPlane(Color::red)); this->setPlane(Color::green,other->getPlane(Color::green)); this->setPlane(Color::blue,other->getPlane(Color::blue)); (and you can keep the emacs lisp code in a C comment if you may need to change it later). >> What other mean to create a cons cell do you know? > > Using (cons ...), that helped. Many many thanks for the help. > > Rodrigo -- __Pascal Bourguignon__