[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 289d6b2: Handle '' in strings in SQL Mode
From: |
Lars Ingebrigtsen |
Subject: |
master 289d6b2: Handle '' in strings in SQL Mode |
Date: |
Sat, 8 Aug 2020 09:34:07 -0400 (EDT) |
branch: master
commit 289d6b2265e19822ed5ad44e5c62e9bf3750f606
Author: Florian v. Savigny <f.savigny@mailbox.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Handle '' in strings in SQL Mode
* lisp/progmodes/sql.el
(sql--syntax-propertize-escaped-apostrophe): Handle '' in strings
(bug#40231).
(sql-mode): Use it.
---
lisp/progmodes/sql.el | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el
index c86fc59..8e3191c 100644
--- a/lisp/progmodes/sql.el
+++ b/lisp/progmodes/sql.el
@@ -1508,6 +1508,22 @@ Based on `comint-mode-map'.")
table)
"Syntax table used in `sql-mode' and `sql-interactive-mode'.")
+;;; Syntax Properties
+
+;; `sql--syntax-propertize-escaped-apostrophe', as follows, was
+;; (analysed and) adapted from `pascal--syntax-propertize' in
+;; pascal.el because basic syntax parsing cannot handle the SQL ''
+;; construct within strings.
+
+(defconst sql--syntax-propertize-escaped-apostrophe
+ (syntax-propertize-rules
+ ("''"
+ (0
+ (if (save-excursion (nth 3 (syntax-ppss (match-beginning 0))))
+ (string-to-syntax ".")
+ (forward-char -1)
+ nil)))))
+
;; Font lock support
(defvar sql-mode-font-lock-object-name
@@ -4210,6 +4226,11 @@ must tell Emacs. Here's how to do that in your init
file:
(setq-local abbrev-all-caps 1)
;; Contains the name of database objects
(set (make-local-variable 'sql-contains-names) t)
+ ;; Activate punctuation syntax table property for
+ ;; escaped apostrophes within strings:
+ (setq-local syntax-propertize-function
+ sql--syntax-propertize-escaped-apostrophe)
+ (setq-local parse-sexp-lookup-properties t) ; just to make sure it is used
;; Set syntax and font-face highlighting
;; Catch changes to sql-product and highlight accordingly
(sql-set-product (or sql-product 'ansi)) ; Fixes bug#13591
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 289d6b2: Handle '' in strings in SQL Mode,
Lars Ingebrigtsen <=