ui/doom-dashboard: have 'last-project policy fall back to CWD

Normally, the dashboard assumes the default-directory = project root of
the last buffer you had open. This is to make it easy for you to recover
from closing the last buffer in your project and wondering how to get
back. However, if the last file wasn't in a valid project, the dashboard
assumes the directory of the last buffer that did, which can be jarring.

It will now assume the last buffer's CWD if it wasn't in a valid project
root.
This commit is contained in:
Henrik Lissner 2020-08-08 12:59:52 -04:00
parent 358ca9864b
commit de4532f979
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -34,11 +34,12 @@ dashboard reloading is inhibited.")
Possible values: Possible values:
'last-project the `doom-project-root' of the last open buffer 'last-project The `doom-project-root' of the last open buffer. Falls back
'last the `default-directory' of the last open buffer to `default-directory' if not in a project.
a FUNCTION a function run with the `default-directory' of the last 'last The `default-directory' of the last open buffer
a FUNCTION A function run with the `default-directory' of the last
open buffer, that returns a directory path open buffer, that returns a directory path
a STRING a fixed path a STRING A fixed path
nil `default-directory' will never change") nil `default-directory' will never change")
(defvar +doom-dashboard-menu-sections (defvar +doom-dashboard-menu-sections
@ -369,9 +370,8 @@ controlled by `+doom-dashboard-pwd-policy'."
((null lastcwd) ((null lastcwd)
default-directory) default-directory)
((eq policy 'last-project) ((eq policy 'last-project)
(let ((cwd default-directory)) (or (doom-project-root lastcwd)
(or (doom-project-root lastcwd) lastcwd))
cwd)))
((eq policy 'last) ((eq policy 'last)
lastcwd) lastcwd)
((warn "`+doom-dashboard-pwd-policy' has an invalid value of '%s'" ((warn "`+doom-dashboard-pwd-policy' has an invalid value of '%s'"