mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-11 13:07:28 -05:00
Add defuns-auto-insert.el
This commit is contained in:
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
|
Reference in New Issue
Block a user