From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Lennart Borgman Newsgroups: gmane.emacs.devel Subject: Re: web-mode.el Date: Thu, 14 Jun 2012 18:54:04 +0200 Message-ID: References: <4FD9F40C.90406@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1339692902 25649 80.91.229.3 (14 Jun 2012 16:55:02 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 14 Jun 2012 16:55:02 +0000 (UTC) Cc: cyd@gnu.org, monnier@iro.umontreal.ca, emacs-devel@gnu.org To: Dmitry Gutov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jun 14 18:54:57 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 1SfDJv-0000z0-Nm for ged-emacs-devel@m.gmane.org; Thu, 14 Jun 2012 18:54:55 +0200 Original-Received: from localhost ([::1]:59739 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SfDJv-0004Gx-Oj for ged-emacs-devel@m.gmane.org; Thu, 14 Jun 2012 12:54:55 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:55018) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SfDJr-0004Gl-T7 for emacs-devel@gnu.org; Thu, 14 Jun 2012 12:54:53 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SfDJm-0000J3-UV for emacs-devel@gnu.org; Thu, 14 Jun 2012 12:54:51 -0400 Original-Received: from mail-lpp01m010-f41.google.com ([209.85.215.41]:34924) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SfDJe-0000DN-Pr; Thu, 14 Jun 2012 12:54:39 -0400 Original-Received: by lahi5 with SMTP id i5so1702850lah.0 for ; Thu, 14 Jun 2012 09:54:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=mqpQ9SN9sgDh0kjaOaBuObQk9IKMjT57BDgFe5yUmoE=; b=wU/7nzz3/BQwDVoKUaOP7MbdqkOHACojB5ArKLxWm2aSeQJJ1VnWzwPbchNuMVkHrO 5YZw2ph0etLW3cqQV2q7U2RhWe1xX/ynUxZeexYUg5tlpcJJtEq6lTP3AIzBHcDUBjod Kxu45YW8uiyg+PtXcpwx7OKdO69ZzcQkiSYTbTTjA21NJw2iRKpqftWC8AeMpKAj3NYs 5z/L7xznVHr0UACKkRZflx++wpIK1R7+ITIJw2HjJbwp8jsX0/glTSMvXobpD3S667Mx PMscw4F+P+JfBoqiyip8AF1t53WcyoFsMMaLFyKgXLmI6gS4JjfTIyRDD6zOz1TrH3N1 /2QQ== Original-Received: by 10.152.104.44 with SMTP id gb12mr2571750lab.29.1339692875043; Thu, 14 Jun 2012 09:54:35 -0700 (PDT) Original-Received: by 10.112.41.99 with HTTP; Thu, 14 Jun 2012 09:54:04 -0700 (PDT) In-Reply-To: <4FD9F40C.90406@yandex.ru> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.215.41 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:150946 Archived-At: On Thu, Jun 14, 2012 at 4:24 PM, Dmitry Gutov wrote: > Stefan Monnier writes: >>> 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. =C2=A0The important and difficult part is to figure what those >> conventions need to be. > > I agree in principle. And since fontification of chunks can already be > done reliably enough (if not with best performance), I think indentation > function conventions would be more important. Shall we start with > collecting cases? I am not sure I agree. The way I have proposed to do it is to change the low level functions reading the buffer so that you can lie to them and say that the chunks in other major modes are just whitespace+line feeds. It would be reliable (I think), but it requires much effort so it still may not be worth it. I took a look at what I had done so far (it was some time ago now). I have not touched the C code. I have only made some changes in mumamo.el towards this goal. As Dmitry says, fontification is rather simple (but you have to be careful to make it fast). Indentation is harder. First of all I have tried to write down the logic to use. I have rewritten that part a few times. Even this was harder then I expected. You can see my current comments here in mumamo-indent-line-function-1 (at line 7915 currently): http://bazaar.launchpad.net/~nxhtml/nxhtml/main/view/head:/util/mumamo.el Second I have moved towards doing indentation the way it should have been done if the changes in the C code were done. I do this by copying the code to a mirror buffer, replacing everything in "other" chunks with whitespace+line feeds. It is easy to get things a bit wrong when you do this of course. I am not sure if the problem you have seen, Dmitry, is because (1) failed to copy correctly, (2) the idea is somehow buggy, or (3) I just did not implement all cases or did not finish implementing them. > So far I have two problems without obvious solutions: > > 1) js-mode uses (widen) at the beginning of js-indent-line, and then call= s > (syntax-ppss). There are several modes for javascript. And of course for html too; nxml-mode is one. Stopping nxml-mode from crossing the chunks boundaries is not easy. >> Of course, tweaking some parts of the C mode might help. =C2=A0E.g. we c= ould >> 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. I have tried to implement something like that in mumamo.el, but I think it is not working correctly anymore. Something might have changed since I did that.