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: How to learn elisp ? Date: Wed, 05 Aug 2009 17:34:45 +0200 Organization: Anevia SAS Message-ID: <7cocqujmui.fsf@pbourguignon.anevia.com> References: <907065090908050308n695eb056u8d962760efc62468@mail.gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1249486949 1086 80.91.229.12 (5 Aug 2009 15:42:29 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 5 Aug 2009 15:42:29 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Aug 05 17:42:20 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 1MYidA-0002yt-47 for geh-help-gnu-emacs@m.gmane.org; Wed, 05 Aug 2009 17:42:20 +0200 Original-Received: from localhost ([127.0.0.1]:34470 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MYid9-0004Bz-Dr for geh-help-gnu-emacs@m.gmane.org; Wed, 05 Aug 2009 11:42:19 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!proxad.net!feeder1-2.proxad.net!cleanfeed3-a.proxad.net!nnrp3-1.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.101 (Gnus v5.10.10) Emacs/22.2 (gnu/linux) Cancel-Lock: sha1:MWY0ZmQ0YmYwNDE5NDU3ZTk1Yzk4ZmE4YWRmN2E1YjU5ZDE0MTI5Ng== Original-Lines: 128 Original-NNTP-Posting-Date: 05 Aug 2009 17:34:46 MEST Original-NNTP-Posting-Host: 88.170.236.224 Original-X-Trace: 1249486486 news-1.free.fr 31413 88.170.236.224:45381 Original-X-Complaints-To: abuse@proxad.net Original-Xref: news.stanford.edu gnu.emacs.help:171618 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:66792 Archived-At: "Drew Adams" writes: > I am not a programmer. > I have used emacs for a period of time . > I have read `A Introduction to emacs lisp' and Orelly's Learn Gnu Emacs > 3ed . > > Now I am reading `Emacs Lisp Reference' , I feel it is harder and my > progress is slow. > How to learn elisp ? Because I need to write or modify some functions. > Do I need to read Emacs Lisp Reference wholely ? Yes, but not yet. Since you are not (yet) a programmer, you will need to learn programming, to become one. Study these books, one after the other: Common Lisp: A Gentle Introduction to Symbolic Computation David S. Touretzky http://www-cgi.cs.cmu.edu/afs/cs.cmu.edu/user/dst/www/LispBook/index.html http://www.cs.cmu.edu/~dst/LispBook/ Structure and Interpretation of Computer Programs Harold Abelson & Gerald Jay Sussman, with Julie Sussman http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-4.html http://swiss.csail.mit.edu/classes/6.001/abelson-sussman-lectures/ The first gives you an easy introduction to programming. The seconds gives you good fundamentals to programming. The only drawback is that they don't use emacs lisp for their examples. The first uses Common Lisp, which is quite close to emacs lisp. There are significant technical differences, so you will probably learn some Common Lisp along, but it will also make you understand better emacs lisp, and teach you how to program in lisp. For example, to insert X times a line in a buffer in emacs lisp you would write: (defun happy (n) (dotimes (i n) (insert (format "Happy %d%s birthday!\n" i (case i (0 "th") (1 "st") (2 "nd") (3 "rd") (otherwise "th")))))) In Common Lisp you would write: (defun happy (n) (dotimes (i n) (format t "Happy ~d~:*~[th~;st~;nd~;rd~:;th~] birthday!~%" i))) or you could write it more like in emacs lisp: (defun insert (&rest args) ; there's no buffer, therefore no insert in Common Lisp. (dolist (arg args) (princ arg))) ; we will just princ the arguments to the output. (defun happy (n) (dotimes (i n) (insert (format nil "Happy ~d~a birthday!~%" i (case i (0 "th") (1 "st") (2 "nd") (3 "rd") (otherwise "th")))))) You will have to be aware of the differences, but there is a big core of common principles and operators, so you can easily write code that work the same, or quite similarly, in either lisp. Learning how to program with a Common Lisp book will help you to program in emacs lisp, it's basically the same ability. If you put (require 'cl) in your ~/.emacs, you will load a set of functions and macros like thoses found in Common Lisp. If you install eieio (from cedet.sourceforge.net), and (require 'eieio) in your ~/.emacs, you will even get a clone of CLOS (the Common Lisp Object System), if you want to do OO programming in emacs lisp. The most notable difference between emacs lisp and Common Lisp are that all variable bindings in emacs lisp are dynamic, while Common Lisp uses lexical binding by default, and optionnally (eg for global variables), uses dynamic binding. In Scheme, there is only lexical bindings. As a consequence, there is no closure in emacs lisp (but (require 'cl) provides a simulated lexical binding operator (lexical-let) which allow you to create kind of closures). For SICP, this book uses scheme, another kind of lisp, for its examples. But its teaching goes way beyond the specific programming language, and it is really worth studying if you want to make good programs. (Note that these exercises have been translated in several programming languages, including Common Lisp http://www.codepoetics.com/wiki/index.php?title=Topics:SICP_in_other_languages ) > http://www.emacswiki.org/emacs/LearnEmacsLisp You can also get help from: news:gnu.emacs.help irc://irc.freenode.org/#emacs for emacs specific questions, http://cliki.net/ news:comp.lang.lisp irc://irc.freenode.org/#lisp for Common Lisp specific questions, or general lisp questions (including gentle or sicp). http://www.scheme.org/ news:comp.lang.scheme irc://irc.freenode.org/#scheme for scheme specific questions (including sicp). -- __Pascal Bourguignon__