[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/yaml-mode 9e8362d 110/124: Merge pull request #76 from dgu
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/yaml-mode 9e8362d 110/124: Merge pull request #76 from dgutov/spf-speedup |
Date: |
Sun, 29 Aug 2021 11:36:23 -0400 (EDT) |
branch: elpa/yaml-mode
commit 9e8362dc553cde6f5ff27c4dd9b119200445819f
Merge: e1aed40 97a58b3
Author: Vasilij Schneidermann <mail@vasilij.de>
Commit: GitHub <noreply@github.com>
Merge pull request #76 from dgutov/spf-speedup
Speed up syntax-propertize-function in files with large JSON strings
---
test-files/test-quotes-in-strings.yaml | 5 +++++
yaml-mode.el | 36 +++++++++++++++++++++-------------
2 files changed, 27 insertions(+), 14 deletions(-)
diff --git a/test-files/test-quotes-in-strings.yaml
b/test-files/test-quotes-in-strings.yaml
new file mode 100644
index 0000000..5859bbd
--- /dev/null
+++ b/test-files/test-quotes-in-strings.yaml
@@ -0,0 +1,5 @@
+some's'strings'some's'nots:
+- here: syntax is not string
+- this: 'is a string with "quotes"'
+- and: 'to express one single quote, use '' two of them'
+- finally: syntax is not string
diff --git a/yaml-mode.el b/yaml-mode.el
index 19f1bc0..66e41b3 100644
--- a/yaml-mode.el
+++ b/yaml-mode.el
@@ -258,25 +258,33 @@ that key is pressed to begin a block literal."
(put-text-property (point) (1+ (point))
'syntax-table (string-to-syntax "_"))))))
- ;; If quote is detected as a syntactic string start but appeared
- ;; after a non-whitespace character, then mark it as syntactic word.
(save-excursion
(goto-char beg)
- (while (re-search-forward "['\"]" end t)
+ (while (and
+ (> end (point))
+ (re-search-forward "['\"]" end t))
(when (get-text-property (point) 'yaml-block-literal)
(put-text-property (1- (point)) (point)
'syntax-table (string-to-syntax "w")))
- (when (nth 8 (syntax-ppss))
- (save-excursion
- (forward-char -1)
- (cond ((and (char-equal ?' (char-before (point)))
- (char-equal ?' (char-after (point)))
- (put-text-property (1- (point)) (1+ (point))
- 'syntax-table (string-to-syntax
"w"))))
- ((and (not (bolp))
- (char-equal ?w (char-syntax (char-before (point)))))
- (put-text-property (point) (1+ (point))
- 'syntax-table (string-to-syntax
"w")))))))))
+ (let* ((pt (point))
+ (sps (save-excursion (syntax-ppss (1- pt)))))
+ (when (not (nth 8 sps))
+ (cond
+ ((and (char-equal ?' (char-before (1- pt)))
+ (char-equal ?' (char-before pt)))
+ (put-text-property (- pt 2) pt
+ 'syntax-table (string-to-syntax "w")))
+ ;; If quote is detected as a syntactic string start but appeared
+ ;; after a non-whitespace character, then mark it as syntactic word.
+ ((and (char-before (1- pt))
+ (char-equal ?w (char-syntax (char-before (1- pt)))))
+ (put-text-property (1- pt) pt
+ 'syntax-table (string-to-syntax "w")))
+ (t
+ ;; We're right after a quote that opens a string literal.
+ ;; Skip over it (big speedup for long JSON strings).
+ (goto-char (1- pt))
+ (ignore-errors (forward-sexp)))))))))
(defun yaml-font-lock-block-literals (bound)
"Find lines within block literals.
- [nongnu] elpa/yaml-mode 4ae92a7 062/124: Define keymap and syntax table properly, (continued)
- [nongnu] elpa/yaml-mode 4ae92a7 062/124: Define keymap and syntax table properly, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode c757396 066/124: Remove unnecessary refontification, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode 44f73b6 017/124: Add autoload comments., ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode 4c1127c 037/124: Improve paragraph filling of block literals, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode d88c80a 053/124: allow spaces before dash-newline, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode 4e69e6e 059/124: update address for FSF, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode a4794ea 070/124: Mark non-negative integer values for indent safe, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode 28c3403 085/124: Merge pull request #54 from jfrederickson/whitespace-document-separator, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode 7f41037 087/124: Merge pull request #57 from Kaali/master, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode 0aceaf3 100/124: Merge pull request #73 from tarsiiformes/typos, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode 9e8362d 110/124: Merge pull request #76 from dgutov/spf-speedup,
ELPA Syncer <=
- [nongnu] elpa/yaml-mode 97d507f 048/124: Derive from text-mode, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode f49fb81 123/124: Add magic-mode-list entry, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode 6555018 003/124: Merged branch(TEST-MARSHALL-PATCH@17) to trunk, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode 4ce371e 013/124: Removed version from README., ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode 1fa61ec 016/124: Fixed bug for tabified indent., ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode b751113 021/124: Merge pull request #5 from sugyan/master, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode c2ac933 023/124: changed version, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode b15a8ff 028/124: fix anchor name can contain '_', ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode 67b8355 042/124: Merge pull request #21 from wentasah/fill-paragraph, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode 2941501 043/124: Merge pull request #29 from tarsius/font-lock-ensure, ELPA Syncer, 2021/08/29