[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 3129040 24/40: Load snippet after saving
From: |
Noam Postavsky |
Subject: |
[elpa] master 3129040 24/40: Load snippet after saving |
Date: |
Wed, 26 Oct 2016 23:06:33 +0000 (UTC) |
branch: master
commit 3129040fe362a6896a3d4665778728e13cd8fbfd
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>
Load snippet after saving
* yasnippet.el (yas-maybe-load-snippet-buffer): New function.
(snippet-mode): Add it to `after-save-hook'.
---
yasnippet.el | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/yasnippet.el b/yasnippet.el
index 33a635b..d7e780b 100644
--- a/yasnippet.el
+++ b/yasnippet.el
@@ -929,7 +929,8 @@ Honour `yas-dont-activate-functions', which see."
(setq font-lock-defaults '(yas--font-lock-keywords))
(set (make-local-variable 'require-final-newline) nil)
(set (make-local-variable 'comment-start) "#")
- (set (make-local-variable 'comment-start-skip) "#+[\t ]*"))
+ (set (make-local-variable 'comment-start-skip) "#+[\t ]*")
+ (add-hook 'after-save-hook #'yas-maybe-load-snippet-buffer nil t))
@@ -2576,6 +2577,21 @@ Return the `yas--template' object created"
(yas--table-name (yas--template-table
yas--editing-template))))
yas--editing-template)
+(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))))
+
(defun yas-load-snippet-buffer-and-close (table &optional kill)
"Load and save the snippet, then `quit-window' if saved.
Loading is performed by `yas-load-snippet-buffer'. If the
- [elpa] master 5af9276 27/40: Support yas/ symbols in yas-define-menu, (continued)
- [elpa] master 5af9276 27/40: Support yas/ symbols in yas-define-menu, Noam Postavsky, 2016/10/26
- [elpa] master ea9581f 22/40: Fix some quoting problems in doc strings, Noam Postavsky, 2016/10/26
- [elpa] master ee6e7a9 09/40: Fix some compilation warnings, Noam Postavsky, 2016/10/26
- [elpa] master 7661dc1 19/40: yasnippet.el (yas-escape-text): No error on nil text, Noam Postavsky, 2016/10/26
- [elpa] master 351c1e3 10/40: Don't indent first line of mirrors, Noam Postavsky, 2016/10/26
- [elpa] master 655bda8 07/40: Merge: restore backquote evaluation behaviour, Noam Postavsky, 2016/10/26
- [elpa] master 8907fd1 14/40: Escape yas-selected-text for new snippet., Noam Postavsky, 2016/10/26
- [elpa] master a4fafc3 16/40: Add test for loading snippet with same uuid, Noam Postavsky, 2016/10/26
- [elpa] master 8ca8c7d 13/40: Merge: a different fix for #712., Noam Postavsky, 2016/10/26
- [elpa] master 85a43ad 35/40: Explain about backquote expressions in doc, Noam Postavsky, 2016/10/26
- [elpa] master 3129040 24/40: Load snippet after saving,
Noam Postavsky <=
- [elpa] master 1532e66 33/40: Fix saving of new snippets, Noam Postavsky, 2016/10/26
- [elpa] master 0ee86a2 23/40: Simplify `yas-new-snippet' load&save logic, Noam Postavsky, 2016/10/26
- [elpa] master 00be21c 36/40: Change cl dep to cl-lib for tests too, Noam Postavsky, 2016/10/26
- [elpa] master 9c9952c 12/40: Add test for indentation of single line mirrors, Noam Postavsky, 2016/10/26
- [elpa] master 4296a86 15/40: yasnippet.el (yas--quote-string): Remove., Noam Postavsky, 2016/10/26
- [elpa] master d4da806 17/40: Fix removal of snippets by uuid, Noam Postavsky, 2016/10/26
- [elpa] master 42b0c26 18/40: Don't warn about modifications to other buffers, Noam Postavsky, 2016/10/26
- [elpa] master eaaec30 38/40: Replace all occurances of `capitaomorte', Noam Postavsky, 2016/10/26
- [elpa] master ff6f31e 37/40: Replace yas--with-temp-redefs with cl-letf, Noam Postavsky, 2016/10/26
- [elpa] master 244cdfa 26/40: Merge: Simplify `yas-new-snippet' load&save logic, Noam Postavsky, 2016/10/26