From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.devel Subject: Re: A vision for multiple major modes: some design notes Date: Sun, 24 Apr 2016 01:36:52 +0300 Message-ID: <810ee329-ba23-4ced-773b-a442405d75b8@yandex.ru> References: <20160420194450.GA3457@acm.fritz.box> <05d5bd7e-1cea-4336-a37c-fe6bd6752558@default> <20160421124325.GC1775@acm.fritz.box> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1461451029 10486 80.91.229.3 (23 Apr 2016 22:37:09 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 23 Apr 2016 22:37:09 +0000 (UTC) To: Stefan Monnier , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Apr 24 00:37:03 2016 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 1au6Ag-00032I-LJ for ged-emacs-devel@m.gmane.org; Sun, 24 Apr 2016 00:37:02 +0200 Original-Received: from localhost ([::1]:53662 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1au6Af-0008Tm-Vl for ged-emacs-devel@m.gmane.org; Sat, 23 Apr 2016 18:37:01 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55871) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1au6Ac-0008R7-KR for emacs-devel@gnu.org; Sat, 23 Apr 2016 18:36:59 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1au6AZ-0006dC-DN for emacs-devel@gnu.org; Sat, 23 Apr 2016 18:36:58 -0400 Original-Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:35881) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1au6AZ-0006d1-6G for emacs-devel@gnu.org; Sat, 23 Apr 2016 18:36:55 -0400 Original-Received: by mail-wm0-x242.google.com with SMTP id w143so11870459wmw.3 for ; Sat, 23 Apr 2016 15:36:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=I8R9N9wVct0BR/QE1JMvZY1lqG1O0iZtHx1VXCOEgU4=; b=peAgwePadETaQDgB0PFaLBtISyAjKKed7g28iKMFgbgHn2QsCcqB/B6A5CF15VXQdc +SMICpVt5wwgcZCy3TiONwzMRaYg+kSf69OF2ZSxhiLFuozBeuKVE2NrsVwVIvttlkJK 8Www7q7jstcuMnhKUYl1l0hR6+Kb2sysa9qCn7Gc2zJeIkP2VLqPzvrAzlGneVZng2pY QTw6vtE3Z//LyHC/ArCQFrqVURg3yCZBUkxMZ4oVGSKf3AJMA48BCGzYHPZaYyvexRsN TFoHfYeFARZDM+Z1Z2dEzMS/9JoQk4CS11gjOlnJ1riJxxvVCsKWklabgM+TvQpNWi4L pXLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:subject:to:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=I8R9N9wVct0BR/QE1JMvZY1lqG1O0iZtHx1VXCOEgU4=; b=KJ/RwWTAJ+Y+utKeHZleG42LhCpMpOuYJFS+O37qU9K0wDyV8529qHQ6NB5wHWjugZ rrhLqo658om1Io8eh7QoLBmbYztSGOhAyUN+rjun2jJffP9ZW6HwlVvdNzwW9rmZrg0z 8YQTDd9YXHYVZvyisN2mWkvUgGpuEo5hfX3GutARZ81lgW3mXg2cgJFTwRKaw40uYlfq fC3JNOJtIk4TTAfO5vGBYUI3DfOE/a8FmfZl+3CXSyMIdx6JIsoUJoab/hDyOBqhDTsl 4QR8iuAXc12XJ5vqsJ3DQpJja0dFVvSvEExLD+B3QwV8kSwuBv8yT1uAHb8Y/15efI27 IPlw== X-Gm-Message-State: AOPr4FWds7cydAjCPvOQdcMcyoEtLCv7qviIexsCwPF/BSRgGqEOOSANxaurJJXyJgTADw== X-Received: by 10.28.126.145 with SMTP id z139mr4111867wmc.81.1461451014294; Sat, 23 Apr 2016 15:36:54 -0700 (PDT) Original-Received: from [192.168.1.2] ([185.105.175.24]) by smtp.googlemail.com with ESMTPSA id k133sm10465025wmg.7.2016.04.23.15.36.52 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 23 Apr 2016 15:36:53 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.0 In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::242 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.devel:203233 Archived-At: On 04/21/2016 05:24 PM, Stefan Monnier wrote: > I haven't kept up with this discussion, but I think it'd worthwhile > taking a look at what things like SublimeText do for syntax > highlighting, because it's a lot more powerful than what font-lock does > (IOW it lets you define contexts and is hence closer to a parser whereas > font-lock is closer to a lexer), and it might be an interesting starting > point for multiple major modes. Indeed. If anyone's interested, here's some documentation: https://www.sublimetext.com/docs/3/syntax.html Apparently, Sublime, TextMate, Atom and even Vim all use this or similar approaches. If it were somehow adopted for Emacs (plenty of details would need to be worked out), it would allow describing more complex grammars, and e.g. support a related Ruby feature that I'm having difficulty implementing right now. Further, if it provides a different mechanism of syntactic parsing, it could be an alternative to using islands to make parse-partial-sexp skip over "foreign" regions. Although, unless we're going to change how we write indentation code, we'd still need to be able to compute the current paren nesting. Ultimately, the new way of defining a grammar could also be a way to define and apply "island" boundaries automatically, without the need for third-party code. Where it's less likely to help, though, is with being able to combine and reuse settings and code from multiple major modes in one file. For anything like that to happen, the syntax definitions would have to be using a format that's highly composable, at least. I'm not sure I'm seeing that in any of the current grammars in the aforementioned editors. And the current way to combine the functionality from different languages is to call different major mode functions and switch between sets of buffer-local variables. Not sure what's the alternative for that.