diff options
-rw-r--r-- | dashboard.el | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/dashboard.el b/dashboard.el index b285547..cd4886c 100644 --- a/dashboard.el +++ b/dashboard.el @@ -60,11 +60,51 @@ If FORCE is non-nil, re-gerenate the dashboard buffer." (read-only-mode 1) (set 'mode-line-format '("%e" (:eval (modeline-format-dashboard)))) (set 'default-directory user-emacs-directory) - (view-mode 1)))) + (view-mode 1) + (dashboard-mode)))) dashboard)) (set 'initial-buffer-choice #'dashboard) +;;; Dedicated major mode + +(define-derived-mode dashboard-mode nil "Dashboard" + "Major mode for the dashboard buffer. +The main purpose is to provide a dedicated keymap to access +common functionalities more conveniently.") + +(define-key dashboard-mode-map (vector ?l) #'blist) +(define-key dashboard-mode-map (vector ?b) #'bookmark-jump) +(define-key dashboard-mode-map (vector ?a) #'dashboard-org-agenda) +(define-key dashboard-mode-map (vector ?c) #'dashboard-org-capture) +(define-key dashboard-mode-map (vector ?l) #'dashboard-org-store-link) + +;; load Org if not loaded already + +(defmacro dashboard-preload (symbol file-to-load) + "Define a dispatch function for the symbol." + (list + 'defun (intern (format "dashboard-%s" (symbol-name symbol))) + (list (intern "&rest") 'args) + (format + "A dispatch function for `%s'. +This function loads \"%s\" if `%s' is not already loaded, and +calls `%s' otherwise." + (symbol-name symbol) + file-to-load + (symbol-name symbol) + (symbol-name symbol)) + (list 'interactive (list #'list 'current-prefix-arg t)) + (list + 'cond + (list (list 'not (list #'functionp `(quote ,symbol))) + (list #'load-config file-to-load)) + (list (list #'funcall `(quote ,symbol) 'args))))) + +(dashboard-preload org-agenda "org-conf.el") +(dashboard-preload org-capture "org-conf.el") +(dashboard-preload org-store-link "org-conf.el") + ;;; Modify killing buffers ;;;###autoload |