mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-13 05:03:04 +00:00
Merge pull request #1149 from pestctrl/quit-undo-tree
Push modifications to buffer-undo-list, even if unwinding
This commit is contained in:
commit
fe1f4e0e96
67
yasnippet.el
67
yasnippet.el
@ -4128,39 +4128,40 @@ Returns the newly created snippet."
|
||||
(yas--letenv expand-env
|
||||
;; Put a single undo action for the expanded snippet's
|
||||
;; content.
|
||||
(let ((buffer-undo-list t))
|
||||
(goto-char begin)
|
||||
(if (> emacs-major-version 29)
|
||||
;; Don't use the workaround for CC-mode's cache,
|
||||
;; since it was presumably a bug in CC-mode, so either
|
||||
;; it's fixed already, or it should get fixed.
|
||||
(progn
|
||||
(insert content)
|
||||
(narrow-to-region begin (point))
|
||||
(goto-char (point-min))
|
||||
(yas--snippet-parse-create snippet))
|
||||
;; Call before and after change functions manually,
|
||||
;; otherwise cc-mode's cache can get messed up. Don't use
|
||||
;; `inhibit-modification-hooks' for that, that blocks
|
||||
;; overlay and text property hooks as well! FIXME: Maybe
|
||||
;; use `combine-change-calls'? (Requires Emacs 27+ though.)
|
||||
(run-hook-with-args 'before-change-functions begin end)
|
||||
(let ((before-change-functions nil)
|
||||
(after-change-functions nil))
|
||||
;; Some versions of cc-mode (might be the one with Emacs
|
||||
;; 24.3 only) fail when inserting snippet content in a
|
||||
;; narrowed buffer, so make sure to insert before
|
||||
;; narrowing.
|
||||
(insert content)
|
||||
(narrow-to-region begin (point))
|
||||
(goto-char (point-min))
|
||||
(yas--snippet-parse-create snippet))
|
||||
(run-hook-with-args 'after-change-functions
|
||||
(point-min) (point-max)
|
||||
(- end begin))))
|
||||
(when (listp buffer-undo-list)
|
||||
(push (cons (point-min) (point-max))
|
||||
buffer-undo-list))
|
||||
(unwind-protect
|
||||
(let ((buffer-undo-list t))
|
||||
(goto-char begin)
|
||||
(if (> emacs-major-version 29)
|
||||
;; Don't use the workaround for CC-mode's cache,
|
||||
;; since it was presumably a bug in CC-mode, so either
|
||||
;; it's fixed already, or it should get fixed.
|
||||
(progn
|
||||
(insert content)
|
||||
(narrow-to-region begin (point))
|
||||
(goto-char (point-min))
|
||||
(yas--snippet-parse-create snippet))
|
||||
;; Call before and after change functions manually,
|
||||
;; otherwise cc-mode's cache can get messed up. Don't use
|
||||
;; `inhibit-modification-hooks' for that, that blocks
|
||||
;; overlay and text property hooks as well! FIXME: Maybe
|
||||
;; use `combine-change-calls'? (Requires Emacs 27+ though.)
|
||||
(run-hook-with-args 'before-change-functions begin end)
|
||||
(let ((before-change-functions nil)
|
||||
(after-change-functions nil))
|
||||
;; Some versions of cc-mode (might be the one with Emacs
|
||||
;; 24.3 only) fail when inserting snippet content in a
|
||||
;; narrowed buffer, so make sure to insert before
|
||||
;; narrowing.
|
||||
(insert content)
|
||||
(narrow-to-region begin (point))
|
||||
(goto-char (point-min))
|
||||
(yas--snippet-parse-create snippet))
|
||||
(run-hook-with-args 'after-change-functions
|
||||
(point-min) (point-max)
|
||||
(- end begin))))
|
||||
(when (listp buffer-undo-list)
|
||||
(push (cons (point-min) (point-max))
|
||||
buffer-undo-list)))
|
||||
|
||||
;; Indent, collecting undo information normally.
|
||||
(yas--indent snippet)
|
||||
|
Loading…
x
Reference in New Issue
Block a user