GNU bug report logs - #35646
In SQL mode /- incorrectly starts a comment

Previous Next

Package: emacs;

Reported by: mdruiter <at> gmail.com

Date: Thu, 9 May 2019 07:58:01 UTC

Severity: normal

Tags: fixed, patch

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 35646 in the body.
You can then email your comments to 35646 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#35646; Package emacs. (Thu, 09 May 2019 07:58:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to mdruiter <at> gmail.com:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 09 May 2019 07:58:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Michel de Ruiter <mdruiter <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: In SQL mode /- incorrectly starts a comment
Date: Thu, 9 May 2019 09:56:46 +0200
Hi,

I found that both -* and /- incorrectly start a comment in SQL mode.
The -* combination starts a block comment, but cannot be valid SQL
syntax AFAIK. However /- can be and should not start a line comment as
it does now. The simplest example is:
  SELECT 1/-1
It took me a while (https://emacs.stackexchange.com/q/50375) to
understand that this is expected behavior given the
sql-mode-syntax-table.
Of course using whitespace to separate / and -  'solves' the issue.
Someone might want to properly fix this using
syntax-propertize-function (as suggested by Stefan Monnier?,
https://emacs.stackexchange.com/a/50399).

Hope this helps!

Greets, Michel.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#35646; Package emacs. (Sun, 27 Oct 2019 20:49:02 GMT) Full text and rfc822 format available.

Message #8 received at 35646 <at> debbugs.gnu.org (full text, mbox):

From: Kristian Hole <kristian <at> hole.priv.no>
To: 35646 <at> debbugs.gnu.org
Subject: Re: In SQL mode /- incorrectly starts a comment
Date: Sun, 27 Oct 2019 21:48:26 +0100
[Message part 1 (text/plain, inline)]
Attached is a patch that fixes this by using the following
syntax-propertize-function:

(set (make-local-variable 'syntax-propertize-function)
     (syntax-propertize-rules
      ("\\(/-\\)" (1 "."))
      ("\\(-\\*\\)" (1 "."))))

Adds sql-mode syntax propertize rules to fix comment highlighting

Fixes the issue where -* and /- incorrectly starts comments
in SQL mode Bug(#35646). This is done by adding a
syntax-propertize-function to sql-mode.
[Message part 2 (text/html, inline)]
[0001-Adds-sql-mode-syntax-propertize-rules-to-fix-comment.patch (application/octet-stream, attachment)]

Added tag(s) patch. Request was from Kristian Hole <kristian <at> hole.priv.no> to control <at> debbugs.gnu.org. (Mon, 28 Oct 2019 11:42:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#35646; Package emacs. (Mon, 20 Jan 2020 19:46:02 GMT) Full text and rfc822 format available.

Message #13 received at 35646 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: Michael Mauger <michael <at> mauger.com>
Cc: Kristian Hole <kristian <at> hole.priv.no>, 35646 <at> debbugs.gnu.org
Subject: Re: bug#35646: In SQL mode /- incorrectly starts a comment
Date: Mon, 20 Jan 2020 20:44:52 +0100
Hi Michael,

Kristian Hole <kristian <at> hole.priv.no> writes:

> Attached is a patch that fixes this by using the following syntax-propertize-function:
>
> (set (make-local-variable 'syntax-propertize-function)
>      (syntax-propertize-rules
>       ("\\(/-\\)" (1 "."))
>       ("\\(-\\*\\)" (1 "."))))
>
> Adds sql-mode syntax propertize rules to fix comment highlighting
>
> Fixes the issue where -* and /- incorrectly starts comments
> in SQL mode Bug(#35646). This is done by adding a
> syntax-propertize-function to sql-mode.

Could you please take a look also at the below patch?  TIA.

Best regards,
Stefan Kangas

>
> From b6bd0f6f812fdb3200dd240bb8eab5f717ab7c44 Mon Sep 17 00:00:00 2001
> From: kahole <kristian <at> hole.priv.no>
> Date: Sun, 27 Oct 2019 21:29:48 +0100
> Subject: [PATCH] Adds sql-mode syntax propertize rules to fix comment
>  highlighting
>
> Fixes the issue where -* and /- incorrectly starts comments
> in SQL mode Bug(#35646). This is done by adding a
> syntax-propertize-function to sql-mode.
> ---
>  lisp/progmodes/sql.el | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el
> index b17364b08f..645944b34a 100644
> --- a/lisp/progmodes/sql.el
> +++ b/lisp/progmodes/sql.el
> @@ -4253,6 +4253,13 @@ sql-mode
>  
>    ;; (smie-setup sql-smie-grammar #'sql-smie-rules)
>    (set (make-local-variable 'comment-start) "--")
> +
> +  ;; Propertize rules to not have /- and -* start comments
> +  (set (make-local-variable 'syntax-propertize-function)
> +       (syntax-propertize-rules
> +        ("\\(/-\\)" (1 "."))
> +        ("\\(-\\*\\)" (1 "."))))
> +
>    ;; Make each buffer in sql-mode remember the "current" SQLi buffer.
>    (make-local-variable 'sql-buffer)
>    ;; Add imenu support for sql-mode.  Note that imenu-generic-expression




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#35646; Package emacs. (Mon, 10 Aug 2020 11:26:02 GMT) Full text and rfc822 format available.

Message #16 received at 35646 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Kristian Hole <kristian <at> hole.priv.no>
Cc: 35646 <at> debbugs.gnu.org
Subject: Re: bug#35646: In SQL mode /- incorrectly starts a comment
Date: Mon, 10 Aug 2020 13:25:23 +0200
Kristian Hole <kristian <at> hole.priv.no> writes:

> Attached is a patch that fixes this by using the following
> syntax-propertize-function:
>
> (set (make-local-variable 'syntax-propertize-function)
>      (syntax-propertize-rules
>       ("\\(/-\\)" (1 "."))
>       ("\\(-\\*\\)" (1 "."))))
>
> Adds sql-mode syntax propertize rules to fix comment highlighting
>
> Fixes the issue where -* and /- incorrectly starts comments
> in SQL mode Bug(#35646). This is done by adding a
> syntax-propertize-function to sql-mode.

Thanks; I've now adapted your code to work in Emacs 28.1 -- some other
changes had been made in this area that made your patch no longer apply.

I also cleaned up (and simplified) the previous patch at the same time.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 10 Aug 2020 11:26:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.1, send any further explanations to 35646 <at> debbugs.gnu.org and mdruiter <at> gmail.com Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 10 Aug 2020 11:26:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 08 Sep 2020 11:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 202 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.