aboutsummaryrefslogtreecommitdiff
path: root/modules/dashboard-config.el
diff options
context:
space:
mode:
Diffstat (limited to 'modules/dashboard-config.el')
-rw-r--r--modules/dashboard-config.el117
1 files changed, 102 insertions, 15 deletions
diff --git a/modules/dashboard-config.el b/modules/dashboard-config.el
index b4e4545d0..17a0e2c4a 100644
--- a/modules/dashboard-config.el
+++ b/modules/dashboard-config.el
@@ -17,10 +17,62 @@
;;; Code:
+(require 'system-lib) ;; cj/exclude-from-global-font-lock
(eval-when-compile (require 'undead-buffers))
(declare-function cj/make-buffer-undead "undead-buffers" (string))
(autoload 'cj/make-buffer-undead "undead-buffers" nil t)
-(declare-function ghostel "ghostel" (&optional arg))
+(declare-function cj/term-toggle "eat-config")
+
+;; ------------------------------ Declarations -------------------------------
+;; These functions and variables belong to lazily-loaded packages or to other
+;; cj modules; declaring them keeps the byte-compiler quiet without forcing an
+;; eager require. Behavior is unchanged -- the symbols still resolve at runtime
+;; once their owning package/module loads.
+
+;; dashboard package internals used by the bookmark-insertion override.
+(declare-function dashboard-insert-section "dashboard")
+(declare-function dashboard-subseq "dashboard")
+(declare-function dashboard-get-shortcut "dashboard")
+(declare-function dashboard-shorten-path "dashboard")
+(declare-function dashboard--align-length-by-type "dashboard")
+(declare-function dashboard--generate-align-format "dashboard")
+(declare-function dashboard-refresh-buffer "dashboard")
+(declare-function dashboard-open "dashboard")
+(defvar dashboard-bookmarks-show-path)
+(defvar dashboard--bookmarks-cache-item-format)
+
+;; bookmark.el (required at runtime inside `dashboard-insert-bookmarks').
+(declare-function bookmark-all-names "bookmark")
+(declare-function bookmark-get-filename "bookmark")
+
+;; recentf.el (required at runtime inside the exclude helper).
+(defvar recentf-exclude)
+
+;; nerd-icons glyph functions used in the launcher table.
+(declare-function nerd-icons-faicon "nerd-icons")
+(declare-function nerd-icons-devicon "nerd-icons")
+(declare-function nerd-icons-mdicon "nerd-icons")
+(declare-function nerd-icons-codicon "nerd-icons")
+(declare-function nerd-icons-octicon "nerd-icons")
+
+;; user-constants.el provides the home-directory constant.
+(defvar user-home-dir)
+
+;; Launcher actions defined in other cj modules.
+(declare-function cj/main-agenda-display "org-agenda-config")
+(declare-function cj/elfeed-open "elfeed-config")
+(declare-function cj/drill-start "org-drill-config")
+(declare-function cj/music-playlist-toggle "music-config")
+(declare-function cj/music-playlist-load "music-config")
+(declare-function cj/erc-switch-to-buffer-with-completion "erc-config")
+(declare-function cj/telega "telega-config")
+(declare-function cj/slack-start "slack-config")
+(declare-function cj/signel-message "signal-config")
+(declare-function cj/kill-all-other-buffers-and-windows "undead-buffers")
+
+;; External package commands invoked by launchers.
+(declare-function mu4e "mu4e")
+(declare-function pearl-list-issues "pearl")
;; ------------------------ Dashboard Bookmarks Override -----------------------
;; overrides the bookmark insertion from the dashboard package to provide an
@@ -32,6 +84,14 @@
(defvar dashboard-bookmarks-item-format "%s"
"Format to use when showing the base of the file name.")
+;; `el' is bound dynamically by dashboard's section-insertion machinery, which the
+;; override below plugs into. Declare it so the byte-compiler reads the
+;; references as that special variable rather than a free variable. The name is
+;; dashboard's, not ours, so the missing-prefix lint is suppressed rather than
+;; renamed (renaming would break the dynamic binding dashboard supplies).
+(with-suppressed-warnings ((lexical el))
+ (defvar el))
+
(defun dashboard-insert-bookmarks (list-size)
"Add the list of LIST-SIZE items of bookmarks."
(require 'bookmark)
@@ -77,23 +137,24 @@ Adjust this if the title doesn't appear centered under the banner image.")
(list
(list "c" #'nerd-icons-faicon "nf-fa-code" "Code" "Switch Project" (lambda () (projectile-switch-project)))
(list "d" #'nerd-icons-faicon "nf-fa-folder_o" "Files" "Dirvish File Manager" (lambda () (dirvish user-home-dir)))
- (list "t" #'nerd-icons-devicon "nf-dev-terminal" "Terminal" "Launch Terminal" (lambda () (ghostel)))
+ (list "t" #'nerd-icons-devicon "nf-dev-terminal" "Terminal" "Launch Terminal" (lambda () (cj/term-toggle)))
(list "a" #'nerd-icons-mdicon "nf-md-calendar" "Agenda" "Main Org Agenda" (lambda () (cj/main-agenda-display)))
(list "r" #'nerd-icons-faicon "nf-fa-rss_square" "Feeds" "Elfeed Feed Reader" (lambda () (cj/elfeed-open)))
- (list "b" #'nerd-icons-faicon "nf-fae-book_open_o" "Books" "Calibre Ebook Reader" (lambda () (calibredb)))
+ (list "b" #'nerd-icons-codicon "nf-cod-library" "Books" "Calibre Ebook Reader" (lambda () (calibredb)))
(list "f" #'nerd-icons-mdicon "nf-md-school" "Flashcards" "Org-Drill" (lambda () (cj/drill-start)))
(list "m" #'nerd-icons-mdicon "nf-md-music" "Music" "EMMS Music Player" (lambda () (cj/music-playlist-toggle) (cj/music-playlist-load)))
(list "e" #'nerd-icons-faicon "nf-fa-envelope" "Email" "Mu4e Email Client" (lambda () (mu4e)))
(list "i" #'nerd-icons-faicon "nf-fa-comments" "IRC" "Emacs Relay Chat" (lambda () (cj/erc-switch-to-buffer-with-completion)))
- (list "g" #'nerd-icons-faicon "nf-fa-telegram" "Telegram" "Telega Telegram Client" (lambda () (cj/telega)))
+ (list "G" #'nerd-icons-faicon "nf-fa-telegram" "Telegram" "Telega Telegram Client" (lambda () (cj/telega)))
(list "s" #'nerd-icons-faicon "nf-fa-slack" "Slack" "Slack Client" (lambda () (cj/slack-start)))
- (list "l" #'nerd-icons-octicon "nf-oct-issue_tracks" "Linear" "Linear Issue Tracker" (lambda () (pearl-list-issues))))
+ (list "l" #'nerd-icons-octicon "nf-oct-issue_tracks" "Linear" "Linear Issue Tracker" (lambda () (pearl-list-issues)))
+ (list "S" #'nerd-icons-mdicon "nf-md-message" "Signal" "Signal Messenger" (lambda () (cj/signel-message))))
"Dashboard launcher table: (KEY ICON-FN ICON-NAME LABEL TOOLTIP ACTION).
Drives both `dashboard-navigator-buttons' and the dashboard-mode-map keys.")
-(defconst cj/dashboard--row-sizes '(4 4 3 2)
+(defconst cj/dashboard--row-sizes '(4 4 3 3)
"Navigator row lengths. Must sum to the number of `cj/dashboard--launchers'.
-The last row groups Slack and Linear together.")
+The last row groups Slack, Linear, and Signal together.")
(defun cj/dashboard--navigator-button (l)
"Build a `dashboard-navigator-buttons' entry from launcher L."
@@ -134,17 +195,36 @@ doesn't leak into this display when the buffer is taller than the
window."
(interactive)
(if (get-buffer "*dashboard*")
- (progn
- (switch-to-buffer "*dashboard*")
- (cj/kill-all-other-buffers-and-windows))
- (when (fboundp 'dashboard-open)
- (dashboard-open)))
+ (progn
+ (switch-to-buffer "*dashboard*")
+ (cj/kill-all-other-buffers-and-windows))
+ (when (fboundp 'dashboard-open)
+ (dashboard-open)))
+ ;; Refresh so re-showing the dashboard always lands on fresh content.
+ (when (fboundp 'dashboard-refresh-buffer)
+ (dashboard-refresh-buffer))
(goto-char (point-min))
(set-window-start (selected-window) (point-min)))
;; --------------------------------- Dashboard ---------------------------------
;; a useful startup screen for Emacs
+(defun cj/--dashboard-exclude-emms-from-recentf ()
+ "Exclude the EMMS history file from recentf.
+Adds to `recentf-exclude' so entries set elsewhere (e.g. in
+system-defaults) are preserved rather than overwritten."
+ (require 'recentf)
+ (add-to-list 'recentf-exclude "/emms/history"))
+
+;; Keep global font-lock out of the dashboard buffer. Dashboard colors its
+;; banner title (`dashboard-banner-logo-title') and section headings
+;; (`dashboard-heading') with the `face' text property; `global-font-lock-mode'
+;; owns `face' and strips manually-applied ones it didn't set, so with font-lock
+;; running the banner and headings fall back to the default face. Excluding
+;; dashboard-mode lets those text-property faces survive. (Item and navigator
+;; colors ride a `dashboard-items-face' overlay, which font-lock leaves alone.)
+(cj/exclude-from-global-font-lock 'dashboard-mode)
+
(use-package dashboard
:demand t
:hook (emacs-startup . cj/dashboard-only)
@@ -192,15 +272,18 @@ window."
(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-set-file-icons t) ;; per-filetype icons on the list items (nerd-icons colors them by type)
+ (setq dashboard-set-heading-icons t) ;; nerd-icons on the section titles (Projects/Bookmarks/Recent)
(setq dashboard-center-content t) ;; horizontally center dashboard content
(setq dashboard-bookmarks-show-path nil) ;; don't show paths in bookmarks
(setq dashboard-recentf-show-base t) ;; show filename, not full path
(setq dashboard-recentf-item-format "%s")
- (setq recentf-exclude '("/emms/history")) ;; exclude EMMS history from recent files
- (setq dashboard-set-footer nil) ;; don't show footer and quotes
+ (cj/--dashboard-exclude-emms-from-recentf) ;; exclude EMMS history from recent files
;; == navigation
- (setq dashboard-set-navigator t)
+ ;; footer and navigator visibility are controlled by `dashboard-startupify-list'
+ ;; above (footer omitted, navigator included); the dashboard-set-* toggles are
+ ;; obsolete as of dashboard 1.9.0.
(setq dashboard-navigator-buttons (cj/dashboard--navigator-rows))
;; == content
@@ -215,6 +298,10 @@ window."
;; Disable 'q' to quit dashboard
(define-key dashboard-mode-map (kbd "q") nil)
+ ;; 'g' refreshes the dashboard (the dired/magit convention). Telegram moved to
+ ;; 'G' in the launcher table to free it.
+ (define-key dashboard-mode-map (kbd "g") #'dashboard-refresh-buffer)
+
;; Launcher keys, derived from `cj/dashboard--launchers' (same source as the
;; navigator icons, so key order can't drift from the icon-row order).
(cj/dashboard--bind-launchers dashboard-mode-map))