GNU bug report logs - #15874
24.3.50; exit! not properly font-locked in ruby-mode

Previous Next

Package: emacs;

Reported by: Bozhidar Batsov <bozhidar <at> batsov.com>

Date: Tue, 12 Nov 2013 12:40:01 UTC

Severity: minor

Found in version 24.3.50

Fixed in version 24.4

Done: Dmitry Gutov <dgutov <at> yandex.ru>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 15874 <at> debbugs.gnu.org, Bozhidar Batsov <bozhidar <at> batsov.com>
Subject: bug#15874: 24.3.50; exit! not properly font-locked in ruby-mode
Date: Thu, 05 Dec 2013 14:02:53 -0500
>> Maybe a good way to handle them is via syntax-propertize,
> Huh yes, that's an approach I haven't considered.

The advantage is that it would also fix the sexp-movement operations.

> But it seems more performance-intensive than the other options, at
> least as long as Emacs regexps don't support lookbehind.

I don't see why we'd need lookbehind.
We can use a regexp like "\\(?:\\sw\\|\\s_\\)\\([!?]\\)" and then place
the syntax-table property on the ? (or !) character.

> Say, why don't we have a "non-symbol" matcher?

I'd rather do something a bit more generic, then, like a \\S which can
take a set of syntaxes to exclude.  Or maybe extend the [:foo:]
character classes to allow [:sw:], [:s_:], etc... so we could do
[^[:sw:][:s_:]].

> I would think that in many cases the regexp engine performs
> unnecessary work when it sees "\\_<" or "\\_>" because we often know
> in advance that the character we've already matched, or will have to
> match next, is a symbol constituent. But the engine has to check.

It's not that big of a deal, tho.  I doubt this would ever appear as
a noticeable slowdown.  And with [^[:sw:][:s_:]] you'd have the extra
work of having to handle the EOB case, so you'd have
\(\'\|[^[:sw:][:s_:]]). 

>> then, especially if we can come up with a good regexp that
>> distinguishes "method name" from "local variable name"?
> Not really.  References to local variables, unlike instance and global ones,
> are indistinguishable from method calls if we judge only by name.

But you said that ! and ? are only allowed in method names.  So somehow
Ruby's parser/lexer distinguishes the two cases.  Would a reference to
a variable "foo?" simply always be parsed as "a reference to variable
foo?"  which would later trigger an error because there's no such
variable (because there can't be any such variable)?


        Stefan




This bug report was last modified 11 years and 165 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.