From ff5a069cf024565751e4db4783c18e920994b211 Mon Sep 17 00:00:00 2001 From: Simeon Simeonov Date: Mon, 11 May 2020 08:56:54 +0200 Subject: Update yaml-mode --- .emacs.d/lisp/yaml-mode.el | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/.emacs.d/lisp/yaml-mode.el b/.emacs.d/lisp/yaml-mode.el index 9f76c38..66e41b3 100644 --- a/.emacs.d/lisp/yaml-mode.el +++ b/.emacs.d/lisp/yaml-mode.el @@ -4,10 +4,10 @@ ;; Author: Yoshiki Kurihara ;; Marshall T. Vandegrift -;; Maintainer: Vasilij Schneidermann +;; Maintainer: Vasilij Schneidermann ;; Package-Requires: ((emacs "24.1")) ;; Keywords: data yaml -;; Version: 0.0.13 +;; Version: 0.0.14 ;; This file is not part of Emacs @@ -117,7 +117,7 @@ that key is pressed to begin a block literal." ;; Constants -(defconst yaml-mode-version "0.0.13" "Version of `yaml-mode'.") +(defconst yaml-mode-version "0.0.14" "Version of `yaml-mode'.") (defconst yaml-blank-line-re "^ *$" "Regexp matching a line containing only (valid) whitespace.") @@ -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. @@ -286,7 +294,7 @@ line in the match data, as consumed by `font-lock-keywords' matcher functions. The function begins by searching backwards to determine whether or not the current line is within a block literal. This could be time-consuming in large buffers, so the number of lines searched is -artificially limitted to the value of +artificially limited to the value of `yaml-block-literal-search-lines'." (if (eolp) (goto-char (1+ (point)))) (unless (or (eobp) (>= (point) bound)) -- cgit v1.3