mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-13 21:13:04 +00:00
yasnippet.el (yas-maybe-load-snippet-buffer): Don't move point (#1146)
This commit is contained in:
parent
fe1f4e0e96
commit
37d0b2790f
28
yasnippet.el
28
yasnippet.el
@ -1,6 +1,6 @@
|
||||
;;; yasnippet.el --- Yet another snippet extension for Emacs -*- lexical-binding: t; -*-
|
||||
|
||||
;; Copyright (C) 2008-2024 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 2008-2025 Free Software Foundation, Inc.
|
||||
;; Authors: pluskid <pluskid@gmail.com>,
|
||||
;; João Távora <joaotavora@gmail.com>,
|
||||
;; Noam Postavsky <npostavs@gmail.com>
|
||||
@ -2784,18 +2784,20 @@ Return the `yas--template' object created"
|
||||
|
||||
(defun yas-maybe-load-snippet-buffer ()
|
||||
"Added to `after-save-hook' in `snippet-mode'."
|
||||
(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)
|
||||
(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))))
|
||||
(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)))))
|
||||
|
||||
(defun yas-load-snippet-buffer-and-close (table &optional kill)
|
||||
"Load and save the snippet, then `quit-window' if saved.
|
||||
|
Loading…
x
Reference in New Issue
Block a user