Skip to content
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

Function to load snippets without confirmation #1202

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions yasnippet.el
Original file line number Diff line number Diff line change
Expand Up @@ -2824,6 +2824,23 @@ and `kill-buffer' instead."
(save-buffer)))
(quit-window kill)))

(defun yas-load-snippet-buffer-and-close-noconfirm()
"Load and save the snippet buffer and quit the window
while selecting the default table, file path, and not prompting
the user to save the buffer"
(interactive)
(unless yas--guessed-modes
(setq-local yas--guessed-modes (yas--compute-major-mode-and-parents buffer-file-name)))
(let ((template (yas-load-snippet-buffer (cl-first yas--guessed-modes) t)))
(when (buffer-modified-p)
(let ((default-directory (cadar (yas--guess-snippet-directories
(yas--template-table template))))
(default-file-name (yas--template-name template)))
(setq buffer-file-name (concat default-directory default-file-name))
(rename-buffer default-file-name t)
(save-buffer)))
(quit-window t)))

(declare-function yas-debug-snippets "yasnippet-debug")

(defun yas-tryout-snippet (&optional debug)
Expand Down