-
-
Notifications
You must be signed in to change notification settings - Fork 220
Add lem-dashboard
#1495
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add lem-dashboard
#1495
Conversation
Wow, it's super cool 🚀 LGTM (only a minor request with the defvar) |
user feedback:
last but not least:
|
accepted, thanks. I can see a short description with screenshot in the usage page, then link to a more detailed page of its own. Also, what about a |
That's great! It just seems a little buggy.
I was able to open the dashboard with M-x open-dashboard. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I commented on a few things that bothered me.
Nevertheless, I think this feature and implementation is excellent.
Thank you.
(move-to-line (buffer-point buffer) old-line) | ||
(move-to-column (buffer-point buffer) old-column))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was there a problem with save-excursion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It didn't work for me... I might be using it wrong. Here's the redraw function, works fine (keeps cursor position when resizing window)
(defun redraw-dashboard ()
(let* ((buffer (create-dashboard-buffer))
(old-line (line-number-at-point (buffer-point buffer)))
(old-column (point-column (buffer-point buffer))))
(with-buffer-read-only buffer nil
(erase-buffer buffer)
(let ((point (buffer-point buffer)))
(dolist (item *dashboard-layout*)
(draw-dashboard-item item point)))
(change-buffer-mode buffer 'dashboard-mode)
(move-to-line (buffer-point buffer) old-line)
(move-to-column (buffer-point buffer) old-column))))
Here's after changing it:
(defun redraw-dashboard ()
(let* ((buffer (create-dashboard-buffer)))
(save-excursion
(with-buffer-read-only buffer nil
(erase-buffer buffer)
(let ((point (buffer-point buffer)))
(dolist (item *dashboard-layout*)
(draw-dashboard-item item point)))
(change-buffer-mode buffer 'dashboard-mode)))))
After making that change, if I resize the window it'll reset it to the top. I tried using it in a few other spots and couldn't get it to work.
Bah my bad, I lost logic I had there in a commit I reverted. Thanks for pointing that out.
|
…rd command prefix, print blank project/file list, minor command/url fix)
(define-key *dashboard-mode-keymap* "s" 'open-lem-docs) | ||
(define-key *dashboard-mode-keymap* "g" 'open-lem-github)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just noticed this code, is there any reason why it is not defined at the top level?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way I had bindings previously worked a bit differently. The idea was to not apply the keybind until it's used in case the user has a dashboard that doesn't contain an item like the docs/github link. That being said, after changing the way the default dashboard is created, it doesn't work since it gets called at compile time, so further calls to set-default-dashboard
won't remove the stale binds.
I went ahead and moved it to the top-level, users can just replace the stale bind in their config if they want to bind something else there.
@cxxxr I see what vindarel was talking about with the default font making the ascii art look too big. I can try making it smaller. This is the smallest I think I can make it without it starting to look strange: Should I commit it? |
I think it's good |
User feedback:
|
Hmm I don't see that, I'm guessing I just happen to have the font it needs installed? Is there a way to detect if the font is available and then just not show it if it's not? I guess worst-case scenario I can omit icons if on ncurses.
Whoops, that's my bad. I tested in same folder so I missed that 😆 The |
alright the PR looks great to me and cxxxr approved the changes. @jfaz1 you're done, I/we merge? |
Looks good, so I'll merge it. |
This PR adds a customizable dashboard to lem, inspired by how distributions like doom/spacemacs/lazyvim ship out of the box. Besides a more friendly greeting than a
*tmp*
buffer, it ships with useful shortcuts like starting a lisp scratch or seeing recent files/projects at a glance.The dashboard is simply a list of
dashboard-item
s, of which a few are included by default, like a splash/footer message,commands/urls, working directory, and recent projects/files.
When making a
dashboard-item
, the only method you need to implement isdraw-dashboard-item
, which is called whenever the dashboard is (re)drawn.Let's say you want to add a
dashboard-item
that prints a random fact/quote from an http endpoint, you can make it like this (multithreading is overkill here, just for fun):To make a custom dashboard layout, all you have to do is call
set-dashboard
and pass a list of items:Users might want to keep most of the default dashboard's functionality, but customize it a bit (e.g. change the splash, number of projects, etc.). There's a
set-default-dashboard
available to make it easy so they don't have to re-do the whole layout:Notes:
*dashboard-enable*
to nil to disable