[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/yasnippet 1cc1996 5/8: Don't bind inhibit-modification-
From: |
Stefan Monnier |
Subject: |
[elpa] externals/yasnippet 1cc1996 5/8: Don't bind inhibit-modification-hooks in yas--snippet-create |
Date: |
Mon, 15 Mar 2021 22:25:53 -0400 (EDT) |
branch: externals/yasnippet
commit 1cc1996074bdd8fa4e94a51171f5f4ae35f6600b
Author: Noam Postavsky <npostavs@users.sourceforge.net>
Commit: Noam Postavsky <npostavs@users.sourceforge.net>
Don't bind inhibit-modification-hooks in yas--snippet-create
* yasnippet.el (yas--snippet-create): Bind before-change-functions and
after-change-functions to nil instead of inhibit-modification-hooks to
t while expanding snippet. The latter also needlessly blocks overlay
and text property modification hooks (which we don't call ourselves
afterwards). This way we allow packages like iedit to better
co-operate with yasnippet.
---
yasnippet.el | 33 +++++++++++++++++++--------------
1 file changed, 19 insertions(+), 14 deletions(-)
diff --git a/yasnippet.el b/yasnippet.el
index 8cb27ac..5b252a2 100644
--- a/yasnippet.el
+++ b/yasnippet.el
@@ -4168,21 +4168,26 @@ 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)
- (inhibit-modification-hooks t))
- ;; Some versions of cc-mode fail when inserting snippet
- ;; content in a narrowed buffer, so make sure to insert
- ;; before narrowing. Furthermore, call before and after
- ;; change functions manually, otherwise cc-mode's cache can
- ;; get messed up.
+ (let ((buffer-undo-list t))
(goto-char begin)
- (run-hook-with-args 'before-change-functions begin begin)
- (insert content)
- (setq end (+ end (length content)))
- (narrow-to-region begin end)
- (goto-char (point-min))
- (yas--snippet-parse-create snippet)
- (run-hook-with-args 'after-change-functions (point-min) (point-max)
0))
+ ;; 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 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)
+ (- (point-max) (point-min))))
(when (listp buffer-undo-list)
(push (cons (point-min) (point-max))
buffer-undo-list))
- [elpa] externals/yasnippet updated (3bf9a3b -> 5cbdbf0), Stefan Monnier, 2021/03/15
- [elpa] externals/yasnippet 5b1217a 6/8: ; Add some notes about narrowing, font-lock cc-mode issues, Stefan Monnier, 2021/03/15
- [elpa] externals/yasnippet 1cc1996 5/8: Don't bind inhibit-modification-hooks in yas--snippet-create,
Stefan Monnier <=
- [elpa] externals/yasnippet d3d6d70 7/8: Correct manual call to after-change-functions, Stefan Monnier, 2021/03/15
- [elpa] externals/yasnippet 291873e 4/8: ; .travis.yml: Clean up validator warnings/infos, Stefan Monnier, 2021/03/15
- [elpa] externals/yasnippet ac03c2f 1/8: ; Test on Emacs 27, Stefan Monnier, 2021/03/15
- [elpa] externals/yasnippet 170d13d 3/8: Scan nested fields properly, Stefan Monnier, 2021/03/15
- [elpa] externals/yasnippet 7c02bc1 2/8: Fix failure on depth 2+ nested snippets, Stefan Monnier, 2021/03/15
- [elpa] externals/yasnippet 5cbdbf0 8/8: Handle errors during evaluation properly, Stefan Monnier, 2021/03/15