From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jeff Clough Newsgroups: gmane.emacs.devel Subject: Re: What is emacs architecture ? Date: Thu, 08 Jul 2010 00:16:10 -0400 Message-ID: <1278562570.16810.20.camel@logrus.localdomain> References: <20100707.150746.549331509773933118.yamato@redhat.com> <87aaq3qpo7.fsf@kslab.red-bean.com> <8739vvxkqr.fsf@escher.home> <8739vvoyak.fsf@kslab.red-bean.com> <87eifek5zm.fsf@uwakimon.sk.tsukuba.ac.jp> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1278562605 31652 80.91.229.12 (8 Jul 2010 04:16:45 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 8 Jul 2010 04:16:45 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jul 08 06:16:44 2010 Return-path: Envelope-to: ged-emacs-devel@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 1OWiXS-0005Qk-DR for ged-emacs-devel@m.gmane.org; Thu, 08 Jul 2010 06:16:42 +0200 Original-Received: from localhost ([127.0.0.1]:50987 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OWiXQ-0004IH-S5 for ged-emacs-devel@m.gmane.org; Thu, 08 Jul 2010 00:16:40 -0400 Original-Received: from [140.186.70.92] (port=49890 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OWiXK-0004I8-KS for emacs-devel@gnu.org; Thu, 08 Jul 2010 00:16:35 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OWiXJ-00033Y-FH for emacs-devel@gnu.org; Thu, 08 Jul 2010 00:16:34 -0400 Original-Received: from hrndva-omtalb.mail.rr.com ([71.74.56.124]:47293) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OWiXJ-000333-Cc for emacs-devel@gnu.org; Thu, 08 Jul 2010 00:16:33 -0400 X-Authority-Analysis: v=1.1 cv=o8sBXTxWt3Y8I13SYZ0pmcTcOViZ+nX/QX6HkgGmvUU= c=1 sm=0 a=A4IO0QmidFMA:10 a=mI6YO6ZdSLUA:10 a=IkcTkHD0fZMA:10 a=wN3dDBks/ChO7xvezkoALQ==:17 a=d6OV3vMiWGEOKQG8lmUA:9 a=DJAJfxdC2qs3WrncRoKmWeedaaAA:4 a=QEXdDO2ut3YA:10 a=wN3dDBks/ChO7xvezkoALQ==:117 X-Cloudmark-Score: 0 X-Originating-IP: 74.70.71.134 Original-Received: from [74.70.71.134] ([74.70.71.134:52044] helo=[192.168.1.101]) by hrndva-oedge01.mail.rr.com (envelope-from ) (ecelerity 2.2.2.39 r()) with ESMTP id 2B/E3-05792-611553C4; Thu, 08 Jul 2010 04:16:31 +0000 In-Reply-To: <87eifek5zm.fsf@uwakimon.sk.tsukuba.ac.jp> X-Mailer: Evolution 2.30.2 (2.30.2-1.fc13) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:126890 Archived-At: I mostly just lurk on the list and putter around in Emacs as a sort of hobby project at this point, but I've made a number of personal modifications to the code and have figured out a thing or two. Here's what I suggest as to learning how Emacs is built at the C level. 1. Most of Emacs isn't even *at* the C level. It's in the Lisp sources. Make darn sure you know Emacs Lisp and have followed a bunch of calls and threaded your way through the Emacs sources to know how that all works. Here, the Emacs Lisp debugger is your friend. Learn how to unconditionally invoke it. Create a function in Lisp which does this, then runs some interesting functions. Step through and watch what happens. 2. Once you get to a function called by Emacs Lisp that is implemented in C, dive into the source for that function and work through it. Emacs is a large, complex project and you will find a lot of pre-processor macros have been defined to make C suitable for it's development. Find the definitions for those macros and "hand expand" them to find out what is truly happening behind the scenes. 3. Even seemingly trivial functions defined in the C sub-strata have a lot of cool stuff. Look at "(point)" as an example. 4. Stay away from running gdb. You don't need to be stepping through code at that level. You need to be understanding things like what cons cells are made of, what a buffer is, how buffer local variables work, etc. That means reading their code, not threading your way through the execution stack to learning how one specific use of these things is handled. 5. Question everything. If you look at the math functions, for instance, you might see that *two* checks are done to find floating point numbers when division occurs. Try to figure out why this happens. 6. Create your own "toy" functions at the C level and expose them to Lisp. These might even be non-toy functions. If you run even the most "minimal" of functions to read a file into a buffer in Emacs, you'll be implicitly invoking more than a dozen calls to other functions. Find a way to not do that and implement it. 7. Ultimately, the best way to learn how something like Emacs works is to hack at it. Make it do something else. Break it. Explore. Find a function like forward-char and go through it and all of the functions it calls until you know what every line of C does to make that command work. That's what I did, anyway, and it seems to work for me. Jeff