From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: ndame Newsgroups: gmane.emacs.bugs Subject: bug#37459: 26.2; sql syntax highlight problem when escaping single quote Date: Fri, 20 Sep 2019 15:28:54 +0200 (CEST) Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_7576_1734759372.1568985933475" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="136569"; mail-complaints-to="usenet@blaine.gmane.org" To: "37459@debbugs.gnu.org" <37459@debbugs.gnu.org> Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Sep 20 15:30:43 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1iBIzi-000ZMq-GY for geb-bug-gnu-emacs@m.gmane.org; Fri, 20 Sep 2019 15:30:42 +0200 Original-Received: from localhost ([::1]:59674 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBIzf-00086n-HL for geb-bug-gnu-emacs@m.gmane.org; Fri, 20 Sep 2019 09:30:39 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54774) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBIz9-0007lN-FR for bug-gnu-emacs@gnu.org; Fri, 20 Sep 2019 09:30:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iBIz8-000229-0G for bug-gnu-emacs@gnu.org; Fri, 20 Sep 2019 09:30:07 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:48162) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iBIz7-00021c-1B for bug-gnu-emacs@gnu.org; Fri, 20 Sep 2019 09:30:05 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iBIz6-00070B-RU for bug-gnu-emacs@gnu.org; Fri, 20 Sep 2019 09:30:04 -0400 X-Loop: help-debbugs@gnu.org Resent-From: ndame Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 20 Sep 2019 13:30:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 37459 X-GNU-PR-Package: emacs Original-Received: via spool by 37459-submit@debbugs.gnu.org id=B37459.156898614526796 (code B ref 37459); Fri, 20 Sep 2019 13:30:04 +0000 Original-Received: (at 37459) by debbugs.gnu.org; 20 Sep 2019 13:29:05 +0000 Original-Received: from localhost ([127.0.0.1]:56983 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iBIy9-0006y6-8t for submit@debbugs.gnu.org; Fri, 20 Sep 2019 09:29:05 -0400 Original-Received: from fmfe09.onbox.hu ([46.107.16.202]:27344 helo=web-out.onbox.hu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iBIy6-0006xh-6w for 37459@debbugs.gnu.org; Fri, 20 Sep 2019 09:29:03 -0400 X-fm-smtp-source: yes Original-Received: from localhost (localhost [94.21.250.143]) by web-out.onbox.hu (Postfix) with SMTP id 46ZZLG724rzVpF for <37459@debbugs.gnu.org>; Fri, 20 Sep 2019 15:28:54 +0200 (CEST) In-Reply-To: X-AccountId: 57978162 X-Originating-Ip: 94.21.250.143 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrvddvgdehhecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucggtfgfnhhsuhgsshgtrhhisggvpdcuhfftgffgofetkffnnecuuegrihhlohhuthemuceftddtnecunecujfgurhephffvkfgjfhfugggtihffsegrtdersgdttddunecuhfhrohhmpehnuggrmhgvuceovghmrggtshhushgvrhesfhhrvggvmhgrihhlrdhhuheqnecuffhomhgrihhnpehmhihsqhhlrdgtohhmnecukfhppeelgedrvddurddvhedtrddugeefnecurfgrrhgrmhephhgvlhhopedpihhnvghtpeelgedrvddurddvhedtrddugeefpdhmrghilhhfrhhomhepvghmrggtshhushgvrhesfhhrvggvmhgrihhlrdhhuhdprhgtphhtthhopeefjeegheelseguvggssghughhsrdhgnhhurdhorhhgnecuvehluhhsthgvrhfuihiivgeptd DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=simple/relaxed; t=1568986135; s=20181004; d=freemail.hu; h=From:To:Message-ID:In-Reply-To:References:Subject:MIME-Version:Content-Type:Date; l=4483; bh=PGRSO/PA/soHO9xKesKfckT7hQb+JdjkWqVYFzq2NrE=; b=ZJsQZKBr+oEdoUOjeX8i2augf1yfNhQoMYZS2C228LVM++OnyhcZeru+mQz8y/DQ JrfmP4ohpzQphLJ7BuAEa8LfGyl1V/Mnr0hVASlr0PKNaBurBEGONndX7JqYSUgVf3O WmnpfA2HA669iSbonqQKKsFRvruvtfHb6u0ephGPf+U+zAGR0PA/g5uDfRA0WwilCH+ Ul1kZhuA4jMCCa5hhzfp0Fw+ouUZY4lp0ZoA4+QXoS59Kec+iMrEF3SD7REAH+NNwi3 0KlvDo1NLLIWbG/2CN9q+KziZjZO4yBUijCGqXAS/Jev/WjKzdK4QrtDjEApq1A5qOp IpS3lo2Hpg== X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:166767 Archived-At: ------=_Part_7576_1734759372.1568985933475 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I poked around for the problem and found this in sql-mode Help: =C2=A0 Note that SQL doesn't have an escape character unless you specify =C2=A0 one. =C2=A0If you specify backslash as escape character in SQL, you =C2=A0 must tell Emacs. =C2=A0Here's how to do that in your init file: =C2=A0 (add-hook 'sql-mode-hook =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (lambda () =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (modify-syntax-entry ?\\ "= ." sql-mode-syntax-table))) And sure enough, the syntax of \ was punctuation. However, adding the above add hook did nothing. The string highlighting was still wrong. It's because the suggestion is wrong, because it sets slash to punctuation again. Somebody who has access to the repo could simply fix that by changing the syntax string in the example: =C2=A0 (modify-syntax-entry ?\\ "\\" sql-mode-syntax-table) So it worked, but then I realized there are different sql modes and the default is ANSI, so I changed it to Mysql to test it, but that didn't help either. Then I checked the mysql syntax setting and backslash was missing there too, though backslash is an escape character for mysql by default: =C2=A0 https://dev.mysql.com/doc/refman/8.0/en/string-literals.html So I changed the syntax for mysql by adding backslash: =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0:syntax-alist ((?# . "< b") (?\\ .= "\\")) and this fixed it. There are 3 takeaways: 1. The incorrect example in sql-mode Help should be fixed. 2. Since backslash is an escape character in mysql it may be set as =C2=A0 =C2=A0such by default if the user chooses mysql mode. 3. The user may not realize he is in an incorrect sql mode. Maybe when =C2=A0 =C2=A0the user activates sql mode for the first time emacs should te= ll him =C2=A0 =C2=A0that ansi is the default and ask him if he wants to change it? =C2=A0 =C2=A0 ------=_Part_7576_1734759372.1568985933475 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit I poked around for the problem and found this in sql-mode Help:

  Note that SQL doesn't have an escape character unless you specify
  one.  If you specify backslash as escape character in SQL, you
  must tell Emacs.  Here's how to do that in your init file:

  (add-hook 'sql-mode-hook
            (lambda ()
              (modify-syntax-entry ?\\ "." sql-mode-syntax-table)))


And sure enough, the syntax of \ was punctuation.

However, adding the above add hook did nothing. The string
highlighting was still wrong.

It's because the suggestion is wrong, because it sets slash to
punctuation again.

Somebody who has access to the repo could simply fix that by changing
the syntax string in the example:

  (modify-syntax-entry ?\\ "\\" sql-mode-syntax-table)


So it worked, but then I realized there are different sql modes and
the default is ANSI, so I changed it to Mysql to test it, but that
didn't help either.

Then I checked the mysql syntax setting and backslash was missing
there too, though backslash is an escape character for mysql by
default:

  https://dev.mysql.com/doc/refman/8.0/en/string-literals.html

So I changed the syntax for mysql by adding backslash:

           :syntax-alist ((?# . "< b") (?\\ . "\\"))

and this fixed it.


There are 3 takeaways:

1. The incorrect example in sql-mode Help should be fixed.

2. Since backslash is an escape character in mysql it may be set as
   such by default if the user chooses mysql mode.

3. The user may not realize he is in an incorrect sql mode. Maybe when
   the user activates sql mode for the first time emacs should tell him
   that ansi is the default and ask him if he wants to change it?
    ------=_Part_7576_1734759372.1568985933475--