* ruby-mode interpolated quotes error
@ 2014-05-02 21:42 Andrew Pennebaker
2014-05-02 23:13 ` Bob Proulx
2014-05-03 1:32 ` Stefan Monnier
0 siblings, 2 replies; 5+ messages in thread
From: Andrew Pennebaker @ 2014-05-02 21:42 UTC (permalink / raw)
To: Emacs Help
Sometimes ruby-mode incorrectly highlights the double quotes containing an
interpolated string.
Screenshot:
http://i.imgur.com/SEyMKZ4.png
Specifically, the initial double quote on line 46 should be colored yellow,
like the end double quote, and the single quoted string above.
Anyone else experience this?
System:
$ specs emacs brew os
Specs:
specs 0.8
https://github.com/mcandre/specs#readme
emacs --version
GNU Emacs 24.3.1
Copyright (C) 2013 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.
brew --version
0.9.5
system_profiler SPSoftwareDataType | grep 'System Version'
System Version: OS X 10.9.2 (13C1021)
--
Cheers,
Andrew Pennebaker
www.yellosoft.us
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: ruby-mode interpolated quotes error
2014-05-02 21:42 ruby-mode interpolated quotes error Andrew Pennebaker
@ 2014-05-02 23:13 ` Bob Proulx
2014-05-02 23:55 ` Bob Proulx
2014-05-03 1:32 ` Stefan Monnier
1 sibling, 1 reply; 5+ messages in thread
From: Bob Proulx @ 2014-05-02 23:13 UTC (permalink / raw)
To: Emacs Help
Andrew Pennebaker wrote:
> Sometimes ruby-mode incorrectly highlights the double quotes containing an
> interpolated string.
>
> Screenshot:
>
> http://i.imgur.com/SEyMKZ4.png
Thank you for sending a URL to the image rather than the image
attached! Much smaller and much easier on the mailing lists!
> Specifically, the initial double quote on line 46 should be colored yellow,
> like the end double quote, and the single quoted string above.
>
> Anyone else experience this?
I have seen something similar but slightly different. I don't have a
solution. It hasn't been enough of an itch for me to dig into it.
But I will add that it is related to the parsing of the '#{...}' in
the string.
"abc#{def}ghi"
In the above the 'c' character before the '#' is in the incorrect
face. This is what I see.
"ab quoted string face
c#{def} variable face
ghi" quoted string face
The #{...} construct causes the character immediately preceding the
'#' to be colored in the variable face color.
I notice that you have posted a slightly different set of colors. I
assume this is simply differences in color maps or different themes
between our displays.
I am using Debian Unstable emacs 24.3.1. Everything is stock. I see
the problem I described when invoked as "emacs -Q".
Bob
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: ruby-mode interpolated quotes error
2014-05-02 23:13 ` Bob Proulx
@ 2014-05-02 23:55 ` Bob Proulx
0 siblings, 0 replies; 5+ messages in thread
From: Bob Proulx @ 2014-05-02 23:55 UTC (permalink / raw)
To: help-gnu-emacs
Bob Proulx wrote:
> Andrew Pennebaker wrote:
> > Specifically, the initial double quote on line 46 should be colored yellow,
> > like the end double quote, and the single quoted string above.
> >
> > Anyone else experience this?
>
> The #{...} construct causes the character immediately preceding the
> '#' to be colored in the variable face color.
This motivated me to poke into the problem a little. The problem
appears to be ruby-match-expression-expansion which is looking for any
character not a backslash before the #{...}.
(defun ruby-match-expression-expansion (limit)
(when (re-search-forward "[^\\]\\(\\\\\\\\\\)*\\(#\\({[^}\n\\\\]*\\(\\\\.[^}\n\\\\]*\\)*}\\|\\(\\$\\|@\\|@@\\)\\(\\w\\|_\\)+\\)\\)" limit 'move)
(or (ruby-in-ppss-context-p 'string)
(ruby-match-expression-expansion limit))))
It is trying to avoid matching a sub-expression in this case. Two
test cases would be:
"abc#{def}ghi"
"abc\#{def}ghi"
In the first #{def} is a subexpression. In the second the # is
escaped and is not evaluated.
So what is needed is a way to match a # that is not preceded by a
backslash but not to include the non-backslash character in the
expression. Or another method to accomplish the task. I am only an
infrequent elisp hacker and am unfamiliar with the idioms needed to
avoid this problem.
Anyone else on the list know a good idiom to use? It needs to match
but ignore the leading context. (This is the opposite of the "trailing
context" match feature provided by lex.)
As a quick hack to alleviate your particular symptom, while creating a
more rare different one, you could remove the [^\\] part from the
front of the expression. That would no longer match the non-backslash
in front of the #{...} construct and your case would work correctly.
It then would miscolor the new case "abc\#{def}ghi" which is not a
sub-expression due to the escape but would still be colored as if it
were. That might be a less annoying problem.
Bob
--- ruby-mode.el.orig 2014-05-02 17:29:15.312413975 -0600
+++ ruby-mode.el 2014-05-02 17:27:31.935234984 -0600
@@ -1578,7 +1578,7 @@
"Additional expressions to highlight in Ruby mode.")
(defun ruby-match-expression-expansion (limit)
- (when (re-search-forward "[^\\]\\(\\\\\\\\\\)*\\(#\\({[^}\n\\\\]*\\(\\\\.[^}\n\\\\]*\\)*}\\|\\(\\$\\|@\\|@@\\)\\(\\w\\|_\\)+\\)\\)" limit 'move)
+ (when (re-search-forward "\\(\\\\\\\\\\)*\\(#\\({[^}\n\\\\]*\\(\\\\.[^}\n\\\\]*\\)*}\\|\\(\\$\\|@\\|@@\\)\\(\\w\\|_\\)+\\)\\)" limit 'move)
(or (ruby-in-ppss-context-p 'string)
(ruby-match-expression-expansion limit))))
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: ruby-mode interpolated quotes error
2014-05-02 21:42 ruby-mode interpolated quotes error Andrew Pennebaker
2014-05-02 23:13 ` Bob Proulx
@ 2014-05-03 1:32 ` Stefan Monnier
2014-05-03 1:55 ` Bob Proulx
1 sibling, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2014-05-03 1:32 UTC (permalink / raw)
To: help-gnu-emacs
> Anyone else experience this?
That's typically something that deserves a bug-report.
In this particular instance, I can tell you that the bug is already
fixed in the 24.3.90 pretest, tho.
Stefan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: ruby-mode interpolated quotes error
2014-05-03 1:32 ` Stefan Monnier
@ 2014-05-03 1:55 ` Bob Proulx
0 siblings, 0 replies; 5+ messages in thread
From: Bob Proulx @ 2014-05-03 1:55 UTC (permalink / raw)
To: help-gnu-emacs
Stefan Monnier wrote:
> Andrew Pennebaker wrote:
> > Anyone else experience this?
>
> That's typically something that deserves a bug-report.
> In this particular instance, I can tell you that the bug is already
> fixed in the 24.3.90 pretest, tho.
Oh! Good deal. And the code there is quite different around this
area. But the new file can be used directly in 24.3.1 by my quick
testing of it. I put that into my $HOME emacs lisp file load area and
it solves this bug for me.
http://git.savannah.gnu.org/gitweb/?p=emacs.git;a=tree;f=lisp/progmodes
A direct link to download just the ruby-mode.el file individually is:
http://git.savannah.gnu.org/gitweb/?p=emacs.git;a=blob_plain;f=lisp/progmodes/ruby-mode.el
Bob
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-05-03 1:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-02 21:42 ruby-mode interpolated quotes error Andrew Pennebaker
2014-05-02 23:13 ` Bob Proulx
2014-05-02 23:55 ` Bob Proulx
2014-05-03 1:32 ` Stefan Monnier
2014-05-03 1:55 ` Bob Proulx
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).