Skip to content

Instantly share code, notes, and snippets.

@jrnold
Created November 13, 2010 19:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrnold/675584 to your computer and use it in GitHub Desktop.
Save jrnold/675584 to your computer and use it in GitHub Desktop.
Use yasnippet templates with aut-insert-mode in emacs
(defun yas/expand-by-uuid (mode uuid)
"Exapnd snippet template in MODE by its UUID"
(yas/expand-snippet
(yas/template-content
(yas/get-template-by-uuid mode uuid))))
;; Yasnippet templates used in auto-insert mode
(require 'autoinsert)
(auto-insert-mode)
(setq auto-insert-query nil)
(define-auto-insert "\.R"
'(lambda () (yas/expand-by-uuid 'ess-mode "header")))
;; Also see help for variable auto-insert-alist
@howardabrams
Copy link

Which the newest version of yasnippets, the initial function should be:

 (defun yas--expand-by-uuid (mode uuid)
   "Exapnd snippet template in MODE by its UUID"
   (yas-expand-snippet
    (yas--template-content
     (yas--get-template-by-uuid mode uuid))))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment