Last active
July 26, 2023 19:25
-
-
Save Tokubara/66908d6ec26c0f6fba3a24952b066aee to your computer and use it in GitHub Desktop.
emacs yasnippet nested snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun my/get-yasnippet-content-by-name(snippet-name &optional mode) | |
(yas--template-content (yas--get-template-by-uuid (yas--table-get-create (or mode major-mode) ) snippet-name))) | |
(defun my/get-yasnippet-expansion-by-name(snippet-name &optional mode) | |
(let ((mode (or mode major-mode)) start-point snippet-expansion) | |
(save-excursion | |
;; (funcall mode) | |
(unless yas-minor-mode (yas-minor-mode)) | |
(goto-char (point-max)) | |
(insert "\n") | |
(setq start-point (point)) | |
(yas-expand-snippet (my/get-yasnippet-content-by-name snippet-name mode)) | |
(setq snippet-expansion (buffer-substring-no-properties start-point (point-max))) | |
(delete-region start-point (point))) | |
snippet-expansion | |
)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
`(my/get-yasnippet-expansion-by-name "CHECK_macro")` | |
`(my/get-yasnippet-expansion-by-name "CHECK_macro" 'cuda-mode)` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment