unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#5757: 23.1; String literal parse problem in ruby-mode
@ 2010-03-23 16:21 Rhett Sutphin
  2011-03-30 22:08 ` bug#5757: The line which causes the bug is 1185 Pål de Vibe
  0 siblings, 1 reply; 7+ messages in thread
From: Rhett Sutphin @ 2010-03-23 16:21 UTC (permalink / raw)
  To: 5757

ruby-mode will misunderstand a ruby double-quoted string literal which
contains a single quote and ends with a question mark.  It thinks that
the string literal is unterminated, which contaminates the syntax
highlighting for the remainder of the buffer.

Example ruby code which will demonstrate the problem:

["Is 'this' a string?"], [:something, :else]

If there's anything between the question mark and the terminating
double-quote, the string will be correctly interpreted.

Thanks,
Rhett Sutphin
rhett@detailedbalance.net


In GNU Emacs 23.1.1 (i386-apple-darwin9.8.0, NS apple-appkit-949.54)
  of 2009-08-16 on black.local
Windowing system distributor `Apple', version 10.3.949
configured using `configure  '--with-ns''

Important settings:
   value of $LC_ALL: nil
   value of $LC_COLLATE: nil
   value of $LC_CTYPE: nil
   value of $LC_MESSAGES: nil
   value of $LC_MONETARY: nil
   value of $LC_NUMERIC: nil
   value of $LC_TIME: nil
   value of $LANG: nil
   value of $XMODIFIERS: nil
   locale-coding-system: nil
   default-enable-multibyte-characters: t

Major mode: Ruby

Minor modes in effect:
   yas/global-mode: t
   yas/minor-mode: t
   auto-fill-function: do-auto-fill
   global-auto-revert-mode: t
   hi-lock-mode: t
   shell-dirtrack-mode: t
   hl-line-mode: t
   global-linum-mode: t
   linum-mode: t
   show-paren-mode: t
   nxhtml-global-minor-mode: t
   recentf-mode: t
   mouse-wheel-mode: t
   menu-bar-mode: t
   file-name-shadow-mode: t
   global-font-lock-mode: t
   font-lock-mode: t
   global-auto-composition-mode: t
   auto-composition-mode: t
   auto-encryption-mode: t
   auto-compression-mode: t
   column-number-mode: t
   line-number-mode: t
   transient-mark-mode: t

Recent input:
<right> <backspace> <backspace> <backspace> <backspace>
<backspace> <backspace> <backspace> <backspace> <backspace>
<backspace> <backspace> <backspace> <backspace> <backspace>
<backspace> <left> <backspace> <backspace> <backspace>
<backspace> <backspace> <backspace> <backspace> <backspace>
<backspace> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <right> <right> <right> <right> <right>
<right> <right> <right> <right> <right> <up> <up> <up>
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up>
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <left>
<left> <right> <right> ' <right> <left> " <left> <left>
<left> <left> <right> <left> <right> <right> <left>
<left> <right> <right> <right> <left> <left> <left>
<left> <right> <right> <right> <right> <right> <down>
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <right>
<right> <right> <right> <right> <right> <left> <right>
<right> <right> <right> <right> <right> <right> <right>
<right> <right> <right> <right> <left> <left> <left>
<left> <left> <left> <left> <left> <left> <left> <left>
<left> <backspace> <left> <left> <backspace> ' <right>
<right> <right> <right> <right> <right> <right> <right>
<right> <right> <right> <right> <right> <right> , SPC
[ : a ] <left> <left> <left> <left> <left> <left> <left>
<left> <left> <left> <left> <left> <left> <left> <left>
<left> <left> <left> <left> <left> <backspace> <right>
<right> <right> <right> <right> ' <right> <right> <right>
<right> <right> <right> ' <backspace> <left> <left>
<left> <left> <left> <left> <backspace> <backspace>
<backspace> <backspace> <backspace> <backspace> <backspace>
<backspace> <backspace> <backspace> <backspace> ' '
' ' ' ' ' ' ' ' ' ' ' <backspace> <backspace> <backspace>
<backspace> <backspace> <backspace> <backspace> <backspace>
<backspace> <backspace> <backspace> <backspace> <backspace>
<backspace> " <right> <right> <right> <right> <right>
<right> ? <backspace> <left> <left> <left> ? <down-mouse-1>
<mouse-1> M-x r e p o r t - e m <tab> <return>

Recent messages:
Auto-saving...done
Quit
Mark set
Undo! [6 times]
Quit
Auto-saving...done
Making completion list...
Quit
ruby-indent-to: invalid nest [2 times]
call-interactively: End of buffer







^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#5757: The line which causes the bug is 1185
  2010-03-23 16:21 bug#5757: 23.1; String literal parse problem in ruby-mode Rhett Sutphin
@ 2011-03-30 22:08 ` Pål de Vibe
  2011-04-03  0:50   ` bug#5757: String literal parse problem in ruby-mode Chong Yidong
  0 siblings, 1 reply; 7+ messages in thread
From: Pål de Vibe @ 2011-03-30 22:08 UTC (permalink / raw)
  To: 5757

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

Line 1185:
          ("\\(^\\|[^\\\\]\\)\\(\\\\\\\\\\)*[?$]\\([#\"'`]\\)" 3 (1 . nil))

A workaround (with, to me, uknown consequences) is to remove the question mark 
from the line, like this:

          ("\\(^\\|[^\\\\]\\)\\(\\\\\\\\\\)*[$]\\([#\"'`]\\)" 3 (1 . nil))

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#5757: String literal parse problem in ruby-mode
  2011-03-30 22:08 ` bug#5757: The line which causes the bug is 1185 Pål de Vibe
@ 2011-04-03  0:50   ` Chong Yidong
  2011-04-04 13:53     ` Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: Chong Yidong @ 2011-04-03  0:50 UTC (permalink / raw)
  To: Nobuyoshi Nakada; +Cc: Pål de Vibe, 5757

Hi Nakada-san,

Could you help review Pål de Vibe's proposed fix to the following
problem in Emacs ruby-mode?  Thanks.


Pål de Vibe <pauldevibe@yahoo.no> writes:

>> ruby-mode will misunderstand a ruby double-quoted string literal which
>> contains a single quote and ends with a question mark.  It thinks that
>> the string literal is unterminated, which contaminates the syntax
>> highlighting for the remainder of the buffer.
>>
>> Example ruby code which will demonstrate the problem:
>>
>> ["Is 'this' a string?"], [:something, :else]
>>
>> If there's anything between the question mark and the terminating
>> double-quote, the string will be correctly interpreted.
>
> Line 1185:
> ("\\(^\\|[^\\\\]\\)\\(\\\\\\\\\\)*[?$]\\([#\"'`]\\)" 3 (1 . nil))
>
> A workaround (with, to me, uknown consequences) is to remove the
> question mark from the line, like this:
>
> ("\\(^\\|[^\\\\]\\)\\(\\\\\\\\\\)*[$]\\([#\"'`]\\)" 3 (1 . nil))






^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#5757: String literal parse problem in ruby-mode
  2011-04-03  0:50   ` bug#5757: String literal parse problem in ruby-mode Chong Yidong
@ 2011-04-04 13:53     ` Stefan Monnier
  2011-04-04 13:55       ` Pål de Vibe
  2011-04-09 20:34       ` Chong Yidong
  0 siblings, 2 replies; 7+ messages in thread
From: Stefan Monnier @ 2011-04-04 13:53 UTC (permalink / raw)
  To: Chong Yidong; +Cc: Pål de Vibe, Nobuyoshi Nakada, 5757

> Could you help review Pål de Vibe's proposed fix to the following
> problem in Emacs ruby-mode?  Thanks.

His proposed fix is not correct: in ruby (like in Elisp) ?<char> is used
for chars (including ?' and ?") and $' and $" are also special vars, so
his fix just disables the special treatment of ?.
For Emacs-24, we use a different chunk of code which doesn't suffer from
this problem (mostly calling syntax-ppss to determine if we're inside
a string).


        Stefan


> Pål de Vibe <pauldevibe@yahoo.no> writes:

>>> ruby-mode will misunderstand a ruby double-quoted string literal which
>>> contains a single quote and ends with a question mark.  It thinks that
>>> the string literal is unterminated, which contaminates the syntax
>>> highlighting for the remainder of the buffer.
>>> 
>>> Example ruby code which will demonstrate the problem:
>>> 
>>> ["Is 'this' a string?"], [:something, :else]
>>> 
>>> If there's anything between the question mark and the terminating
>>> double-quote, the string will be correctly interpreted.
>> 
>> Line 1185:
>> ("\\(^\\|[^\\\\]\\)\\(\\\\\\\\\\)*[?$]\\([#\"'`]\\)" 3 (1 . nil))
>> 
>> A workaround (with, to me, uknown consequences) is to remove the
>> question mark from the line, like this:
>> 
>> ("\\(^\\|[^\\\\]\\)\\(\\\\\\\\\\)*[$]\\([#\"'`]\\)" 3 (1 . nil))








^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#5757: String literal parse problem in ruby-mode
  2011-04-04 13:53     ` Stefan Monnier
@ 2011-04-04 13:55       ` Pål de Vibe
  2011-04-09 20:34       ` Chong Yidong
  1 sibling, 0 replies; 7+ messages in thread
From: Pål de Vibe @ 2011-04-04 13:55 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Chong Yidong, Nobuyoshi Nakada, 5757

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

Hi. This wasn't really a proposed fix but more a hint to help debugging. I
haven't had time to really study the code. Thanks for the feedback.

On Mon, Apr 4, 2011 at 9:23 AM, Stefan Monnier <monnier@iro.umontreal.ca>wrote:

> > Could you help review Pål de Vibe's proposed fix to the following
> > problem in Emacs ruby-mode?  Thanks.
>
> His proposed fix is not correct: in ruby (like in Elisp) ?<char> is used
> for chars (including ?' and ?") and $' and $" are also special vars, so
> his fix just disables the special treatment of ?.
> For Emacs-24, we use a different chunk of code which doesn't suffer from
> this problem (mostly calling syntax-ppss to determine if we're inside
> a string).
>
>
>        Stefan
>
>
> > Pål de Vibe <pauldevibe@yahoo.no> writes:
>
> >>> ruby-mode will misunderstand a ruby double-quoted string literal which
> >>> contains a single quote and ends with a question mark.  It thinks that
> >>> the string literal is unterminated, which contaminates the syntax
> >>> highlighting for the remainder of the buffer.
> >>>
> >>> Example ruby code which will demonstrate the problem:
> >>>
> >>> ["Is 'this' a string?"], [:something, :else]
> >>>
> >>> If there's anything between the question mark and the terminating
> >>> double-quote, the string will be correctly interpreted.
> >>
> >> Line 1185:
> >> ("\\(^\\|[^\\\\]\\)\\(\\\\\\\\\\)*[?$]\\([#\"'`]\\)" 3 (1 . nil))
> >>
> >> A workaround (with, to me, uknown consequences) is to remove the
> >> question mark from the line, like this:
> >>
> >> ("\\(^\\|[^\\\\]\\)\\(\\\\\\\\\\)*[$]\\([#\"'`]\\)" 3 (1 . nil))
>
>
>
>

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#5757: String literal parse problem in ruby-mode
  2011-04-04 13:53     ` Stefan Monnier
  2011-04-04 13:55       ` Pål de Vibe
@ 2011-04-09 20:34       ` Chong Yidong
  2011-04-12  3:16         ` Stefan Monnier
  1 sibling, 1 reply; 7+ messages in thread
From: Chong Yidong @ 2011-04-09 20:34 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Pål de Vibe, Nobuyoshi Nakada, 5757

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

> His proposed fix is not correct: in ruby (like in Elisp) ?<char> is used
> for chars (including ?' and ?") and $' and $" are also special vars, so
> his fix just disables the special treatment of ?.
> For Emacs-24, we use a different chunk of code which doesn't suffer from
> this problem (mostly calling syntax-ppss to determine if we're inside
> a string).

Is this worth backporting to Emacs 23?  If not, let's close this bug.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#5757: String literal parse problem in ruby-mode
  2011-04-09 20:34       ` Chong Yidong
@ 2011-04-12  3:16         ` Stefan Monnier
  0 siblings, 0 replies; 7+ messages in thread
From: Stefan Monnier @ 2011-04-12  3:16 UTC (permalink / raw)
  To: Chong Yidong; +Cc: Pål de Vibe, Nobuyoshi Nakada, 5757

>> His proposed fix is not correct: in ruby (like in Elisp) ?<char> is used
>> for chars (including ?' and ?") and $' and $" are also special vars, so
>> his fix just disables the special treatment of ?.
>> For Emacs-24, we use a different chunk of code which doesn't suffer from
>> this problem (mostly calling syntax-ppss to determine if we're inside
>> a string).
> Is this worth backporting to Emacs 23?  If not, let's close this bug.

I think it's more important to keep in touch with the upstream
maintainers.  E.g. I still haven't heard anything from them regarding
the changes I've made for syntax-propertize (which happen to fix the
OP's problem).  I'm worried we might not stay in sync.


        Stefan





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-04-12  3:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-23 16:21 bug#5757: 23.1; String literal parse problem in ruby-mode Rhett Sutphin
2011-03-30 22:08 ` bug#5757: The line which causes the bug is 1185 Pål de Vibe
2011-04-03  0:50   ` bug#5757: String literal parse problem in ruby-mode Chong Yidong
2011-04-04 13:53     ` Stefan Monnier
2011-04-04 13:55       ` Pål de Vibe
2011-04-09 20:34       ` Chong Yidong
2011-04-12  3:16         ` Stefan Monnier

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