[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/smartparens 37f77bf2e2 2/2: fix(escape): when autoescaping
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/smartparens 37f77bf2e2 2/2: fix(escape): when autoescaping, explicitly check for escape on open quote |
Date: |
Fri, 4 Feb 2022 06:58:40 -0500 (EST) |
branch: elpa/smartparens
commit 37f77bf2e2199be9fe27e981317b02cfd0e8c70e
Author: Matus Goljer <matus.goljer@gmail.com>
Commit: Matus Goljer <matus.goljer@gmail.com>
fix(escape): when autoescaping, explicitly check for escape on open quote
Some modes like org-mode do not respect an escape syntactically and
even an escaped quote actually opens a string.
---
smartparens.el | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/smartparens.el b/smartparens.el
index 7498d9e37a..fd58064586 100644
--- a/smartparens.el
+++ b/smartparens.el
@@ -3674,7 +3674,19 @@ delimiter insertion separately."
;; do not escape if we are looking at a closing
;; delimiter, that means we closed an opened string,
;; most likely.
- (sp--buffer-is-string-balanced-p))
+ (sp--buffer-is-string-balanced-p)
+ ;; in some text modes like org-mode which do not
+ ;; respect escapes, an "escaped" quote will still
+ ;; behave as regular quote, but we want to ignore it to
+ ;; be logically consistent. This will prevent a buffer
+ ;; with \" followed by newly inserted " auto-escaping
+ ;; the inserted quotes (which actually closes the
+ ;; string and makes the buffer balanced)
+ (save-excursion
+ (backward-char (length open))
+ (-when-let (string-start (nth 8 (sp--syntax-ppss)))
+ (goto-char string-start)
+ (not (sp-char-is-escaped-p)))))
(sp--escape-region (list open) (- (point) (length open)) (point)))))
;; kept to not break people's config... remove later