ui/doom-dashboard: fix pwd not always being set #309
This commit is contained in:
parent
58b2605215
commit
7ea3895b99
1 changed files with 31 additions and 30 deletions
|
@ -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,35 +139,37 @@ 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))
|
(let ((fallback-buffer (doom-fallback-buffer)))
|
||||||
(unless (or +doom-dashboard-inhibit-refresh
|
(when (or force
|
||||||
(window-minibuffer-p (frame-selected-window)))
|
(and (get-buffer-window fallback-buffer)
|
||||||
(let ((fallback-buffer (doom-fallback-buffer)))
|
(not (window-minibuffer-p (frame-selected-window)))))
|
||||||
(with-current-buffer fallback-buffer
|
(with-current-buffer fallback-buffer
|
||||||
(with-silent-modifications
|
(setq default-directory
|
||||||
(unless (eq major-mode '+doom-dashboard-mode)
|
(or (+doom-dashboard--get-pwd)
|
||||||
(+doom-dashboard-mode))
|
default-directory)))
|
||||||
(erase-buffer)
|
(unless +doom-dashboard-inhibit-refresh
|
||||||
(setq default-directory
|
(with-silent-modifications
|
||||||
(or (+doom-dashboard--get-pwd dir)
|
(unless (eq major-mode '+doom-dashboard-mode)
|
||||||
default-directory))
|
(+doom-dashboard-mode))
|
||||||
(let ((+doom-dashboard--height (window-height (get-buffer-window fallback-buffer)))
|
(erase-buffer)
|
||||||
(lines 1)
|
|
||||||
content)
|
(let ((+doom-dashboard--height (window-height (get-buffer-window fallback-buffer)))
|
||||||
(with-temp-buffer
|
(lines 1)
|
||||||
(dolist (widget-name +doom-dashboard-widgets)
|
content)
|
||||||
(funcall (intern (format "doom-dashboard-widget--%s" widget-name)))
|
(with-temp-buffer
|
||||||
(insert "\n"))
|
(dolist (widget-name +doom-dashboard-widgets)
|
||||||
(setq content (buffer-string)
|
(funcall (intern (format "doom-dashboard-widget--%s" widget-name)))
|
||||||
lines (count-lines (point-min) (point-max))))
|
(insert "\n"))
|
||||||
(insert (make-string (max 0 (- (/ +doom-dashboard--height 2)
|
(setq content (buffer-string)
|
||||||
(/ lines 2)))
|
lines (count-lines (point-min) (point-max))))
|
||||||
?\n)
|
(insert (make-string (max 0 (- (/ +doom-dashboard--height 2)
|
||||||
content))
|
(/ lines 2)))
|
||||||
(unless (button-at (point))
|
?\n)
|
||||||
(goto-char (next-button (point-min))))))))
|
content))
|
||||||
|
(unless (button-at (point))
|
||||||
|
(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)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue