all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: Alan Mackenzie <acm@muc.de>
Cc: "Vitalie Spinu" <spinuvit@gmail.com>,
	"Andreas Röhler" <andreas.roehler@online.de>,
	emacs-devel@gnu.org, "Stefan Monnier" <monnier@iro.umontreal.ca>,
	"Eli Zaretskii" <eliz@gnu.org>,
	"Drew Adams" <drew.adams@oracle.com>
Subject: Re: A vision for multiple major modes [was: Re: [Emacs-diffs] widen-limits c331b66:]
Date: Wed, 6 Apr 2016 01:52:23 +0300	[thread overview]
Message-ID: <f3ede4b8-9c73-9ae3-376e-9fe8dd17a6d4@yandex.ru> (raw)
In-Reply-To: <20160405162928.GD3463@acm.fritz.box>

Hi Alan,

On 04/05/2016 07:29 PM, Alan Mackenzie wrote:

>> As one option, yes. Let's call it option A, and it entails renumerating
>> buffer positions to avoid gaps.
>
> I'm solidly against using alternative buffer positions.  The unforeseen
> side effects we'd have to cope with would be excessive.  The machinery
> we'd have to set up to convert from "real" offsets to "no gaps" offsets
> would be horrendous.

That's my expectation, too.

> There's no reason forward-char shouldn't jump to
> the next island in a chain without renumbering buffer positions.
> (Assuming `restrict-to-island' has been bound to non-nil by the super
> mode.)

s/shouldn't/couldn't; I'm not sure it should, actually. forward-char 
doesn't normally skip over syntactic whitespace.

> When the key variable `restrict-to-island' is bound to non-nil, things
> like search-forward would skip over islands.  Otherwise it would see the
> insides of islands.  The latter would be what a user doing C-s would
> normally want to happen.

Maybe seeing inside islands is not that terrible. Good code should check 
syntax-ppss anyway, even if it finds a match inside a foreign island.

> parse-partial-sexp would always
> save its state on encountering the start of an island, and restore it at
> the end of the island.

Sure, OK. Or it could just treat the foreign islands as comments, and 
avoid creating a stack of states. Whichever way is easier to implement.

> For the island itself, it would set the state to
> that at the end of the previous island in the chain, or to "nil".

Are you thinking of syntax-ppss instead? The return value of 
parse-partial-sexp must has to depend on where is the start position.

Although if it uses a stack of states internally, it will be easier for 
syntax-ppss to work with (syntax-ppss would be able to reuse cache 
points within islands foreign to the current one).

> I think thinking of it as "changing the value of a variable" is a clumsy
> way to regard it.  "Accessing the correct binding for the current buffer
> position" is more how I would describe it.

Any way we call it now will essentially be a post factum rationalization 
if a programmer is surprised by the behavior. I'm describing the 
behavior. Maybe it's not too bad, IDK.

>>> What sort of variables are you thinking about here?  [ Some time later:]
>>> Could it be that it might be better to have "island chain local"
>>> variables rather than merely "island local" ones?
>
>> mmm-mode has both kinds.
>
> Maybe, but having two extra kinds of locals is more than twice as
> complicated as only having one.

"island chain local" variables are used a lot more often than the 
"island local" ones, in mmm-mode.

> I think "the above concern" was about the lack of newlines in the three
> ruby lines of the example, and the difficulties this would cause
> indentation.  One thing we could do is to make an island syntactically
> equivalent to a newline for the enclosing code.  Maybe.

Yes, it doesn't sounds like a natural solution. Adding a newline in the 
middle of a line might change the meaning of an expression, or at least 
throw off some heuristics we're using in indentation code.

> But we'd surely be happy enough with
>
> <% if foo %>
> <%     = bar(boo) %>
> <% end %>

Not really, no. That's just not how ERB is traditionally formatted. And 
see below (note how the HTML tags, which belong to the superior mode, 
are indented an extra level when inside <% if ... %>...<% end %>).

EJS and JSP are also formatted similarly.

> As a matter of interest, is it really likely that users will type in
> embedded ruby code with <%...%> delimiters around each line, rather than
> one pair around, say, a function or an entire program?

The latter would be an exception. Here's a real-life ERB example:

https://github.com/swanson/stringer/blob/master/app/views/archive.erb

>> - Code complexity: new code paths that might be exercised not very often
>> in the future. Hence, they could be prone to breakage. A dedicated test
>> suite would help with that, though.
>
> If the abstraction we're talking about is sound, then the code complexity
> will be manageable.  People cope with buffer local variables, people cope
> with the regexp engine searching for syntactic things.

Yes, a sound abstraction is key.



  reply	other threads:[~2016-04-05 22:52 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20160322022539.16038.77264@vcs.savannah.gnu.org>
     [not found] ` <E1aiC0q-0004DL-40@vcs.savannah.gnu.org>
2016-03-22 12:08   ` [Emacs-diffs] widen-limits c331b66: Implement buffer-widen-limits functionality Stefan Monnier
2016-03-22 19:44     ` Vitalie Spinu
2016-03-22 19:56       ` Drew Adams
2016-03-22 22:42         ` Vitalie Spinu
2016-03-23  0:44           ` Drew Adams
2016-03-23  7:16             ` Andreas Röhler
2016-03-23 11:58               ` Vitalie Spinu
2016-03-23 13:02                 ` Andreas Röhler
2016-03-23 14:17                   ` Vitalie Spinu
2016-03-23 15:34                     ` Eli Zaretskii
2016-03-23 17:24                       ` Andreas Röhler
2016-03-23 17:55                         ` Eli Zaretskii
2016-03-23 18:53                           ` Andreas Röhler
2016-03-23 21:57                             ` Drew Adams
2016-03-23 22:13                               ` Vitalie Spinu
2016-03-23 23:03                                 ` Drew Adams
2016-03-24  3:38                                 ` Eli Zaretskii
2016-03-24 12:24                                   ` Dmitry Gutov
2016-03-24 15:56                                     ` Eli Zaretskii
2016-03-24 18:55                                       ` Removing prog-indentation-context (was: [Emacs-diffs] widen-limits c331b66: Implement buffer-widen-limits functionality) Stefan Monnier
2016-03-25  0:53                                         ` Removing prog-indentation-context Dmitry Gutov
2016-03-25  1:29                                           ` Dmitry Gutov
2016-03-25  2:09                                           ` Stefan Monnier
2016-03-25 11:38                                             ` Dmitry Gutov
2016-03-26 22:29                                               ` John Wiegley
2016-03-28  1:03                                                 ` Dmitry Gutov
2016-03-25 15:45                                           ` Vitalie Spinu
2016-03-28 21:37                                             ` Dmitry Gutov
2016-03-28 22:08                                               ` Stefan Monnier
2016-03-28 22:55                                                 ` Dmitry Gutov
2016-03-28 23:24                                                   ` Stefan Monnier
2016-03-28  1:03                                       ` [Emacs-diffs] widen-limits c331b66: Implement buffer-widen-limits functionality Dmitry Gutov
2016-03-24  3:37                               ` Eli Zaretskii
2016-03-23 17:14                     ` Andreas Röhler
2016-03-24  0:03                       ` Vitalie Spinu
2016-03-24  0:37                         ` Drew Adams
2016-03-24  2:36                           ` Vitalie Spinu
2016-03-24 13:53                             ` Drew Adams
2016-03-24 13:57                               ` Dmitry Gutov
2016-03-24 14:31                                 ` Drew Adams
2016-03-24 14:56                                   ` Stefan Monnier
2016-03-24 15:13                                     ` Drew Adams
2016-03-24 15:20                                       ` Stefan Monnier
2016-03-24  7:00                         ` Andreas Röhler
2016-03-23 14:29                 ` Drew Adams
2016-03-23 21:16                 ` A vision for multiple major modes [was: Re: [Emacs-diffs] widen-limits c331b66:] Alan Mackenzie
2016-03-23 21:58                   ` Vitalie Spinu
2016-03-24 17:44                     ` Alan Mackenzie
2016-03-24 20:43                       ` Vitalie Spinu
2016-03-23 22:34                   ` Dmitry Gutov
2016-03-24 18:38                     ` Alan Mackenzie
2016-03-24 20:22                       ` Vitalie Spinu
2016-03-25  0:11                       ` Dmitry Gutov
2016-03-27 12:09                         ` Alan Mackenzie
2016-03-27 22:59                           ` Dmitry Gutov
2016-03-29  0:07                             ` Alan Mackenzie
2016-04-01  1:15                               ` Dmitry Gutov
2016-04-05 16:29                                 ` Alan Mackenzie
2016-04-05 22:52                                   ` Dmitry Gutov [this message]
2016-04-18 21:32                                     ` Alan Mackenzie
2016-03-28 13:00                       ` Filipp Gunbin
2016-03-25 18:20                   ` Phillip Lord

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=f3ede4b8-9c73-9ae3-376e-9fe8dd17a6d4@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=acm@muc.de \
    --cc=andreas.roehler@online.de \
    --cc=drew.adams@oracle.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=spinuvit@gmail.com \
    /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.