-
Notifications
You must be signed in to change notification settings - Fork 314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
yasnippet modifies buffer while inhibit-modification-hooks is t #756
Comments
I think it's to avoid recursion. Possibly we should bind |
AFAICT, the Ironically, |
Ah. Probably only recording the changes in the after-change function and then performing them in the post command hook is the best solution then. |
Yes. You might not even need the modification-hook, to be honest -- you can use post-command-hook to check for the overlay. I've submitted a bug to Emacs also. (bug#25111). Let's wait till and see whether there is a better solution in the response to that; switching If not, I'll be happy to send a PR using |
It's mostly an optimization to avoid unneeded mirror updates, but I think modification-hook would still be necessary for the |
Turns out this breaks things, it's hard to say why exactly. Does the following work okay? (I tried installing lentic, but I couldn't figure out how to run the example) --- w/yasnippet.el
+++ i/yasnippet.el
@@ -3533,9 +3533,10 @@ (defun yas--on-field-overlay-modification (overlay after? beg end &optional leng
(unless (or (not after?)
yas--inhibit-overlay-hooks
(not (overlayp yas--active-field-overlay)) ; Avoid Emacs bug #21824.
(yas--undo-in-progress))
- (let* ((inhibit-modification-hooks t)
+ (let* ((inhibit-modification-hooks nil)
+ (yas--inhibit-overlay-hooks t)
(field (overlay-get overlay 'yas--field))
(snippet (overlay-get yas--active-field-overlay 'yas--snippet)))
(save-match-data
(yas--letenv (yas--snippet-expand-env snippet) |
Apologies for the tardy reply. I missed the original notification.Yes, this patch does work. Sorry, you had problems with getting lentic to work. Easiest way is to open a buffer, and do M-x lentic-mode-create-new-view-in-selected-window. You get what looks like an indirect buffer with the same contents as the original file, but with different point and in which you can change mode freely. |
Thanks for confirming.
Ah thanks, I can reproduce the original bug with the old yasnippet version following this. |
The mechanism that yasnippet uses for changing fields means that it changes the buffer while
inhibit-modification-hooks
ist
, if I am reading the code correctly. This means that any other code which depends on these hooks to identify change fails. This happens in theyas--on-field-overlay-modification
function.As an example, it causes a bad interaction with lentic mode phillord/lentic#51.
I'm not sure what the obvious fix is -- probably using
post-command-hook
rather than "modification-hook" to trigger the changes,The text was updated successfully, but these errors were encountered: