mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-13 21:13:04 +00:00
wait till after content insertion to narrow
Fixes #404 without inhibiting change hooks.
This commit is contained in:
parent
6997922011
commit
51e9e8e53c
58
yasnippet.el
58
yasnippet.el
@ -3511,22 +3511,20 @@ considered when expanding the snippet."
|
|||||||
;; plain text will get recorded at the end.
|
;; plain text will get recorded at the end.
|
||||||
;;
|
;;
|
||||||
;; stacked expansion: also shoosh the overlay modification hooks
|
;; stacked expansion: also shoosh the overlay modification hooks
|
||||||
(save-restriction
|
(let ((buffer-undo-list t))
|
||||||
(narrow-to-region start start)
|
;; snippet creation might evaluate users elisp, which
|
||||||
(let ((buffer-undo-list t))
|
;; might generate errors, so we have to be ready to catch
|
||||||
;; snippet creation might evaluate users elisp, which
|
;; them mostly to make the undo information
|
||||||
;; might generate errors, so we have to be ready to catch
|
;;
|
||||||
;; them mostly to make the undo information
|
(setq yas--start-column (current-column))
|
||||||
;;
|
(yas--inhibit-overlay-hooks
|
||||||
(setq yas--start-column (save-restriction (widen) (current-column)))
|
(setq snippet
|
||||||
(yas--inhibit-overlay-hooks
|
(if expand-env
|
||||||
(setq snippet
|
(eval `(let* ,expand-env
|
||||||
(if expand-env
|
(insert content)
|
||||||
(eval `(let* ,expand-env
|
(yas--snippet-create start (point))))
|
||||||
(insert content)
|
(insert content)
|
||||||
(yas--snippet-create (point-min))))
|
(yas--snippet-create start (point))))))
|
||||||
(insert content)
|
|
||||||
(yas--snippet-create (point-min)))))))
|
|
||||||
|
|
||||||
;; stacked-expansion: This checks for stacked expansion, save the
|
;; stacked-expansion: This checks for stacked expansion, save the
|
||||||
;; `yas--previous-active-field' and advance its boundary.
|
;; `yas--previous-active-field' and advance its boundary.
|
||||||
@ -3604,25 +3602,27 @@ After revival, push the `yas--take-care-of-redo' in the
|
|||||||
(push `(apply yas--take-care-of-redo ,beg ,end ,snippet)
|
(push `(apply yas--take-care-of-redo ,beg ,end ,snippet)
|
||||||
buffer-undo-list))))
|
buffer-undo-list))))
|
||||||
|
|
||||||
(defun yas--snippet-create (begin)
|
(defun yas--snippet-create (begin end)
|
||||||
"Create a snippet from a template inserted at BEGIN.
|
"Create a snippet from a template inserted at BEGIN to END.
|
||||||
|
|
||||||
Returns the newly created snippet."
|
Returns the newly created snippet."
|
||||||
(let ((snippet (yas--make-snippet)))
|
(save-restriction
|
||||||
(goto-char begin)
|
(narrow-to-region begin end)
|
||||||
(yas--snippet-parse-create snippet)
|
(let ((snippet (yas--make-snippet)))
|
||||||
|
(goto-char begin)
|
||||||
|
(yas--snippet-parse-create snippet)
|
||||||
|
|
||||||
;; Sort and link each field
|
;; Sort and link each field
|
||||||
(yas--snippet-sort-fields snippet)
|
(yas--snippet-sort-fields snippet)
|
||||||
|
|
||||||
;; Create keymap overlay for snippet
|
;; Create keymap overlay for snippet
|
||||||
(setf (yas--snippet-control-overlay snippet)
|
(setf (yas--snippet-control-overlay snippet)
|
||||||
(yas--make-control-overlay snippet (point-min) (point-max)))
|
(yas--make-control-overlay snippet (point-min) (point-max)))
|
||||||
|
|
||||||
;; Move to end
|
;; Move to end
|
||||||
(goto-char (point-max))
|
(goto-char (point-max))
|
||||||
|
|
||||||
snippet))
|
snippet)))
|
||||||
|
|
||||||
|
|
||||||
;;; Apropos adjacencies and "fom's":
|
;;; Apropos adjacencies and "fom's":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user