Have :P modifier throw error when not in a project

If it returns nil, it will throw a stringp error otherwise.
This commit is contained in:
Henrik Lissner 2018-10-19 23:27:58 -04:00
parent ab95ae1975
commit 54749d04e6
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -133,8 +133,11 @@ more information on modifiers."
(unless global 1))))
path))
("P"
(let ((default-directory (file-name-directory (expand-file-name path))))
(abbreviate-file-name (doom-project-root))))
(let* ((default-directory (file-name-directory (expand-file-name path)))
(project-root (doom-project-root)))
(unless project-root
(user-error "Not in a project"))
(abbreviate-file-name project-root)))
(_ path))
"")))
;; strip trailing slash, if applicable