-
Notifications
You must be signed in to change notification settings - Fork 310
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
yas-maybe-load-snippet-buffer moves point every time I save a snippet #1146
Comments
(add-hook 'snippet-mode-hook (lambda ()
(make-local-variable 'after-save-hook)
(setq after-save-hook nil))) Try this. |
Could you try the patch below:
```
diff --git a/yasnippet.el b/yasnippet.el
index 782c440588..3f007daa84 100644
--- a/yasnippet.el
+++ b/yasnippet.el
@@ -2784,18 +2784,20 @@
(defun yas-maybe-load-snippet-buffer ()
"Added to `after-save-hook' in `snippet-mode'."
+ (save-excursion ;; Issue #1146. Here or in `yas--parse-template`?
(let* ((mode (intern (file-name-sans-extension
(file-name-nondirectory
(directory-file-name default-directory)))))
(current-snippet
(apply #'yas--define-snippets-2 (yas--table-get-create mode)
+ ;; FIXME: `yas-load-snippet-buffer' will *re*parse!
(yas--parse-template buffer-file-name)))
(uuid (yas--template-uuid current-snippet)))
(unless (equal current-snippet
(if uuid (yas--get-template-by-uuid mode uuid)
(yas--lookup-snippet-1
(yas--template-name current-snippet) mode)))
- (yas-load-snippet-buffer mode t))))
+ (yas-load-snippet-buffer mode t)))))
(defun yas-load-snippet-buffer-and-close (table &optional kill)
"Load and save the snippet, then `quit-window' if saved.
```
|
Thanks :) |
monnier
added a commit
that referenced
this issue
Jan 12, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm running this command:
The
foo
file looks like this:Whenever I modify the file and save it, no matter where point is it always jumps back to
(point-min)
. I usedprofiler-start
/profiler-report
to track this down to a call toyas-maybe-load-snippet-buffer
which is run as a hook on save.Is this the intended behavior? If so, is there a way to change it? I'm on Emacs 28.2 on macOS.
The text was updated successfully, but these errors were encountered: