update packages
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
;;; dashboard.el --- A startup screen extracted from Spacemacs -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (c) 2016-2020 Rakan Al-Hneiti & Contributors
|
||||
;; Copyright (c) 2016-2020 Rakan Al-Hneiti <rakan.alhneiti@gmail.com>
|
||||
;; Copyright (c) 2019-2020 Jesús Martínez <jesusmartinez93@gmail.com>
|
||||
;; Copyright (c) 2020 Shen, Jen-Chieh <jcs090218@gmail.com>
|
||||
;;
|
||||
;; Author: Rakan Al-Hneiti
|
||||
;; URL: https://github.com/emacs-dashboard/emacs-dashboard
|
||||
@@ -16,12 +18,11 @@
|
||||
;;; Commentary:
|
||||
|
||||
;; An extensible Emacs dashboard, with sections for
|
||||
;; bookmarks, projectile projects, org-agenda and more.
|
||||
;; bookmarks, projects (projectile or project.el), org-agenda and more.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'seq)
|
||||
(require 'page-break-lines)
|
||||
(require 'recentf)
|
||||
|
||||
(require 'dashboard-widgets)
|
||||
@@ -39,13 +40,18 @@
|
||||
(define-key map (kbd "C-i") 'widget-forward)
|
||||
(define-key map [backtab] 'widget-backward)
|
||||
(define-key map (kbd "RET") 'dashboard-return)
|
||||
(define-key map [down-mouse-1] 'widget-button-click)
|
||||
(define-key map [mouse-1] 'dashboard-mouse-1)
|
||||
(define-key map (kbd "g") #'dashboard-refresh-buffer)
|
||||
(define-key map (kbd "}") #'dashboard-next-section)
|
||||
(define-key map (kbd "{") #'dashboard-previous-section)
|
||||
map)
|
||||
"Keymap for dashboard mode.")
|
||||
|
||||
(defcustom dashboard-after-initialize-hook nil
|
||||
"Hook that is run after dashboard buffer is initialized."
|
||||
:group 'dashboard
|
||||
:type 'hook)
|
||||
|
||||
(define-derived-mode dashboard-mode special-mode "Dashboard"
|
||||
"Dashboard major mode for startup screen.
|
||||
\\<dashboard-mode-map>
|
||||
@@ -59,8 +65,8 @@
|
||||
(when (>= emacs-major-version 26)
|
||||
(display-line-numbers-mode -1))
|
||||
(page-break-lines-mode 1)
|
||||
(setq inhibit-startup-screen t)
|
||||
(setq buffer-read-only t
|
||||
(setq inhibit-startup-screen t
|
||||
buffer-read-only t
|
||||
truncate-lines t))
|
||||
|
||||
(defgroup dashboard nil
|
||||
@@ -153,6 +159,13 @@ Optional prefix ARG says how many lines to move; default is one line."
|
||||
(widget-button-press entry-pt)
|
||||
(call-interactively #'widget-button-press))))
|
||||
|
||||
(defun dashboard-mouse-1 ()
|
||||
"Key for keymap `mouse-1'."
|
||||
(interactive)
|
||||
(let ((old-track-mouse track-mouse))
|
||||
(when (call-interactively #'widget-button-click)
|
||||
(setq track-mouse old-track-mouse))))
|
||||
|
||||
(defun dashboard-maximum-section-length ()
|
||||
"For the just-inserted section, calculate the length of the longest line."
|
||||
(let ((max-line-length 0))
|
||||
@@ -162,7 +175,7 @@ Optional prefix ARG says how many lines to move; default is one line."
|
||||
(setq max-line-length
|
||||
(max max-line-length
|
||||
(- (line-end-position) (line-beginning-position))))
|
||||
(forward-line)))
|
||||
(forward-line 1)))
|
||||
max-line-length))
|
||||
|
||||
(defun dashboard-insert-startupify-lists ()
|
||||
@@ -180,8 +193,8 @@ Optional prefix ARG says how many lines to move; default is one line."
|
||||
;; then restore the orginal list afterwards
|
||||
;; (this avoids many saves/loads that would result from
|
||||
;; disabling/enabling recentf-mode)
|
||||
(if recentf-is-on
|
||||
(setq recentf-list (seq-take recentf-list dashboard-num-recents)))
|
||||
(when recentf-is-on
|
||||
(setq recentf-list (seq-take recentf-list dashboard-num-recents)))
|
||||
(when (or (not (eq dashboard-buffer-last-width (window-width)))
|
||||
(not buffer-exists))
|
||||
(setq dashboard-banner-length (window-width)
|
||||
@@ -208,16 +221,16 @@ Optional prefix ARG says how many lines to move; default is one line."
|
||||
(when dashboard-center-content
|
||||
(when dashboard--section-starts
|
||||
(goto-char (car (last dashboard--section-starts))))
|
||||
(let ((margin (floor (/ (max (- (window-width) max-line-length) 0) 2))))
|
||||
(let ((margin (floor (/ (max (- (window-width) max-line-length) 0) 2))))
|
||||
(while (not (eobp))
|
||||
(and (not (eq ? (char-after)))
|
||||
(insert (make-string margin ?\ )))
|
||||
(unless (string-suffix-p (thing-at-point 'line) dashboard-page-separator)
|
||||
(insert (make-string margin ?\ )))
|
||||
(forward-line 1))))
|
||||
(dashboard-insert-footer))
|
||||
(dashboard-mode)
|
||||
(goto-char (point-min))))
|
||||
(if recentf-is-on
|
||||
(setq recentf-list origial-recentf-list))))
|
||||
(goto-char (point-min))
|
||||
(dashboard-mode)))
|
||||
(when recentf-is-on
|
||||
(setq recentf-list origial-recentf-list))))
|
||||
|
||||
(add-hook 'window-setup-hook
|
||||
(lambda ()
|
||||
@@ -227,7 +240,8 @@ Optional prefix ARG says how many lines to move; default is one line."
|
||||
(defun dashboard-refresh-buffer ()
|
||||
"Refresh buffer."
|
||||
(interactive)
|
||||
(kill-buffer dashboard-buffer-name)
|
||||
(when (get-buffer dashboard-buffer-name)
|
||||
(kill-buffer dashboard-buffer-name))
|
||||
(dashboard-insert-startupify-lists)
|
||||
(switch-to-buffer dashboard-buffer-name))
|
||||
|
||||
@@ -245,14 +259,15 @@ Optional prefix ARG says how many lines to move; default is one line."
|
||||
"Setup post initialization hooks.
|
||||
If a command line argument is provided,
|
||||
assume a filename and skip displaying Dashboard."
|
||||
(when (< (length command-line-args) 2 )
|
||||
(when (< (length command-line-args) 2)
|
||||
(add-hook 'after-init-hook (lambda ()
|
||||
;; Display useful lists of items
|
||||
(dashboard-insert-startupify-lists)))
|
||||
(add-hook 'emacs-startup-hook '(lambda ()
|
||||
(switch-to-buffer "*dashboard*")
|
||||
(switch-to-buffer dashboard-buffer-name)
|
||||
(goto-char (point-min))
|
||||
(redisplay)))))
|
||||
(redisplay)
|
||||
(run-hooks 'dashboard-after-initialize-hook)))))
|
||||
|
||||
(provide 'dashboard)
|
||||
;;; dashboard.el ends here
|
||||
|
||||
Reference in New Issue
Block a user