From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: antlr-mode.el - need some support by python.el Date: Tue, 09 Jun 2015 11:58:46 -0400 Message-ID: References: <54F4A62F.3040403@yandex.ru> <54F4BA93.4000801@yandex.ru> <54F73EE0.9070306@yandex.ru> <5571E070.9050905@yandex.ru> <5575BCB3.4070904@yandex.ru> <55760A1D.5080908@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1433865616 1965 80.91.229.3 (9 Jun 2015 16:00:16 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 9 Jun 2015 16:00:16 +0000 (UTC) Cc: "=?windows-1252?Q?Fabi=E1n?= E.Gallina" , "emacs-devel@gnu.org" , Dmitry Gutov To: "Wedler\, Christoph" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jun 09 18:00:06 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 1Z2LwZ-0008HL-TB for ged-emacs-devel@m.gmane.org; Tue, 09 Jun 2015 18:00:04 +0200 Original-Received: from localhost ([::1]:35883 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2LwZ-0003xT-Ag for ged-emacs-devel@m.gmane.org; Tue, 09 Jun 2015 12:00:03 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40860) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2Lvo-0003Cr-BV for emacs-devel@gnu.org; Tue, 09 Jun 2015 11:59:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z2Lvj-0001cd-1K for emacs-devel@gnu.org; Tue, 09 Jun 2015 11:59:16 -0400 Original-Received: from mercure.iro.umontreal.ca ([132.204.24.67]:43675) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2Lvi-0001bz-QS for emacs-devel@gnu.org; Tue, 09 Jun 2015 11:59:10 -0400 Original-Received: from hidalgo.iro.umontreal.ca (hidalgo.iro.umontreal.ca [132.204.27.50]) by mercure.iro.umontreal.ca (Postfix) with ESMTP id CCD1485FD0; Tue, 9 Jun 2015 11:59:09 -0400 (EDT) Original-Received: from lechon.iro.umontreal.ca (lechon.iro.umontreal.ca [132.204.27.242]) by hidalgo.iro.umontreal.ca (Postfix) with ESMTP id 580591E5B8A; Tue, 9 Jun 2015 11:58:46 -0400 (EDT) Original-Received: by lechon.iro.umontreal.ca (Postfix, from userid 20848) id 2B603B416C; Tue, 9 Jun 2015 11:58:46 -0400 (EDT) In-Reply-To: (Christoph Wedler's message of "Tue, 9 Jun 2015 09:07:08 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-DIRO-MailScanner-Information: Please contact the ISP for more information X-DIRO-MailScanner: Found to be clean X-DIRO-MailScanner-SpamCheck: n'est pas un polluriel, SpamAssassin (score=-2.82, requis 5, autolearn=not spam, ALL_TRUSTED -2.82, MC_TSTLAST 0.00) X-DIRO-MailScanner-From: monnier@iro.umontreal.ca X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 132.204.24.67 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:187128 Archived-At: Looks good to me, please install, Stefan >>>>> "Wedler," == Wedler, Christoph writes: > Here as now a new version - changes to previous one: > - fetch/rebase this morning > - mention text-properties (good idea) and typical use cases in the > docstring of `prog-indentation-context' > - prog-widen: no widen for narrow-to-region case, docstring > "should"->"can" (you are right, "should" was meant for "make it > respect the value `prog-indentation-context'" > a1bd75f57b6d2c726a9c214536da9b63c9c67672 HEAD master > Author: Christoph Wedler > Date: Wed Jun 3 13:54:31 2015 +0000 > Some generic support for multi-mode indentation. > 2 files changed, 73 insertions(+) > ChangeLog.2 | 7 +++++ > lisp/progmodes/prog-mode.el | 66 +++++++++++++++++++++++++++++++++++++++++++++ > Modified ChangeLog.2 > diff --git a/ChangeLog.2 b/ChangeLog.2 > index 4d59b8f..22c4684 100644 > --- a/ChangeLog.2 > +++ b/ChangeLog.2 > @@ -1,3 +1,10 @@ > +2015-06-09 Christoph Wedler > + > + Some generic support for multi-mode indentation. > + * lisp/progmodes/prog-mode.el (prog-indentation-context): New > + variable. > + (prog-first-column, prog-widen): New convenience functions. > + > 2015-06-06 Paul Eggert > Merge from gnulib > Modified lisp/progmodes/prog-mode.el > diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el > index 0d9fabd..cb8aaad 100644 > --- a/lisp/progmodes/prog-mode.el > +++ b/lisp/progmodes/prog-mode.el > @@ -48,6 +48,51 @@ > map) > "Keymap used for programming modes.") > +(defvar prog-indentation-context nil > + "Non-nil while indenting embedded code chunks. > +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 variable enables the major mode of the > +main language to use the indentation engine of the sub mode for > +lines in code chunks written in the sub language. > + > +When a major mode of such a main language decides to delegate 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. > + > +The non-nil value looks as follows > + \(FIRST-COLUMN (START . END) PREVIOUS-CHUNKS) > + > +FIRST-COLUMN is the column the indentation engine of the sub mode > +should usually choose for top-level language constructs inside > +the code chunk (instead of 0). > + > +START to END is the region of the code chunk. See function > +`prog-widen' for additional info. > + > +PREVIOUS-CHUNKS, if non-nil, provides the indentation engine of > +the sub mode with the virtual context of the code chunk. Valid > +values are: > + > + - A string containing code which the indentation engine can > + consider as standing in front of the code chunk. To cache the > + string's calculated syntactic information for repeated calls > + with the same string, it is valid and expected for the inner > + mode to add text-properties to the string. > + > + A typical use case is for grammars with code chunks which are > + to be indented like function bodies - the string would contain > + a corresponding function header. > + > + - A function called with the start position of the current > + chunk. It will return either the region of the previous chunk > + as \(PREV-START . PREV-END) or nil if there is no further > + previous chunk. > + > + A typical use case are literate programming sources - the > + function would successively return the code chunks of the > + previous macro definitions for the same name.") > + > (defun prog-indent-sexp (&optional defun) > "Indent the expression after point. > When interactively called with prefix, indent the enclosing defun > @@ -61,6 +106,27 @@ instead." > (end (progn (forward-sexp 1) (point)))) > (indent-region start end nil)))) > +(defun prog-first-column () > + "Return the indentation column normally used for top-level constructs." > + (or (car prog-indentation-context) 0)) > + > +(defun prog-widen () > + "Remove restrictions (narrowing) from current code chunk or buffer. > +This function can be used instead of `widen' in any function used > +by the indentation engine to make it respect the value > +`prog-indentation-context'. > + > +This function (like 'widen') is useful inside a > +`save-restriction' to make the indentation correctly work when > +narrowing is in effect." > + (let ((chunk (cadr prog-indentation-context))) > + (if chunk > + ;; no widen necessary here, as narrow-to-region changes (not > + ;; just narrows) existing restrictions > + (narrow-to-region (car chunk) (or (cdr chunk) (point-max))) > + (widen)))) > + > + > (defvar-local prettify-symbols-alist nil > "Alist of symbol prettifications. > Each element looks like (SYMBOL . CHARACTER), where the symbol