Refactor feature/file-templates

This removes its dependency on the feature/snippets.
This commit is contained in:
Henrik Lissner 2018-06-03 23:43:27 +02:00
parent cd0e9826ac
commit 818cb27724
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
3 changed files with 22 additions and 13 deletions

View file

@ -73,6 +73,17 @@ evil is loaded and enabled)."
(file-relative-name path doom-emacs-dir))
((abbreviate-file-name path)))))
;;;###autoload
(defun +file-template-p (rule)
"Return t if RULE applies to the current buffer."
(let ((pred (car rule))
(plist (cdr rule)))
(and (cond ((and (stringp pred) buffer-file-name) (string-match-p pred buffer-file-name))
((symbolp pred) (eq major-mode pred)))
(or (not (plist-member plist :when))
(funcall (plist-get plist :when) buffer-file-name))
rule)))
;;
;; Commands