Fix debug helper for format!

Throwing format errors when there are no arguments.

Also makes relpath a little more lenient about nil/empty input.
This commit is contained in:
Henrik Lissner 2019-07-27 17:05:17 +02:00
parent 402260f154
commit a441435f3e
No known key found for this signature in database
GPG Key ID: 5F6C0EA160557395

View File

@ -50,15 +50,24 @@ and `format!' into colored output, where COLOR is any car of this list.")
(concat "- " (if args (apply #'format str args) str))))
(start . (lambda (str &rest args)
(concat "> " (if args (apply #'format str args) str))))
(debug . (lambda (str &rest args) (if doom-debug-mode (apply #'format str args) "")))
(debug . (lambda (str &rest args)
(if doom-debug-mode
(if args
(apply #'format str args)
(format "%s" str))
"")))
(path . abbreviate-file-name)
(symbol . symbol-name)
(relpath . (lambda (str &optional dir)
(let ((dir (or dir (file-truename default-directory)))
(str (file-truename str)))
(if (file-in-directory-p str dir)
(file-relative-name str dir)
(abbreviate-file-name str)))))
(if (or (not str)
(not (stringp str))
(string-empty-p str))
str
(let ((dir (or dir (file-truename default-directory)))
(str (file-truename str)))
(if (file-in-directory-p str dir)
(file-relative-name str dir)
(abbreviate-file-name str))))))
(filename . file-name-nondirectory)
(dirname . (lambda (path)
(unless (file-directory-p path)