all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: "Wedler\, Christoph" <christoph.wedler@sap.com>
Cc: "Fabián E.Gallina" <fabian@anue.biz>,
	"emacs-devel@gnu.org" <emacs-devel@gnu.org>
Subject: Re: antlr-mode.el - need some support by python.el
Date: Fri, 13 Feb 2015 14:40:45 -0500	[thread overview]
Message-ID: <jwvzj8h62gh.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <F9C2521BBF380A4A97379009991555E685B01C9F@DEWDFEMB17C.global.corp.sap> (Christoph Wedler's message of "Fri, 13 Feb 2015 10:56:45 +0000")

> OK, I append a patch for prog-mode.el below.

Thanks, see comments below.

>> 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 ;-))

That's right.

> 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.

Well, I don't mind about having the info in this particular place, I'm
just worried about needing such knowledge, but indeed in your case you
probably do have that knowledge (ANTLR does specify that the embedded
C code should be a sequence of statements rather than a sequence of
declarations, say).

> 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.

Since this is a specific to a particular submode and both the inner-mode
and the outer-mode will need to agree on it, there's no need to document
it in the generic part of the interface.

>>> [...] 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.

That's the responsibility of the sub-mode.

> It would also not help me

Indeed, in your case, there's no such "previous chunk" in the current buffer.
I was thinking of other multi-mode cases such as literate programming or
HTML+Javascript.

> 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.)

Hmm.. you mean you'd specify the c-extra-indentation-context as
a "pseudo previous chunk of code"?  That's a nice idea, in that it would
not encode specific knowledge about CC-mode, only specific knowledge
about the C language, so it'd be fairly generic.  So maybe
prog-indentation-context could come with a PREVIOUS value which could
either be a string (so the indentation should pretend that the code was
preceded by this string) or some other value (e.g. a function, or a list
of buffer positions) which gives access to the previous chunks.

> + When a major mode of such a main language decides to propagate the
                                                         ^^^^^^^^^
                                                         delegate

> + 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
> +    ((MIN . MAX) LEFTMOST-COL)
> +
> + 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).

I think (BEG . END) would better match the names we use in other
contexts (on a naive/superficial reading, I assumed MIN/MAX were column
positions).

> + It is the task of the calling main mode to (temporary) set the
                                                ^^^^^^^^^
                                                temporarily

-- Stefan



  reply	other threads:[~2015-02-13 19:40 UTC|newest]

Thread overview: 79+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-16 19:50 antlr-mode.el - need some support by python.el Wedler, Christoph
2015-01-16 23:37 ` Stefan Monnier
2015-02-05 11:39   ` Wedler, Christoph
2015-02-05 14:27     ` Stefan Monnier
2015-02-06 15:14       ` Wedler, Christoph
2015-02-06 17:47         ` Stefan Monnier
2015-02-13 10:56           ` Wedler, Christoph
2015-02-13 19:40             ` Stefan Monnier [this message]
2015-02-16 14:38               ` Wedler, Christoph
2015-02-16 19:23                 ` Stefan Monnier
2015-02-17 10:55                   ` Wedler, Christoph
2015-02-18  0:00                     ` Stefan Monnier
2015-02-18 14:27                       ` Wedler, Christoph
2015-02-18  3:39                 ` Dmitry Gutov
2015-02-18  5:48                   ` Stefan Monnier
2015-02-18 14:13                     ` Wedler, Christoph
2015-02-18 15:13                     ` Dmitry Gutov
2015-02-18 15:41                       ` Wedler, Christoph
2015-02-18 17:56                       ` Stefan Monnier
2015-02-19  2:43                         ` Dmitry Gutov
2015-02-19  3:20                           ` Stefan Monnier
2015-02-19  3:30                             ` Dmitry Gutov
2015-02-19 13:18                               ` Stefan Monnier
2015-02-21 22:14                                 ` Dmitry Gutov
2015-02-25 11:05                                   ` Wedler, Christoph
2015-03-01 17:04                                   ` Stefan Monnier
2015-03-01 22:16                                     ` Dmitry Gutov
2015-03-02  5:23                                       ` Stefan Monnier
2015-03-02 15:08                                         ` Dmitry Gutov
2015-03-02 16:48                                           ` Stefan Monnier
2015-03-02 18:04                                             ` Dmitry Gutov
2015-03-02 18:51                                               ` Stefan Monnier
2015-03-02 19:31                                                 ` Dmitry Gutov
2015-03-03 16:32                                                   ` Stefan Monnier
2015-03-04 16:53                                                     ` Wedler, Christoph
2015-03-04 17:20                                                       ` Dmitry Gutov
2015-03-05  9:46                                                         ` Wedler, Christoph
2015-03-05 12:29                                                           ` Dmitry Gutov
2015-03-05 12:43                                                             ` Dmitry Gutov
2015-04-02 14:10                                                         ` Wedler, Christoph
2015-04-07 17:49                                                           ` Stefan Monnier
2015-04-09 14:07                                                             ` Wedler, Christoph
2015-04-09 18:13                                                               ` Stefan Monnier
2015-06-03 14:14                                                                 ` Wedler, Christoph
2015-06-03 15:31                                                                   ` Stefan Monnier
2015-06-05 14:17                                                                     ` Wedler, Christoph
2015-06-05 17:46                                                                       ` Dmitry Gutov
2015-06-08  9:12                                                                         ` Wedler, Christoph
2015-06-08 13:26                                                                           ` Stefan Monnier
2015-06-08 16:02                                                                             ` Dmitry Gutov
2015-06-08 20:50                                                                               ` Stefan Monnier
2015-06-08 21:33                                                                                 ` Dmitry Gutov
2015-06-09  9:07                                                                                   ` Wedler, Christoph
2015-06-09 15:58                                                                                     ` Stefan Monnier
2015-06-09 19:05                                                                                       ` Wedler, Christoph
2015-06-15 11:02                                                                           ` Dmitry Gutov
2015-06-08 13:18                                                                       ` Stefan Monnier
2015-03-04 17:37                                                     ` Dmitry Gutov
2015-03-04 22:26                                                       ` Stefan Monnier
2015-03-04 22:59                                                         ` Dmitry Gutov
2015-03-10  1:16                                                           ` Stefan Monnier
2015-03-21 15:30                                                             ` Dmitry Gutov
2015-03-21 17:08                                                               ` Stefan Monnier
2015-03-21 23:41                                                                 ` Dmitry Gutov
2015-03-22 13:54                                                                   ` Stefan Monnier
2015-03-22 19:31                                                                     ` Dmitry Gutov
2015-03-22 21:59                                                                       ` Stefan Monnier
2015-03-23 14:03                                                                         ` Dmitry Gutov
2015-03-23 19:25                                                                           ` Stefan Monnier
2015-03-04 16:29                                                   ` Wedler, Christoph
2015-03-04 17:16                                                     ` Dmitry Gutov
2015-03-01 22:25                                     ` Dmitry Gutov
2015-02-18 12:22                   ` Wedler, Christoph
2015-02-18 15:29                     ` Dmitry Gutov
2015-02-18 16:10                       ` Wedler, Christoph
2015-02-18 22:55                         ` Dmitry Gutov
2015-02-25 11:16                           ` Wedler, Christoph
2015-02-18  3:15               ` Dmitry Gutov
2015-02-22  7:52 ` Andreas Röhler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvzj8h62gh.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=christoph.wedler@sap.com \
    --cc=emacs-devel@gnu.org \
    --cc=fabian@anue.biz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.