emacs-dashboard icon indicating copy to clipboard operation
emacs-dashboard copied to clipboard

Dashboard not opening in emacs29, as well as centering and gif

Open lafith opened this issue 1 year ago • 9 comments
trafficstars

In emacs 29.3 dashboard will open only after adding (dashboard-open) after config. Centering and gif works only after running M-x dashboard-refresh-buffer. Following is my config

(use-package dashboard
  :ensure t
  :config
  (dashboard-setup-startup-hook))

(setq dashboard-display-icons-p t)
(setq dashboard-icon-type 'nerd-icons)
(setq dashboard-set-heading-icons t)
(setq dashboard-set-file-icons t)
(setq dashboard-startup-banner  "~/cowboy.gif")
(setq dashboard-vertically-center-content t)
(setq dashboard-center-content t)
(setq dashboard-items '((recents   . 5)
                        (agenda    . 5)))
(setq dashboard-startupify-list '(dashboard-insert-banner
                                  dashboard-insert-newline
                                  dashboard-insert-banner-title
				   dashboard-insert-init-info
                                  dashboard-insert-newline
                                  dashboard-insert-items))
(dashboard-open)```

lafith avatar Aug 27 '24 17:08 lafith

Hi, your config looks good. I prefer to have all the setq in the custom section of use-package and maybe set the initial buffer to call dashboard-open.

(use-package dashboard
  :ensure t
  :init
  (setq initial-buffer-choice 'dashboard-open)
  :config
  (dashboard-setup-startup-hook)
   :custom
  (dashboard-display-icons-p t)
  (dashboard-icon-type 'nerd-icons)
  (dashboard-set-heading-icons t)
  (dashboard-set-file-icons t)
  (dashboard-startup-banner  "~/cowboy.gif")
  (dashboard-vertically-center-content t)
  (dashboard-center-content t)
  (dashboard-items '((recents   . 5)
                     (agenda    . 5)))
  (dashboard-startupify-list '(dashboard-insert-banner
                     dashboard-insert-newline
                     dashboard-insert-banner-title
                     dashboard-insert-init-info
                     dashboard-insert-newline
                     dashboard-insert-items)))

Could you try the above config and let me know if it works?

ricardoricho avatar Aug 28 '24 09:08 ricardoricho

Above fixed startup buffer choice and gif playing. Centering content still not working. I have to either run dashboard-open or dashboard-refresh-buffer.

I removed rest of my init.el, it still not centering without refreshing the buffer.

  ;; package manager
(defvar bootstrap-version)
(let ((bootstrap-file
       (expand-file-name
        "straight/repos/straight.el/bootstrap.el"
        (or (bound-and-true-p straight-base-dir)
            user-emacs-directory)))
      (bootstrap-version 7))
  (unless (file-exists-p bootstrap-file)
    (with-current-buffer
        (url-retrieve-synchronously
         "https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
         'silent 'inhibit-cookies)
      (goto-char (point-max))
      (eval-print-last-sexp)))
  (load bootstrap-file nil 'nomessage))

;; tidier package configuration
(straight-use-package 'use-package)
;; make straight.el as use-package's default package manger
(setq straight-use-package-by-default t)
(setq use-package-always-defer t)

(use-package dashboard
  :ensure t
  :init
  (setq initial-buffer-choice 'dashboard-open)
  :config
  (dashboard-setup-startup-hook)
  :custom
  (dashboard-vertically-center-content t)
  (dashboard-center-content t))

lafith avatar Aug 29 '24 02:08 lafith

Hi, if you're using straight I believe there are some issues when using :ensure t better use :demand t just to be sure that the package is loaded from straight and not from the package.el.

Looking at the code that center vertically the content of dashboard, window-absolute-pixel-position needs that the point it receives to be visible, so (point-min) and (point-max) should be visible, so perhaps we are trying to center the content before it is visible.

Could you add some (message "Center dashboard %s" (window-absolute-pixel-position (point-min))) just before the when-let* to check if the points (min and max) are visible?

ricardoricho avatar Sep 04 '24 08:09 ricardoricho

Following is the output from *Messages* buffer:

Loading /home/lfz/.config/emacs/recentf...done
Cleaning up the recentf list...done (0 removed)
[yas] Prepared just-in-time loading of snippets successfully.
Center dashboard (159 . 118)
For information about GNU Emacs and the GNU system, type C-h C-a.
Center dashboard (159 . 118)
ad-handle-definition: ‘text-scale-increase’ got redefined

lafith avatar Sep 05 '24 08:09 lafith

Ok, thanks. I played a little with the code and I got the feeling that some point is not visible when we are trying to center the buffer. Here is a better message so we can have more information:

(message "Dashboard center:\n min-point: %s\n max-point: %s\n position: %s\n min: %s\n max: %s"
             (point-min)
             (point-max)
             (point)
             (window-absolute-pixel-position (point-min))
             (window-absolute-pixel-position (point-max)))

I'm doubting about using the window-absolute-pixel-position functions, maybe there is a better way. A possible solution is to ensure points are visible by displaying the buffer before center, that is done by adding (display-buffer (current-buffer)) on the same line as the message.

ricardoricho avatar Sep 06 '24 09:09 ricardoricho

Following is the output after using the new message:

 min-point: 1
 max-point: 399
 position: 399
 min: (196 . 144)
 max: nil

When I am adding (display-buffer (current-buffer)) before the message two dashboard buffers are opening on startup.

Cleaning up the recentf list...done (0 removed)
[yas] Prepared just-in-time loading of snippets successfully.
Dashboard center:
 min-point: 1
 max-point: 354
 position: 354
 min: (196 . 144)
 max: nil
For information about GNU Emacs and the GNU system, type C-h C-a.
Dashboard center:
 min-point: 1
 max-point: 365
 position: 365
 min: (196 . 144)
 max: nil
ad-handle-definition: ‘text-scale-increase’ got redefined

lafith avatar Sep 06 '24 09:09 lafith

Ok, so display-buffer is not a solution. The issue is that (window-absolute-pixel-position (point-max)) is nil meaning the (point-max) is not visible, but (point-max) is only 365, it should fit in the window, and that's why it works on refresh.

I'll keep looking if there are some functions that could help, maybe doing something with window-start or window-end

ricardoricho avatar Sep 06 '24 09:09 ricardoricho

Same issue. Workaround:

:init
(add-hook 'window-setup-hook (lambda () (dashboard-refresh-buffer)))

RadioNoiseE avatar Sep 27 '24 11:09 RadioNoiseE

Got the same issue. Unfortunately the workaround doesn't work for me. Did you find a way to make it work?

ipocentro87 avatar Mar 12 '25 10:03 ipocentro87

I have a similar issue and noticed a difference between emacs normal and emacs client:

  • If I start emacs normally (emacs in the terminal), then everything works great.
  • If I start emacs as a client (emacsclient -c -a="" in the terminal), then dashboard will start without icons and only show them after M-x dashboard-refresh-buffer or M-x revert-buffer.

The workaround is not working for me unfortunately.

YueRen avatar Aug 01 '25 18:08 YueRen

Working correctly after building Emacs from source (version 30.1).

lafith avatar Aug 02 '25 05:08 lafith