unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: ndame <emacsuser@freemail.hu>
To: "37459@debbugs.gnu.org" <37459@debbugs.gnu.org>
Subject: bug#37459: 26.2; sql syntax highlight problem when escaping single quote
Date: Fri, 20 Sep 2019 15:28:54 +0200 (CEST)	[thread overview]
Message-ID: <Ax4HEQ.F0FClPz31N6Y.dHOR7BaMc85JZae4Dm@freemail.hu> (raw)
In-Reply-To: <handler.37459.B.156889741719764.ack@debbugs.gnu.org>

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

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?
   

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

  parent reply	other threads:[~2019-09-20 13:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-19 12:39 bug#37459: 26.2; sql syntax highlight problem when escaping single quote ndame
2019-10-26 15:19 ` bug#37459: Corrects sql-mode help about escape character syntax Kristian Hole
2019-10-26 15:25 ` bug#37459: Adds backslash as escape character to mysql syntax-alist Kristian Hole
2020-01-20 19:37   ` Stefan Kangas
2020-08-09 18:57   ` Lars Ingebrigtsen
2020-08-09 19:02     ` Lars Ingebrigtsen
     [not found] ` <handler.37459.B.156889741719764.ack@debbugs.gnu.org>
2019-09-20 13:28   ` ndame [this message]
2019-11-22 14:44   ` bug#37459: Acknowledgement (26.2; sql syntax highlight problem when escaping single quote) ndame

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Ax4HEQ.F0FClPz31N6Y.dHOR7BaMc85JZae4Dm@freemail.hu \
    --to=emacsuser@freemail.hu \
    --cc=37459@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).