wait till after content insertion to narrow

Fixes #404 without inhibiting change hooks.
This commit is contained in:
Noam Postavsky 2013-10-14 09:57:41 -04:00
parent 6997922011
commit 51e9e8e53c

View File

@ -3511,22 +3511,20 @@ considered when expanding the snippet."
;; plain text will get recorded at the end.
;;
;; stacked expansion: also shoosh the overlay modification hooks
(save-restriction
(narrow-to-region start start)
(let ((buffer-undo-list t))
;; snippet creation might evaluate users elisp, which
;; might generate errors, so we have to be ready to catch
;; them mostly to make the undo information
;;
(setq yas--start-column (save-restriction (widen) (current-column)))
(setq yas--start-column (current-column))
(yas--inhibit-overlay-hooks
(setq snippet
(if expand-env
(eval `(let* ,expand-env
(insert content)
(yas--snippet-create (point-min))))
(yas--snippet-create start (point))))
(insert content)
(yas--snippet-create (point-min)))))))
(yas--snippet-create start (point))))))
;; stacked-expansion: This checks for stacked expansion, save the
;; `yas--previous-active-field' and advance its boundary.
@ -3604,10 +3602,12 @@ After revival, push the `yas--take-care-of-redo' in the
(push `(apply yas--take-care-of-redo ,beg ,end ,snippet)
buffer-undo-list))))
(defun yas--snippet-create (begin)
"Create a snippet from a template inserted at BEGIN.
(defun yas--snippet-create (begin end)
"Create a snippet from a template inserted at BEGIN to END.
Returns the newly created snippet."
(save-restriction
(narrow-to-region begin end)
(let ((snippet (yas--make-snippet)))
(goto-char begin)
(yas--snippet-parse-create snippet)
@ -3622,7 +3622,7 @@ Returns the newly created snippet."
;; Move to end
(goto-char (point-max))
snippet))
snippet)))
;;; Apropos adjacencies and "fom's":