From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Eric M. Ludlam" Newsgroups: gmane.emacs.devel Subject: Re[2]: Multiple major modes Date: Sun, 8 Jul 2007 20:49:41 -0400 Message-ID: <200707090049.l690nf6e027141@projectile.siege-engine.com> References: <466E7A93.3050705@gmail.com> <466E81AA.3030202@gnu.org> <466E9822.2050508@gmail.com> <466EAB9D.9020408@gnu.org> <466EEA71.2070700@gmail.com> <200706122014.l5CKEKV1021902@projectile.siege-engine.com> <200706190209.l5J29Csr010302@projectile.siege-engine.com> <200706251404.l5PE4dgc011720@projectile.siege-engine.com> <200707050144.l651iOeu023173@projectile.siege-engine.com> NNTP-Posting-Host: lo.gmane.org X-Trace: sea.gmane.org 1183942207 23218 80.91.229.12 (9 Jul 2007 00:50:07 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 9 Jul 2007 00:50:07 +0000 (UTC) Cc: jasonr@gnu.org, lennart.borgman@gmail.com, sdl.web@gmail.com, monnier@iro.umontreal.ca, emacs-devel@gnu.org To: rms@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jul 09 02:50:04 2007 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.50) id 1I7hRx-0006Es-VT for ged-emacs-devel@m.gmane.org; Mon, 09 Jul 2007 02:50:02 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1I7hRx-0001gb-Dg for ged-emacs-devel@m.gmane.org; Sun, 08 Jul 2007 20:50:01 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1I7hRs-0001g7-Qa for emacs-devel@gnu.org; Sun, 08 Jul 2007 20:49:56 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1I7hRq-0001fu-Bs for emacs-devel@gnu.org; Sun, 08 Jul 2007 20:49:55 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1I7hRq-0001fm-46 for emacs-devel@gnu.org; Sun, 08 Jul 2007 20:49:54 -0400 Original-Received: from static-71-184-83-10.bstnma.fios.verizon.net ([71.184.83.10] helo=projectile.siege-engine.com) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1I7hRm-0006mb-0J; Sun, 08 Jul 2007 20:49:50 -0400 Original-Received: from projectile.siege-engine.com (localhost.localdomain [127.0.0.1]) by projectile.siege-engine.com (8.12.8/8.12.8) with ESMTP id l690ngYE027145; Sun, 8 Jul 2007 20:49:42 -0400 Original-Received: (from zappo@localhost) by projectile.siege-engine.com (8.12.8/8.12.8/Submit) id l690nf6e027141; Sun, 8 Jul 2007 20:49:41 -0400 In-reply-to: (message from Richard Stallman on Sun, 08 Jul 2007 18:23:49 -0400) X-detected-kernel: Linux 2.4-2.6 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:74483 Archived-At: >>> Richard Stallman seems to think that: > The use syntax of an overloadable function is similar to programs that > call `indent-for-tab-command', or `indent-according-to-mode', but > there is no restriction forcing `according-to-mode' as part of the > function name. > >I understand the similarity, but I see the difference too. >The source code of `indent-according-to-mode' shows that it >calls something that can be set differently by different modes. > >That's why I prefer using a variable. > >However, you didn't show precisely what this feature looks like. >Perhaps I got the wrong idea of the feature. Can you show me >what it looks like? Hi, Here is a use case from semantic, my parsing tool. This is a function that would take a name as found in sources, and split it so that namespaces (if any) and the name are returned. In many languages there is nothing special to do, but in C++, it needs to do something special. Instead of putting c++ code in the first file, it is instead placed in a C specific file that contains many C specific differences. Of course, the doc string talks about C++, but only as an example. I picked this case because it's very short. semantic-analyze.el: -------------------- (define-overload semantic-analyze-split-name (name) "Split a tag NAME into a sequence. Sometimes NAMES are gathered from the parser that are compounded, such as in C++ where foo::bar means: \"The class BAR in the namespace FOO.\" Return the string NAME for no change, or a list if it needs to be split.") (defun semantic-analyze-split-name-default (name) "Don't split up NAME by default." name) -------------------- As you can see, there is no implementation at the initial declaration. In this example, the `-default' is a separate function, because a body could be given to the original that would wrap either the `-default' of a mode specific implementation. semantic-c.el: -------------- (define-mode-local-override semantic-analyze-split-name c-mode (name) "Split up tag names on colon (:) boundaries." (let ((ans (split-string name ":"))) (if (= (length ans) 1) name (delete "" ans)))) -------------- If you use "C-h f semantic-analyze-split-name RET" you get: --------------- semantic-analyze-split-name is a compiled Lisp function in `semantic-analyze.el'. (semantic-analyze-split-name name) This function can be overloaded (see `define-mode-local-override' for details). Split a tag name into a sequence. Sometimes NAMES are gathered from the parser that are compounded, such as in C++ where foo::bar means: "The class BAR in the namespace FOO." Return the string name for no change, or a list if it needs to be split. [back] --------------- which would be improved if the doc for individual overloads could be specified, though I haven't done that yet. Doing so would make it much easier to find the implementation actually being run in a particular case. I hope this helps. Eric -- Eric Ludlam: zappo@gnu.org, eric@siege-engine.com Home: http://www.ludlam.net Siege: www.siege-engine.com Emacs: http://cedet.sourceforge.net GNU: www.gnu.org