Subject: Re: bug#48567: 28.0.50; ruby-toggle-string-quotes quotes the wrong pair of quotes

From: Dmitry Gutov <[email-masked]>
Date: Mon, 24 May 2021 03:54:02 +0300

Hi!

On 21.05.2021 15:33, Sam Weerasinghe wrote:
> I have a method like this:
> 
>    def create!
>      form_name = "Acme Corp #{shop.label("Abandon Cart")}"
>    end
> 
> put point at the start of the phrase "Abandon Cart"
> and press C-c ' ( ruby-toggle-string-quotes ),
> 
> the line becomes:
> 
>      form_name = 'Acme Corp #{shop.label("Abandon Cart")}'
> 
> but the line should become:
> 
>      form_name = "Acme Corp #{shop.label('Abandon Cart')}"

Improving this in a consistent fashion is somewhat difficult because we 
don't support an infinite nesting of string literals (or percent 
literals, etc), and the "inner" quote characters are not really 
considered to be quote characters by the syntax scanner anymore.

So identifying the pair of quotes to change, which ones to skip over, 
and which ones to quote-unquote, will require some ad-hoc heuristics.

I'd be happy to review a patch, though.