all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Erik Charlebois <erikcharlebois@gmail.com>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: emacs-devel@gnu.org
Subject: Re: multi-character syntactic entities in syntax tables
Date: Fri, 26 Apr 2013 15:22:22 -0400	[thread overview]
Message-ID: <CAC+abJa-3DsUn0eY-nwcURFCLT=bnV+wy3A=1CDTpKy3=jZ+pw@mail.gmail.com> (raw)
In-Reply-To: <87sj2d86o9.fsf@yandex.ru>

[-- Attachment #1: Type: text/plain, Size: 2456 bytes --]

Off the top of my head, point motion (e.g. forward-word should skip the
entire word, not stop where the syntax class changes from "(" to "w") and
font locking (show-paren-mode should highlight the entire matching words).

Since the matching keyword lengths can be different (begin vs end), my
understanding is I can't just turn them into ((((( and ))) because it
doesn't balance.

Currently I have some hacks for Ruby mode that makes the first characters
of the block keywords have "(" or ")" syntax class. It works fine, aside
from point motion and font locking.



On Fri, Apr 26, 2013 at 2:53 PM, Dmitry Gutov <dgutov@yandex.ru> wrote:

> Erik Charlebois <erikcharlebois@gmail.com> writes:
>
> > One of the items in etc/TODO is:
> >
> > ** Beefed-up syntax-tables.
> > *** recognize multi-character syntactic entities like `begin' and
> > `end'.
> >
> > Lately I'm using languages where this would be quite useful and would
> > be interested in adding support. Before I dive in, are there any
> > strong opinions about how this should be implemented?
> >
> > The approach I was thinking of taking is defining a new syntax
> > character class (let's say, *) which inherits from the previous
> > character (recursively if the previous character is *). The important
> > distinction is that they would not be treated as a new instance of
> > that syntax class, so point movement by syntax class or paren matching
> > would work (e.g. begin would be (****, and would only add 1 level of
> > paren nesting).
> >
> > A mode would use a syntax-propertize-function to tag keywords with
> > appropriate text properties. So something like Ruby:
> >
> > class Foo
> > def Bar
> > if condition
> > ...
> > end
> > end
> > end
>
> ruby-mode code could definitely benefit from something like this.
>
> > would have syntax classes like:
> >
> > (**** www
> > (** www
> > (* wwwwwwwww
> > ...
> > )**
> > )**
> > )**
>
> I don't think using syntax-propertize-function is something the person
> who wrote that TODO entry had in mind, but if we'll use it for that
> purpose, at least in ruby-mode implementing something like a "generic
> parenthesis" class should suffice (which would work similarly to generic
> string and generic comment delimiters), since all non-curly blocks in
> Ruby end the same way.
>
> So, what's the rationale for your, more complex proposal? In what
> context would treating e, g, i and n in "begin" as parenthesis openers
> will be useful?
>

[-- Attachment #2: Type: text/html, Size: 3364 bytes --]

  reply	other threads:[~2013-04-26 19:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-26 17:28 multi-character syntactic entities in syntax tables Erik Charlebois
2013-04-26 18:53 ` Dmitry Gutov
2013-04-26 19:22   ` Erik Charlebois [this message]
2013-04-26 20:57     ` Dmitry Gutov
2013-04-26 19:26 ` Stefan Monnier
2013-04-26 21:37   ` Erik Charlebois
2013-04-27  4:15     ` Stefan Monnier

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='CAC+abJa-3DsUn0eY-nwcURFCLT=bnV+wy3A=1CDTpKy3=jZ+pw@mail.gmail.com' \
    --to=erikcharlebois@gmail.com \
    --cc=dgutov@yandex.ru \
    --cc=emacs-devel@gnu.org \
    /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.