feature/file-templates: rewrite & fix wrong-number-of-args errors #602

This commit is contained in:
Henrik Lissner 2018-05-24 22:20:45 +02:00
parent 4c73ac0111
commit b806ff937c
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 113 additions and 114 deletions

View file

@ -66,8 +66,12 @@ evil is loaded and enabled)."
;;;###autoload
(defun +file-templates-get-short-path ()
"Fetches a short file path for the header in Doom module templates."
(when (string-match "/modules/\\(.+\\)$" buffer-file-truename)
(match-string 1 buffer-file-truename)))
(let ((path (file-truename (or buffer-file-name default-directory))))
(cond ((string-match "/modules/\\(.+\\)$" path)
(match-string 1 path))
((file-in-directory-p path doom-emacs-dir)
(file-relative-name path doom-emacs-dir))
((abbreviate-file-name path)))))
;;