* bug#35646: In SQL mode /- incorrectly starts a comment
@ 2019-05-09 7:56 Michel de Ruiter
2019-10-27 20:48 ` Kristian Hole
0 siblings, 1 reply; 4+ messages in thread
From: Michel de Ruiter @ 2019-05-09 7:56 UTC (permalink / raw)
To: 35646
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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#35646: In SQL mode /- incorrectly starts a comment
2019-05-09 7:56 bug#35646: In SQL mode /- incorrectly starts a comment Michel de Ruiter
@ 2019-10-27 20:48 ` Kristian Hole
2020-01-20 19:44 ` Stefan Kangas
2020-08-10 11:25 ` Lars Ingebrigtsen
0 siblings, 2 replies; 4+ messages in thread
From: Kristian Hole @ 2019-10-27 20:48 UTC (permalink / raw)
To: 35646
[-- Attachment #1.1: Type: text/plain, Size: 449 bytes --]
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.
[-- Attachment #1.2: Type: text/html, Size: 579 bytes --]
[-- Attachment #2: 0001-Adds-sql-mode-syntax-propertize-rules-to-fix-comment.patch --]
[-- Type: application/octet-stream, Size: 1156 bytes --]
From b6bd0f6f812fdb3200dd240bb8eab5f717ab7c44 Mon Sep 17 00:00:00 2001
From: kahole <kristian@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
--
2.18.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* bug#35646: In SQL mode /- incorrectly starts a comment
2019-10-27 20:48 ` Kristian Hole
@ 2020-01-20 19:44 ` Stefan Kangas
2020-08-10 11:25 ` Lars Ingebrigtsen
1 sibling, 0 replies; 4+ messages in thread
From: Stefan Kangas @ 2020-01-20 19:44 UTC (permalink / raw)
To: Michael Mauger; +Cc: Kristian Hole, 35646
Hi Michael,
Kristian Hole <kristian@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@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
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#35646: In SQL mode /- incorrectly starts a comment
2019-10-27 20:48 ` Kristian Hole
2020-01-20 19:44 ` Stefan Kangas
@ 2020-08-10 11:25 ` Lars Ingebrigtsen
1 sibling, 0 replies; 4+ messages in thread
From: Lars Ingebrigtsen @ 2020-08-10 11:25 UTC (permalink / raw)
To: Kristian Hole; +Cc: 35646
Kristian Hole <kristian@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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-08-10 11:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-09 7:56 bug#35646: In SQL mode /- incorrectly starts a comment Michel de Ruiter
2019-10-27 20:48 ` Kristian Hole
2020-01-20 19:44 ` Stefan Kangas
2020-08-10 11:25 ` Lars Ingebrigtsen
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).