[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/yaml-mode ad8685c 104/124: yaml-mode-syntax-propertize-fun
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/yaml-mode ad8685c 104/124: yaml-mode-syntax-propertize-function: Speed up in large strings |
Date: |
Sun, 29 Aug 2021 11:36:22 -0400 (EDT) |
branch: elpa/yaml-mode
commit ad8685c24846ccde4f618589812d7324c0ac7210
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>
yaml-mode-syntax-propertize-function: Speed up in large strings
Fixes #75
---
yaml-mode.el | 33 +++++++++++++++++++++------------
1 file changed, 21 insertions(+), 12 deletions(-)
diff --git a/yaml-mode.el b/yaml-mode.el
index 7adb17f..5eaa51e 100644
--- a/yaml-mode.el
+++ b/yaml-mode.el
@@ -262,21 +262,30 @@ that key is pressed to begin a block literal."
;; 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 ((sps (syntax-ppss)))
+ (when (nth 8 sps)
+ (or
+ (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")))))
+ ;; We're right after a quote that opens a string literal.
+ ;; Skip over it (big speedup for long JSON strings).
+ (when (nth 3 sps)
+ (goto-char (nth 8 sps))
+ (ignore-errors (forward-sexp)))))))))
(defun yaml-font-lock-block-literals (bound)
"Find lines within block literals.
- [nongnu] elpa/yaml-mode 73951dd 055/124: added test files, (continued)
- [nongnu] elpa/yaml-mode 73951dd 055/124: added test files, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode 3362e1b 057/124: Merge pull request #33 from antalk2/antalk2-patch-1, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode 4966854 061/124: Merge pull request #36 from mmckinst/license, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode e73adce 069/124: Fix regex in autoload as well, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode c0d6da0 073/124: Merge pull request #42 from scop/spelling, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode b03fba2 074/124: Merge pull request #43 from scop/raml, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode 93252a0 076/124: Change dashes from word to symbol syntax, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode 64b2891 083/124: Merge pull request #47 from Wilfred/references_as_punctuation, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode 700dfda 093/124: Use block literal font-lock first, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode 5b4a0db 098/124: Bump version, summarize changes, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode ad8685c 104/124: yaml-mode-syntax-propertize-function: Speed up in large strings,
ELPA Syncer <=
- [nongnu] elpa/yaml-mode 0b33131 115/124: Merge pull request #78 from dgutov/spf-correctness, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode 04c30ea 119/124: Fix propertization for lists of dicts with literal block, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode 63b637f 124/124: Merge pull request #88 from scop/feature/magic-mode-alist, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode 0709258 005/124: Added dist to `Changes', ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode 4377ee5 009/124: Apply patch from k-nagano, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode b738999 010/124: changed version, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode 522d464 022/124: added changes, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode 1a779ba 029/124: Merge pull request #8 from holymonson/master, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode 059c255 030/124: Merge branch 'master' of github.com:yoshiki/yaml-mode, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode 9e07024 032/124: Changed version to 0.0.9, ELPA Syncer, 2021/08/29