unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 15874@debbugs.gnu.org, Bozhidar Batsov <bozhidar@batsov.com>
Subject: bug#15874: 24.3.50; exit! not properly font-locked in ruby-mode
Date: Fri, 06 Dec 2013 04:44:49 +0200	[thread overview]
Message-ID: <87a9ge7l5q.fsf@yandex.ru> (raw)
In-Reply-To: <jwv8uvzdtb7.fsf-monnier+emacsbugs@gnu.org> (Stefan Monnier's message of "Thu, 05 Dec 2013 14:02:53 -0500")

Stefan Monnier <monnier@iro.umontreal.ca> writes:

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

Two birds with one stone, yes.

> I don't see why we'd need lookbehind.

Not mandatory, just good for performance, AFAICT. Instead of maching all
identifiers that look like methods and then finding out that most of
them don't end with ? or ! anyway, it would be faster to scan the buffer
for ? or !, and then look a bit back and see if the text before such a
character resembles a method name.

> We can use a regexp like "\\(?:\\sw\\|\\s_\\)\\([!?]\\)" and then place
> the syntax-table property on the ? (or !) character.

Yes, something like that.

> 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_:]].

That looks good, but, like you mentioned later, if we had a dedicated
backslash-sequence, it could also transparently handle the EOB case.  I
guess, the question is, would it see much use. `regexp-opt' seems to be
the primary use case to me.

> It's not that big of a deal, tho.  I doubt this would ever appear as
> a noticeable slowdown.

That may be true. 

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

Eh, I guess whenever it sees ? or ! at the end of the identifier, the
parser goes with the assumption that it is a method call, because
otherwise it would be a syntax error.

IOW, we only have to worry about @instance and $global variables.

irb(main):022:0* def a
irb(main):023:1> 42
irb(main):024:1> end
=> nil
irb(main):025:0> a?1:2
SyntaxError: (irb):25: syntax error, unexpected ':', expecting $end
a?1:2
    ^
	from /home/gutov/.rbenv/versions/1.9.3-p429/bin/irb:12:in `<main>'
irb(main):026:0> a = 5
=> 5
irb(main):027:0> a?3:4
SyntaxError: (irb):27: syntax error, unexpected ':', expecting $end
a?3:4
    ^
	from /home/gutov/.rbenv/versions/1.9.3-p429/bin/irb:12:in `<main>'
irb(main):028:0> $abc?
irb(main):029:0* 2
SyntaxError: (irb):29: syntax error, unexpected $end, expecting ':'
	from /home/gutov/.rbenv/versions/1.9.3-p429/bin/irb:12:in `<main>'
irb(main):030:0> $abc = 6
=> 6
irb(main):031:0> $abc?1:2
=> 1





  reply	other threads:[~2013-12-06  2:44 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-12 12:38 bug#15874: 24.3.50; exit! not properly font-locked in ruby-mode Bozhidar Batsov
2013-12-04 18:31 ` Dmitry Gutov
2013-12-04 19:20   ` Stefan Monnier
2013-12-04 22:33     ` Dmitry Gutov
2013-12-04 23:15     ` Dmitry Gutov
2013-12-05  2:50       ` Stefan Monnier
2013-12-05  3:42         ` Dmitry Gutov
2013-12-05 19:02           ` Stefan Monnier
2013-12-06  2:44             ` Dmitry Gutov [this message]
2013-12-06  4:57               ` Stefan Monnier
2013-12-06  4:23             ` Dmitry Gutov
2013-12-05  6:34   ` Kevin Rodgers
2013-12-05 10:58     ` Dmitry Gutov
2013-12-05 14:50       ` Kevin Rodgers
2013-12-05 17:25         ` Dmitry Gutov

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87a9ge7l5q.fsf@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=15874@debbugs.gnu.org \
    --cc=bozhidar@batsov.com \
    --cc=monnier@iro.umontreal.ca \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).