From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Vitalie Spinu Newsgroups: gmane.emacs.devel Subject: Re: web-mode.el Date: Fri, 15 Jun 2012 10:34:38 +0200 Organization: EUR Message-ID: <871ulh3rdt.fsf@gmail.com> References: <4FD9313D.70303@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1339749305 27007 80.91.229.3 (15 Jun 2012 08:35:05 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 15 Jun 2012 08:35:05 +0000 (UTC) Cc: emacs-devel@gnu.org, cyd@gnu.org, lennart.borgman@gmail.com, Dmitry Gutov To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jun 15 10:35:03 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SfRzh-0005y8-K1 for ged-emacs-devel@m.gmane.org; Fri, 15 Jun 2012 10:35:01 +0200 Original-Received: from localhost ([::1]:49450 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SfRzh-0001gy-Do for ged-emacs-devel@m.gmane.org; Fri, 15 Jun 2012 04:35:01 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:54824) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SfRze-0001gp-8E for emacs-devel@gnu.org; Fri, 15 Jun 2012 04:34:59 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SfRzY-0001Zj-1U for emacs-devel@gnu.org; Fri, 15 Jun 2012 04:34:57 -0400 Original-Received: from mail-we0-f169.google.com ([74.125.82.169]:56328) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SfRzT-0001Z5-Ro; Fri, 15 Jun 2012 04:34:48 -0400 Original-Received: by wefh52 with SMTP id h52so2468779wef.0 for ; Fri, 15 Jun 2012 01:34:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:organization:references:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=LISfACqUbMWGrjiA/SvgX03OrP4JAnic6SLM3j6VX2A=; b=nX7W0A0dv7EVg642G592V5TvG4azOZvX5gce5PiUrDr/gVwS3rt6dYYgE/Lb65v53v lHv6VMPIYPgzPoyugF1YbY25Dn/X4IkqkVPRnrAaBvEfSB0Bg/lumSfHR/GyezyDTl44 dzrIU1cOEKEHImf7osgtUOe3CcVeFlYdKtRwpClhRukzme/Yt7aMKfC2VV51Kmrk0r7b JZIDi/VjfrDYT4SwGf8+XsWOb6RlfD8UQhW7zpIVK+WPOEnw5v+pYR69ujYvW+8YbgZt D3DMcBV8w31gAupGre4z5e4rLhK5hbNDNWtl3niW3jgD3MaZ74rbNU8myJaKJ+NjbXiK 2FYQ== Original-Received: by 10.180.102.228 with SMTP id fr4mr2452656wib.6.1339749281128; Fri, 15 Jun 2012 01:34:41 -0700 (PDT) Original-Received: from localhost (i108036.upc-i.chello.nl. [62.195.108.36]) by mx.google.com with ESMTPS id k8sm3108536wia.6.2012.06.15.01.34.39 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 15 Jun 2012 01:34:39 -0700 (PDT) In-Reply-To: (Stefan Monnier's message of "Wed, 13 Jun 2012 23:23:54 -0400") User-Agent: Gnus/5.130004 (Ma Gnus v0.4) Emacs/23.3 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 74.125.82.169 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:150958 Archived-At: >> Stefan Monnier >> on Wed, 13 Jun 2012 23:23:54 -0400 wrote: >> I'm also using narrowing during indentation, but some modes (like js) >> use (widen) in indent-line-function. It should be somewhat fixable by > I don't think it's worthwhile trying to make a "multi-major-mode" that > works with any major mode, no matter what wicked thing it does. > So it's OK to impose a few conventions that the major mode needs > to obey. The important and difficult part is to figure what those > conventions need to be. I also think that multi-major-mode is too much work into a wrong direction. Major mode with chunk switching modes is a dead end also. Modes are becoming heavier and more complex, and one can never know reliably what is happening during the initialization. Besides that, this approach is extremely expensive. Mumamo has almost 10000 lines and it doesn't look like it's the end of it. Dave Love wrote his 400 lines multi-mode.el in 2003, which is based on indirect buffers (http://www.loveshack.ukfsn.org/emacs/multi-mode.el). It still needs tweaking, but it's lightening fast and doesn't require mode swapping. It happened that I've started improving it here (https://github.com/vitoshka/litprog) as part of a general literate programing framework project a couple of weeks ago. I bet a working *minor*-web-mode can be written in less than 100 lines only by specifying chunk delimiters regexps and a mode detection function. > Of course, tweaking some parts of the C mode might help. E.g. we could > maybe extend syntax-tables slightly so that chunk boundaries are marked > with a special syntax-table value which then makes forward-comment skip > over "other language" chunks, so that any indentation code which > consistently ignores comments would then work in multi-major-mode. In litprog-mode.el chunk delimiters already marked as comments to avoid issues with parse-partial-sexp (they even have a separate mode). I guess this works well enough for most of the cases. To achieve full generality one would need to mark whole "irrelevant" chunks as comments. For example in js-mode buffer all html, php etc chunks are comments. In html-mode buffer js, php are comments, etc. Dmitry suggested collecting test cases. That would be great for comparing multi modes head to head. Where can I find really difficult ones? Best, Vitalie.