From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Philippe Vaucher Newsgroups: gmane.emacs.devel Subject: Re: Help understanding ruby.el percent literal syntax Date: Wed, 19 Jun 2019 17:51:57 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000002ffbe6058baf37f7" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="9722"; mail-complaints-to="usenet@blaine.gmane.org" Cc: Emacs developers To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jun 19 17:57:39 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hdcxu-0002KM-7b for ged-emacs-devel@m.gmane.org; Wed, 19 Jun 2019 17:57:38 +0200 Original-Received: from localhost ([::1]:39754 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hdcxn-0001Km-UR for ged-emacs-devel@m.gmane.org; Wed, 19 Jun 2019 11:57:31 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49739) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hdcsu-0005F2-Bt for emacs-devel@gnu.org; Wed, 19 Jun 2019 11:52:29 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hdcst-00029r-47 for emacs-devel@gnu.org; Wed, 19 Jun 2019 11:52:28 -0400 Original-Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]:39745) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hdcss-00029A-S5 for emacs-devel@gnu.org; Wed, 19 Jun 2019 11:52:27 -0400 Original-Received: by mail-lf1-x12d.google.com with SMTP id p24so12539224lfo.6 for ; Wed, 19 Jun 2019 08:52:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=SvWD/2DAcwmrm9RK1d6jczvQ52UmstiD+MNyXR61RH8=; b=eDFfWO/3fGzDxZGrTukmowzwzFm1Rk35nEqYhr4+dBB288DWieHu7kl7/CvpvKSe3Y kXdbHFZW2XxtSO6AvCLIFujDbF8CcAbn6k77SNYNn6ooOzZz42fsf2xvXberSP3C2cUV 6FFumd8aPQdbos7PWWu5Lg9fLfdLnD/MvmdoR67TSarQ1r9LK1Cu2xnCwCG4uRx7mXM7 Lw1+mWjpY9emELDojnoO/15LX85deojDa7gDLmdgLLWekMt9naGVhwL6GIFAg+itu3e3 c51bPSXjWRONiawlctXiVZgEaK1PyXaNLOAOs6I+vx17vQkgxDkmQtD84ScRVweAgpc/ N0tA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=SvWD/2DAcwmrm9RK1d6jczvQ52UmstiD+MNyXR61RH8=; b=MkAVr9wOyOuZkSPW0CP5VZAkFqSYHkAfp8CwDMjZe+bIVstL1Eby+BVmksUihxkJMi +uowBeEPv+ICjmY1FLKbSzDYocvJ9yZYZDXQQUnje4AVmtmllStNpDEq80iLwWJ6asWY aV8ap5YhW9BYB9fU+992xJdFuiKfnqXnrlk/9CLBeCqvIdGTjH96Dx8+E8sxn5+SKcBg w63C8CWd0JE9P3fj3cLXV6OdPvyruq9NMvF+A3LROPT04zIi/Gk72CXQmaLIWVzW6NUg 2Brt93vIIuJlyPku+YEE5ymzoHiDCXPwErPDLhvgM0BswQfZMbiDhETWfnGptD0N4N54 IC2Q== X-Gm-Message-State: APjAAAUnHW4Ml+5OH2tQYvFT1z7zJpbi9u1cbORwqamuy7VYw1qjz3pL sMYwL6SnVXDS1N8nUgUkUpVppxblkTk9on8nlhY= X-Google-Smtp-Source: APXvYqwdcSy5NKHn4s+lcR54uoOMOWJVTHUhoZrVpT4rfibsomIfQnvpmw7QOCo+ZBn3jDg1TunEFHSuGhDmnf80SYE= X-Received: by 2002:ac2:50cd:: with SMTP id h13mr25963228lfm.36.1560959544981; Wed, 19 Jun 2019 08:52:24 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::12d X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:237912 Archived-At: --0000000000002ffbe6058baf37f7 Content-Type: text/plain; charset="UTF-8" > > ruby-mode uses syntax-propertize to make it so that > > config.allow_sites = %w{twitter facebook pinterest linkedin} > > is treated somewhat like > > config.allow_sites = "w{twitter facebook pinterest linkedin" > > So if you go to the end of the line and try to skip back over the > previous `sexp` you'll end up in front of the `%` rather than in front > of the `{`. > > The purpose is probably to handle things like: > > config.allow_sites = %w{twitter facebook # pinterest linkedin} > > where the `#` would otherwise be taken as the beginning of a comment. > Ah right, that makes sense. > > If I comment out the call to `ruby-syntax-propertize-percent-literal', > then > > the bug in evil-surround is gone, and everything just looks the same > > visually (the percent literals are correctly highlighted). > > Not sure what "comment out the call" means exactly, but from my reading > of the code, it would result in mayhem (the %w{ above would probably > be highlighted as if he extended to the end of the buffer). > What I meant was "if I edit `ruby-syntax-propertize' so it never calls `ruby-syntax-propertize-percent-literal' at line 1929". But I think you are right, it would probably break on your example with the comment above. In order to interact better with things like Evil's > delimiter-replacement, ruby-mode.el could be changed so that instead of > marking the opening `%` and the closing `}` with the `|` syntax, it > would mark the `%` and `w` part with `'` syntax and then arrange to mark > the inside of the delimited text with an ad-hoc syntax table that > doesn't treat `#` as a comment started nor `"` as a string delimiter > (i.e., the same syntax-table used by the `with-syntax-table` > in `ruby-syntax-propertize-percent-literal`). Or alternatively, it > could look for things like `#` and `"` and give them a `.` syntax. Thank you a lot for the explanation and the suggestion! We'll see what we can do :-) Kind regards, Philippe --0000000000002ffbe6058baf37f7 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
ruby-mode uses syntax-propertize to make it so that

=C2=A0 =C2=A0 config.allow_sites =3D %w{twitter facebook pinterest linkedin= }

is treated somewhat like

=C2=A0 =C2=A0 config.allow_sites =3D "w{twitter facebook pinterest lin= kedin"

So if you go to the end of the line and try to skip back over the
previous `sexp` you'll end up in front of the `%` rather than in front<= br> of the `{`.

The purpose is probably to handle things like:

=C2=A0 =C2=A0 config.allow_sites =3D %w{twitter facebook # pinterest linked= in}

where the `#` would otherwise be taken as the beginning of a comment.

Ah right, that makes sense.

=C2=A0
>= If I comment out the call to `ruby-syntax-propertize-percent-literal',= then
> the bug in evil-surround is gone, and everything just looks the same > visually (the percent literals are correctly highlighted).

Not sure what "comment out the call" means exactly, but from my r= eading
of the code, it would result in mayhem (the %w{ above would probably
be highlighted as if he extended to the end of the buffer).

What I meant was "if I edit `ruby-syntax-properti= ze' so it never calls `ruby-syntax-propertize-percent-literal' at l= ine 1929". But I think you are right, it would probably break on your = example with the comment above.
=C2=A0

In order to interact better wit= h things like Evil's
delimiter-replacement, ruby-mode.el could be changed so that instead of
marking the opening `%` and the closing `}` with the `|` syntax, it
would mark the `%` and `w` part with `'` syntax and then arrange to mar= k
the inside of the delimited text with an ad-hoc syntax table that
doesn't treat `#` as a comment started nor `"` as a string delimit= er
(i.e., the same syntax-table used by the `with-syntax-table`
in `ruby-syntax-propertize-percent-literal`).=C2=A0 Or alternatively, it could look for things like `#` and `"` and give them a `.` syntax.

Thank you a lot for the explanation and the su= ggestion! We'll see what we can do :-)

Kind re= gards,
Philippe=C2=A0
--0000000000002ffbe6058baf37f7--