Add defuns-auto-insert.el
This commit is contained in:
parent
03c6c05677
commit
0dc0c1db8d
1 changed files with 21 additions and 0 deletions
21
core/lib/defuns-auto-insert.el
Normal file
21
core/lib/defuns-auto-insert.el
Normal file
|
@ -0,0 +1,21 @@
|
|||
;;; defuns-auto-insert.el
|
||||
;; for ../core-auto-insert.el
|
||||
|
||||
;;;###autoload
|
||||
(defun narf/auto-insert-snippet (key &optional mode project-only)
|
||||
"Auto insert a snippet of yasnippet into new file."
|
||||
(interactive)
|
||||
(when (if project-only (narf/project-p) t)
|
||||
(let ((is-yasnippet-on (not (cond ((functionp yas-dont-activate)
|
||||
(funcall yas-dont-activate))
|
||||
((consp yas-dont-activate)
|
||||
(some #'funcall yas-dont-activate))
|
||||
(yas-dont-activate))))
|
||||
(snippet (let ((template (cdar (mapcan #'(lambda (table) (yas--fetch table key))
|
||||
(yas--get-snippet-tables mode)))))
|
||||
(if template (yas--template-content template) nil))))
|
||||
(when (and is-yasnippet-on snippet)
|
||||
(yas-expand-snippet snippet)))))
|
||||
|
||||
(provide 'defuns-auto-insert)
|
||||
;;; defuns-auto-insert.el ends here
|
Loading…
Add table
Add a link
Reference in a new issue