blob: 3bb6034c2fd3d0acf572e4345abd0bc1b97a3b88 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
;;; dashboard-config.el --- Dashboard Configuration -*- lexical-binding: t; coding: utf-8; -*-
;; author Craig Jennings <c@cjennings.net>
;;; Commentary:
;; Note:
;; Nerd-Icons Cheat Sheet: https://www.nerdfonts.com/cheat-sheet
;;; Code:
(eval-when-compile (require 'undead-buffers))
(declare-function cj/make-buffer-undead "undead-buffers" (string))
(autoload 'cj/make-buffer-undead "undead-buffers" nil t)
;; ------------------------ Dashboard Bookmarks Override -----------------------
;; overrides the bookmark insertion from the dashboard package to provide an
;; option that only shows the bookmark name, avoiding the path. Paths are often
;; too long and the truncation options aren't aesthetically pleasing. Should be
;; accompanied by the setting (setq dashboard-bookmarks-show-path nil) in
;; config.
(defvar dashboard-bookmarks-item-format "%s"
"Format to use when showing the base of the file name.")
(defun dashboard-insert-bookmarks (list-size)
"Add the list of LIST-SIZE items of bookmarks."
(require 'bookmark)
(dashboard-insert-section
"Bookmarks:"
(dashboard-subseq (bookmark-all-names) list-size)
list-size
'bookmarks
(dashboard-get-shortcut 'bookmarks)
`(lambda (&rest _) (bookmark-jump ,el))
(if-let* ((filename el)
(path (bookmark-get-filename el))
(path-shorten (dashboard-shorten-path path 'bookmarks)))
(cl-case dashboard-bookmarks-show-path
(`align
(unless dashboard--bookmarks-cache-item-format
(let* ((len-align (dashboard--align-length-by-type 'bookmarks))
(new-fmt (dashboard--generate-align-format
dashboard-bookmarks-item-format len-align)))
(setq dashboard--bookmarks-cache-item-format new-fmt)))
(format dashboard--bookmarks-cache-item-format filename path-shorten))
(`nil filename)
(t (format dashboard-bookmarks-item-format filename path-shorten)))
el)))
;; ----------------------------- Display Dashboard -----------------------------
;; convenience function to redisplay dashboard and kill all other windows
(defun cj/dashboard-only ()
"Switch to *dashboard* buffer and kill all other buffers and windows."
(interactive)
(when (fboundp 'dired-sidebar-hide-sidebar)
(dired-sidebar-hide-sidebar))
(if (get-buffer "*dashboard*")
(progn
(switch-to-buffer "*dashboard*")
(cj/kill-all-other-buffers-and-windows))
(when (fboundp 'dashboard-open)
(dashboard-open))))
;; --------------------------------- Dashboard ---------------------------------
;; a useful startup screen for Emacs
(use-package dashboard
:defer t
:hook (emacs-startup . cj/dashboard-only)
:bind ("<f1>" . cj/dashboard-only)
:custom
(dashboard-projects-backend 'projectile)
(dashboard-item-generators
'((projects . dashboard-insert-projects)
(bookmarks . dashboard-insert-bookmarks)))
(dashboard-items '((projects . 5)
(bookmarks . 15)))
(dashboard-startupify-list
'(dashboard-insert-banner
dashboard-insert-banner-title
dashboard-insert-newline
dashboard-insert-newline
dashboard-insert-navigator
dashboard-insert-init-info
dashboard-insert-newline
dashboard-insert-newline
dashboard-insert-items
dashboard-insert-newline))
:config
;; == general
(dashboard-setup-startup-hook) ;; run dashboard post emacs init
(cj/make-buffer-undead "*dashboard*") ;; make this buffer unkillable
(if (< (length command-line-args) 2)
(setq initial-buffer-choice (lambda () (get-buffer "*dashboard*")))) ;; don't display dashboard if opening a file
(setq dashboard-display-icons-p t) ;; display icons on both GUI and terminal
(setq dashboard-icon-type 'nerd-icons) ;; use `nerd-icons' package
(setq dashboard-center-content t) ;; horizontally center dashboard content
(setq dashboard-bookmarks-show-path nil) ;; don't show paths in bookmarks
(setq dashboard-set-footer nil) ;; don't show footer and quotes
;; == banner
(setq dashboard-startup-banner (concat user-emacs-directory "assets/M-x_butterfly.png"))
(setq dashboard-banner-logo-title "Emacs: The Editor That Saves Your Soul")
;; == navigation
(setq dashboard-set-navigator t)
(setq dashboard-navigator-buttons
`(((,(nerd-icons-faicon "nf-fa-envelope")
"Email" "Mu4e Email Client"
(lambda (&rest _) (mu4e)))
(,(nerd-icons-faicon "nf-fae-book_open_o")
"Ebooks" "Calibre Ebook Reader"
(lambda (&rest _) (calibredb)))
(,(nerd-icons-mdicon "nf-md-school")
"Flashcards" "Org-Drill"
(lambda (&rest _) (cj/drill-start)))
(,(nerd-icons-faicon "nf-fa-rss_square")
"Feeds" "Elfeed Feed Reader"
(lambda (&rest _) (cj/elfeed-open)))
(,(nerd-icons-faicon "nf-fa-comments")
"IRC" "Emacs Relay Chat"
(lambda (&rest _) (cj/erc-start-or-switch)))
;; (,(nerd-icons-faicon "nf-fae-telegram")
;; "Telegram" "Telega Chat Client"
;; (lambda (&rest _) (telega)))
(,(nerd-icons-faicon "nf-fa-folder_o")
"Files" "Dirvish File Manager"
(lambda (&rest _) (dirvish user-home-dir))))))
;; == content
(setq dashboard-show-shortcuts nil) ;; don't show dashboard item abbreviations
) ;; end use-package dashboard
(provide 'dashboard-config)
;;; dashboard-config.el ends here.
|