ui/doom-dashboard: fix pwd not always being set #309

This commit is contained in:
Henrik Lissner 2017-12-28 19:59:32 -05:00
parent 58b2605215
commit 7ea3895b99
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -116,12 +116,11 @@ whose dimensions may not be fully initialized by the time this is run."
(concat (make-string (ceiling (max 0 (- len (length s))) 2) ? ) (concat (make-string (ceiling (max 0 (- len (length s))) 2) ? )
s)) s))
(defun +doom-dashboard--get-pwd (dir) (defun +doom-dashboard--get-pwd ()
(let ((lastcwd +doom-dashboard--last-cwd) (let ((lastcwd +doom-dashboard--last-cwd)
(policy +doom-dashboard-pwd-policy)) (policy +doom-dashboard-pwd-policy))
(cond ((null policy) (cond ((null policy)
default-directory) default-directory)
(dir dir)
((null lastcwd) ((null lastcwd)
default-directory) default-directory)
((eq policy 'last-project) ((eq policy 'last-project)
@ -140,20 +139,22 @@ whose dimensions may not be fully initialized by the time this is run."
(warn "`+doom-dashboard-pwd-policy' has an invalid value of '%s'" (warn "`+doom-dashboard-pwd-policy' has an invalid value of '%s'"
+doom-dashboard-pwd-policy))))) +doom-dashboard-pwd-policy)))))
(defun +doom-dashboard-reload (&optional dir) (defun +doom-dashboard-reload (&optional force)
"Update the DOOM scratch buffer (or create it, if it doesn't exist)." "Update the DOOM scratch buffer (or create it, if it doesn't exist)."
(when (get-buffer-window (doom-fallback-buffer))
(unless (or +doom-dashboard-inhibit-refresh
(window-minibuffer-p (frame-selected-window)))
(let ((fallback-buffer (doom-fallback-buffer))) (let ((fallback-buffer (doom-fallback-buffer)))
(when (or force
(and (get-buffer-window fallback-buffer)
(not (window-minibuffer-p (frame-selected-window)))))
(with-current-buffer fallback-buffer (with-current-buffer fallback-buffer
(setq default-directory
(or (+doom-dashboard--get-pwd)
default-directory)))
(unless +doom-dashboard-inhibit-refresh
(with-silent-modifications (with-silent-modifications
(unless (eq major-mode '+doom-dashboard-mode) (unless (eq major-mode '+doom-dashboard-mode)
(+doom-dashboard-mode)) (+doom-dashboard-mode))
(erase-buffer) (erase-buffer)
(setq default-directory
(or (+doom-dashboard--get-pwd dir)
default-directory))
(let ((+doom-dashboard--height (window-height (get-buffer-window fallback-buffer))) (let ((+doom-dashboard--height (window-height (get-buffer-window fallback-buffer)))
(lines 1) (lines 1)
content) content)
@ -168,7 +169,7 @@ whose dimensions may not be fully initialized by the time this is run."
?\n) ?\n)
content)) content))
(unless (button-at (point)) (unless (button-at (point))
(goto-char (next-button (point-min)))))))) (goto-char (next-button (point-min)))))))
;; Update all dashboard windows ;; Update all dashboard windows
(dolist (win (get-buffer-window-list (doom-fallback-buffer) nil t)) (dolist (win (get-buffer-window-list (doom-fallback-buffer) nil t))
(set-window-fringes win 0 0) (set-window-fringes win 0 0)