summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.emacs.d/lisp/yaml-mode.el38
1 files changed, 23 insertions, 15 deletions
diff --git a/.emacs.d/lisp/yaml-mode.el b/.emacs.d/lisp/yaml-mode.el
index 7adb17f..66e41b3 100644
--- a/.emacs.d/lisp/yaml-mode.el
+++ b/.emacs.d/lisp/yaml-mode.el
@@ -4,7 +4,7 @@
4 4
5;; Author: Yoshiki Kurihara <clouder@gmail.com> 5;; Author: Yoshiki Kurihara <clouder@gmail.com>
6;; Marshall T. Vandegrift <llasram@gmail.com> 6;; Marshall T. Vandegrift <llasram@gmail.com>
7;; Maintainer: Vasilij Schneidermann <v.schneidermann@gmail.com> 7;; Maintainer: Vasilij Schneidermann <mail@vasilij.de>
8;; Package-Requires: ((emacs "24.1")) 8;; Package-Requires: ((emacs "24.1"))
9;; Keywords: data yaml 9;; Keywords: data yaml
10;; Version: 0.0.14 10;; Version: 0.0.14
@@ -258,25 +258,33 @@ that key is pressed to begin a block literal."
258 (put-text-property (point) (1+ (point)) 258 (put-text-property (point) (1+ (point))
259 'syntax-table (string-to-syntax "_")))))) 259 'syntax-table (string-to-syntax "_"))))))
260 260
261 ;; If quote is detected as a syntactic string start but appeared
262 ;; after a non-whitespace character, then mark it as syntactic word.
263 (save-excursion 261 (save-excursion
264 (goto-char beg) 262 (goto-char beg)
265 (while (re-search-forward "['\"]" end t) 263 (while (and
264 (> end (point))
265 (re-search-forward "['\"]" end t))
266 (when (get-text-property (point) 'yaml-block-literal) 266 (when (get-text-property (point) 'yaml-block-literal)
267 (put-text-property (1- (point)) (point) 267 (put-text-property (1- (point)) (point)
268 'syntax-table (string-to-syntax "w"))) 268 'syntax-table (string-to-syntax "w")))
269 (when (nth 8 (syntax-ppss)) 269 (let* ((pt (point))
270 (save-excursion 270 (sps (save-excursion (syntax-ppss (1- pt)))))
271 (forward-char -1) 271 (when (not (nth 8 sps))
272 (cond ((and (char-equal ?' (char-before (point))) 272 (cond
273 (char-equal ?' (char-after (point))) 273 ((and (char-equal ?' (char-before (1- pt)))
274 (put-text-property (1- (point)) (1+ (point)) 274 (char-equal ?' (char-before pt)))
275 'syntax-table (string-to-syntax "w")))) 275 (put-text-property (- pt 2) pt
276 ((and (not (bolp)) 276 'syntax-table (string-to-syntax "w")))
277 (char-equal ?w (char-syntax (char-before (point))))) 277 ;; If quote is detected as a syntactic string start but appeared
278 (put-text-property (point) (1+ (point)) 278 ;; after a non-whitespace character, then mark it as syntactic word.
279 'syntax-table (string-to-syntax "w"))))))))) 279 ((and (char-before (1- pt))
280 (char-equal ?w (char-syntax (char-before (1- pt)))))
281 (put-text-property (1- pt) pt
282 'syntax-table (string-to-syntax "w")))
283 (t
284 ;; We're right after a quote that opens a string literal.
285 ;; Skip over it (big speedup for long JSON strings).
286 (goto-char (1- pt))
287 (ignore-errors (forward-sexp)))))))))
280 288
281(defun yaml-font-lock-block-literals (bound) 289(defun yaml-font-lock-block-literals (bound)
282 "Find lines within block literals. 290 "Find lines within block literals.