From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Wedler, Christoph" Newsgroups: gmane.emacs.devel Subject: RE: antlr-mode.el - need some support by python.el Date: Fri, 13 Feb 2015 10:56:45 +0000 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1423825028 3406 80.91.229.3 (13 Feb 2015 10:57:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 13 Feb 2015 10:57:08 +0000 (UTC) Cc: =?iso-8859-1?Q?Fabi=E1n_E=2EGallina?= , "emacs-devel@gnu.org" To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Feb 13 11:57:02 2015 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 1YMDvh-0001pr-VL for ged-emacs-devel@m.gmane.org; Fri, 13 Feb 2015 11:57:02 +0100 Original-Received: from localhost ([::1]:54475 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YMDvh-0002e4-66 for ged-emacs-devel@m.gmane.org; Fri, 13 Feb 2015 05:57:01 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37933) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YMDvd-0002do-Gh for emacs-devel@gnu.org; Fri, 13 Feb 2015 05:56:58 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YMDvZ-0008Hn-MT for emacs-devel@gnu.org; Fri, 13 Feb 2015 05:56:56 -0500 Original-Received: from smtpgw02.sap-ag.de ([155.56.66.97]:59587 helo=smtpgw.sap-ag.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YMDvZ-0008Cp-Cr for emacs-devel@gnu.org; Fri, 13 Feb 2015 05:56:53 -0500 Thread-Topic: antlr-mode.el - need some support by python.el Thread-Index: AQHQQjTxxsXFZU5LQTeH9ayNQUY/OZzuYG1Q In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.21.40.114] X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 X-Received-From: 155.56.66.97 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:183002 Archived-At: > I'd use prog-indentation-context. OK, I append a patch for prog-mode.el below. >> The values are provided by the outer mode. But the inner mode decides >> what it expects in (that's why I called it SUBMODE-SPECIFIC in >> the "real doc"). > That requires some cross-knowledge of the two modes. It's not ideal, > but I guess it's OK. You are right, it is not ideal. I do not think it requires cross-knowledge= , just some knowledge by the outer mode about the inner (bad for me ;-)) What I deduce from your text is that you do not like to have this variable "polluted" by some sub-mode specific stuff - and I do agree. In the patch below I have now deleted SUBMODE-SPECIFIC. It has the advantage that we could extend the variable with some future generic context info in a compatible manner. Instead, I added a paragraph in the doc string that sub modes can define their own `SUB-extra-indentation-context', which would have the additional advantage that the variable content is documented. >> [...] that would require them to create a temporary buffer for the >> indent calculation. > Not necessarily: the submode can just go to the end of the previous > chunk, compute some state at that position and use that state as initial > context at MIN. ... if scan-lists, mode-specific skip-comments etc are prepared for this. It would also not help me as the previous chunks are not part of the ANTLR grammar buffer (but of the ANTLR code generation code) - I could just fake some context _string_. (Providing the context as a string would be actually the easiest for me.) Christoph diff -c prog-mode.el.\~24.4\~ prog-mode.el *** prog-mode.el.~24.4~ 2014-04-27 19:41:16.000000000 +0000 --- prog-mode.el 2015-02-13 09:19:26.285457000 +0000 *************** *** 41,46 **** --- 41,76 ---- map) "Keymap used for programming modes.") =20 + (defvar prog-indentation-context nil + "Non-nil while indenting lines considered as belonging to a sub mode. + There are languages where part of the code is actually written in + a sub language, e.g., a Yacc/Bison or ANTLR grammar also consists + of plain C code. This variables enables the major mode of the + main language to use the indentation function of the sub language + for lines belonging the code of the sub language. +=20 + When a major mode of such a main language decides to propagate the + indentation of a line/region to the indentation engine of the sub + mode, it is supposed to bind this variable to non-nil around the call. +=20 + The non-nil value looks as follows + ((MIN . MAX) LEFTMOST-COL) +=20 + MIN to MAX is the region consisting of code of the sub mode. + LEFTMOST-COL is the minimum column the indentation engine of the + sub mode should choose (instead of 0). +=20 + It is the task of the calling main mode to (temporary) set the + syntax table and related variables to values suitable for the sub + mode, and to call `syntax-ppss-flush-cache' if necessary. +=20 + If the indentation engine of the sub mode SUB depends on some + global context, it may introduce a variable named + `SUB-extra-indentation-context', which is to be bound like this + variable by the main major mode. For example, cc-mode might + define `c-extra-indentation-context' which is to be bound to a + list of SYNTACTIC-SYMBOL as explained in `c-offsets-alist'.") +=20 (defun prog-indent-sexp (&optional defun) "Indent the expression after point. When interactively called with prefix, indent the enclosing defun Diff finished. Fri Feb 13 10:19:56 2015