From 46db98ece2cab6bac67c05aff1def9d910591cbb Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Sun, 19 Jun 2022 15:31:04 +0200 Subject: [PATCH] Recognize \' as a quoted quote in MySQL * lisp/progmodes/sql.el (sql-mode): Recognize \' as a quoted quote in MySQL (bug#38302). --- lisp/progmodes/sql.el | 49 ++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el index 8d259860901..ef8375e859c 100644 --- a/lisp/progmodes/sql.el +++ b/lisp/progmodes/sql.el @@ -4161,28 +4161,33 @@ must tell Emacs. Here's how to do that in your init file: (setq-local sql-contains-names t) (setq-local escaped-string-quote "'") (setq-local syntax-propertize-function - (syntax-propertize-rules - ;; Handle escaped apostrophes within strings. - ("''" - (0 - (if (save-excursion (nth 3 (syntax-ppss (match-beginning 0)))) - (string-to-syntax ".") - (forward-char -1) - nil))) - ;; Propertize rules to not have /- and -* start comments. - ("\\(/-\\)" (1 ".")) - ("\\(-\\*\\)" - (1 - (if (save-excursion - (not (ppss-comment-depth - (syntax-ppss (match-beginning 1))))) - ;; If we're outside a comment, we don't let -* - ;; start a comment. - (string-to-syntax ".") - ;; Inside a comment, ignore it to avoid -*/ not - ;; being interpreted as a comment end. - (forward-char -1) - nil))))) + (eval + '(syntax-propertize-rules + ;; Handle escaped apostrophes within strings. + ((if (eq sql-product 'mysql) + "\\\\'" + "''") + (0 + (if (save-excursion + (nth 3 (syntax-ppss (match-beginning 0)))) + (string-to-syntax ".") + (forward-char -1) + nil))) + ;; Propertize rules to not have /- and -* start comments. + ("\\(/-\\)" (1 ".")) + ("\\(-\\*\\)" + (1 + (if (save-excursion + (not (ppss-comment-depth + (syntax-ppss (match-beginning 1))))) + ;; If we're outside a comment, we don't let -* + ;; start a comment. + (string-to-syntax ".") + ;; Inside a comment, ignore it to avoid -*/ not + ;; being interpreted as a comment end. + (forward-char -1) + nil)))) + t)) ;; Set syntax and font-face highlighting ;; Catch changes to sql-product and highlight accordingly (sql-set-product (or sql-product 'ansi)) ; Fixes bug#13591 -- 2.39.2