Restore syntax-propertize-function before indenting mirrors

* yasnippet.el (yas--snippet-parse-create): End binding of
syntax-propertize-function once snippet field parsing is finished.
This commit is contained in:
Noam Postavsky 2017-05-18 20:53:40 -04:00
parent 82818e5460
commit 1043b6c557

View File

@ -4025,45 +4025,30 @@ expansion.")
necessary fields, mirrors and exit points. necessary fields, mirrors and exit points.
Meant to be called in a narrowed buffer, does various passes" Meant to be called in a narrowed buffer, does various passes"
(let ((parse-start (point)) (let ((parse-start (point)))
;; Avoid major-mode's syntax propertizing function, since we ;; Avoid major-mode's syntax propertizing function, since we
;; change the syntax-table while calling `scan-sexps'. ;; change the syntax-table while calling `scan-sexps'.
(syntax-propertize-function nil)) (let ((syntax-propertize-function nil))
;; Reset the yas--dollar-regions (setq yas--dollar-regions nil) ; Reset the yas--dollar-regions.
;; (yas--protect-escapes nil '(?`)) ; Protect just the backquotes.
(setq yas--dollar-regions nil) (goto-char parse-start)
;; protect just the backquotes (yas--save-backquotes) ; Replace all backquoted expressions.
;; (yas--protect-escapes) ; Protect escaped characters.
(yas--protect-escapes nil '(?`)) (goto-char parse-start)
;; replace all backquoted expressions (yas--indent-parse-create) ; Parse indent markers: `$>'.
;; (goto-char parse-start)
(goto-char parse-start) (yas--field-parse-create snippet) ; Parse fields with {}.
(yas--save-backquotes) (goto-char parse-start)
;; protect escaped characters (yas--simple-mirror-parse-create snippet) ; Parse simple mirrors & fields.
;; (goto-char parse-start)
(yas--protect-escapes) (yas--transform-mirror-parse-create snippet) ; Parse mirror transforms.
;; Parse indent markers: `$>'. ;; Invalidate any syntax-propertizing done while
(goto-char parse-start) ;; `syntax-propertize-function' was nil.
(yas--indent-parse-create) (syntax-ppss-flush-cache parse-start))
;; parse fields with {} ;; Set "next" links of fields & mirrors.
;;
(goto-char parse-start)
(yas--field-parse-create snippet)
;; parse simple mirrors and fields
;;
(goto-char parse-start)
(yas--simple-mirror-parse-create snippet)
;; parse mirror transforms
;;
(goto-char parse-start)
(yas--transform-mirror-parse-create snippet)
;; calculate adjacencies of fields and mirrors
;;
(yas--calculate-adjacencies snippet) (yas--calculate-adjacencies snippet)
;; Delete $-constructs
;;
(save-restriction (save-restriction
(widen) (widen) ; Delete $-constructs.
(yas--delete-regions yas--dollar-regions)) (yas--delete-regions yas--dollar-regions))
;; Make sure to do this insertion *after* deleting the dollar ;; Make sure to do this insertion *after* deleting the dollar
;; regions, otherwise we invalidate the calculated positions of ;; regions, otherwise we invalidate the calculated positions of
@ -4078,23 +4063,12 @@ Meant to be called in a narrowed buffer, does various passes"
(get-register yas-wrap-around-region)) (get-register yas-wrap-around-region))
(insert (prog1 (get-register yas-wrap-around-region) (insert (prog1 (get-register yas-wrap-around-region)
(set-register yas-wrap-around-region nil))))) (set-register yas-wrap-around-region nil)))))
;; restore backquoted expression values (yas--restore-backquotes) ; Restore backquoted expression values.
;;
(yas--restore-backquotes)
;; restore escapes
;;
(goto-char parse-start) (goto-char parse-start)
(yas--restore-escapes) (yas--restore-escapes) ; Restore escapes.
;; update mirrors for the first time (yas--update-mirrors snippet) ; Update mirrors for the first time.
;; (goto-char parse-start))
(yas--update-mirrors snippet) (yas--indent snippet)) ; Indent the best we can.
;; indent the best we can
;;
(goto-char parse-start)
;; Invalidate any syntax-propertizing done while
;; `syntax-propertize-function' was nil.
(syntax-ppss-flush-cache parse-start))
(yas--indent snippet))
;; HACK: Some implementations of `indent-line-function' (called via ;; HACK: Some implementations of `indent-line-function' (called via
;; `indent-according-to-mode') delete text before they insert (like ;; `indent-according-to-mode') delete text before they insert (like