update of packages
This commit is contained in:
@@ -1,20 +1,11 @@
|
||||
;;; dashboard-widgets.el --- A startup screen extracted from Spacemacs -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (c) 2016-2022 emacs-dashboard maintainers
|
||||
;;
|
||||
;; Author : Rakan Al-Hneiti <rakan.alhneiti@gmail.com>
|
||||
;; Maintainer : Jesús Martínez <jesusmartinez93@gmail.com>
|
||||
;; Shen, Jen-Chieh <jcs090218@gmail.com>
|
||||
;; URL : https://github.com/emacs-dashboard/emacs-dashboard
|
||||
;;
|
||||
;; Copyright (c) 2016-2023 emacs-dashboard maintainers
|
||||
|
||||
;; This file is not part of GNU Emacs.
|
||||
;;
|
||||
;;; License: GPLv3
|
||||
;;
|
||||
;; Created: October 05, 2016
|
||||
;; Package-Version: 1.8.0-SNAPSHOT
|
||||
;; Keywords: startup, screen, tools, dashboard
|
||||
;; Package-Requires: ((emacs "26.1"))
|
||||
;;; Commentary:
|
||||
|
||||
;; An extensible Emacs dashboard, with sections for
|
||||
@@ -31,13 +22,17 @@
|
||||
(declare-function all-the-icons-icon-for-file "ext:all-the-icons.el")
|
||||
(declare-function all-the-icons-fileicon "ext:data-fileicons.el")
|
||||
(declare-function all-the-icons-octicon "ext:data-octicons.el")
|
||||
(declare-function nerd-icons-icon-for-dir "ext:nerd-icons.el")
|
||||
(declare-function nerd-icons-icon-for-file "ext:nerd-icons.el")
|
||||
(declare-function nerd-icons-sucicon "ext:nerd-icons.el")
|
||||
(declare-function nerd-icons-octicon "ext:nerd-icons.el")
|
||||
(declare-function nerd-icons-codicon "ext:nerd-icons.el")
|
||||
(declare-function bookmark-get-filename "ext:bookmark.el")
|
||||
(declare-function bookmark-all-names "ext:bookmark.el")
|
||||
(declare-function calendar-date-compare "ext:calendar.el")
|
||||
(declare-function projectile-cleanup-known-projects "ext:projectile.el")
|
||||
(declare-function projectile-load-known-projects "ext:projectile.el")
|
||||
(declare-function projectile-mode "ext:projectile.el")
|
||||
(declare-function projectile-relevant-known-projects "ext:projectile.el")
|
||||
;;; project.el in Emacs 26 does not contain this function
|
||||
(declare-function project-known-project-roots "ext:project.el" nil t)
|
||||
(declare-function project-forget-zombie-projects "ext:project.el" nil t)
|
||||
@@ -69,6 +64,7 @@
|
||||
(defvar org-todo-keywords-1)
|
||||
(defvar all-the-icons-dir-icon-alist)
|
||||
(defvar package-activated-list)
|
||||
(defvar elpaca-after-init-time)
|
||||
(declare-function string-pixel-width "subr-x.el") ; TODO: remove this after 29.1
|
||||
(declare-function shr-string-pixel-width "shr.el") ; TODO: remove this after 29.1
|
||||
|
||||
@@ -135,6 +131,70 @@ preserved."
|
||||
:type 'list
|
||||
:group 'dashboard)
|
||||
|
||||
(defcustom dashboard-icon-type (and (or dashboard-set-heading-icons
|
||||
dashboard-set-file-icons)
|
||||
(or (require 'nerd-icons nil t)
|
||||
(require 'all-the-icons nil t)))
|
||||
"Icon type used for dashboard.
|
||||
The value can be one of: `all-the-icons', `nerd-icons'."
|
||||
:type 'symbol
|
||||
:group 'dashboard
|
||||
:set
|
||||
(lambda (k v)
|
||||
(pcase v
|
||||
('all-the-icons
|
||||
(unless (require 'all-the-icons nil t)
|
||||
(setq v nil)))
|
||||
('nerd-icons
|
||||
(unless (require 'nerd-icons nil t)
|
||||
(setq v nil))))
|
||||
(set k v)))
|
||||
|
||||
(defcustom dashboard-heading-icons
|
||||
(pcase dashboard-icon-type
|
||||
('all-the-icons '((recents . "history")
|
||||
(bookmarks . "bookmark")
|
||||
(agenda . "calendar")
|
||||
(projects . "rocket")
|
||||
(registers . "database")))
|
||||
('nerd-icons '((recents . "nf-oct-history")
|
||||
(bookmarks . "nf-oct-bookmark")
|
||||
(agenda . "nf-oct-calendar")
|
||||
(projects . "nf-oct-rocket")
|
||||
(registers . "nf-oct-database"))))
|
||||
"Association list for the icons of the heading sections.
|
||||
Will be of the form `(list-type . icon-name-string)`.
|
||||
If nil it is disabled. Possible values for list-type are:
|
||||
`recents' `bookmarks' `projects' `agenda' `registers'"
|
||||
:type '(repeat (alist :key-type symbol :value-type string))
|
||||
:group 'dashboard)
|
||||
|
||||
(defcustom dashboard-heading-icon-height 1.2
|
||||
"The height of the heading icon."
|
||||
:type 'float
|
||||
:group 'dashboard)
|
||||
|
||||
(defcustom dashboard-heading-icon-v-adjust 0.0
|
||||
"The v-adjust of the heading icon."
|
||||
:type 'float
|
||||
:group 'dashboard)
|
||||
|
||||
(defcustom dashboard-agenda-item-icon
|
||||
(pcase dashboard-icon-type
|
||||
('all-the-icons (all-the-icons-octicon "primitive-dot" :height 1.0 :v-adjust 0.01))
|
||||
('nerd-icons (nerd-icons-octicon "nf-oct-dot_fill" :height 1.0 :v-adjust 0.01)))
|
||||
"Agenda item icon."
|
||||
:type 'string
|
||||
:group 'dashboard)
|
||||
|
||||
(defcustom dashboard-remote-path-icon
|
||||
(pcase dashboard-icon-type
|
||||
('all-the-icons (all-the-icons-octicon "radio-tower" :height 1.0 :v-adjust 0.01))
|
||||
('nerd-icons (nerd-icons-codicon "nf-cod-radio_tower" :height 1.0 :v-adjust 0.01)))
|
||||
"Remote path icon."
|
||||
:type 'string
|
||||
:group 'dashboard)
|
||||
|
||||
(defcustom dashboard-show-shortcuts t
|
||||
"Whether to show shortcut keys for each section."
|
||||
:type 'boolean
|
||||
@@ -157,13 +217,19 @@ preserved."
|
||||
:type 'string
|
||||
:group 'dashboard)
|
||||
|
||||
(defcustom dashboard-banner-ascii "EMACS"
|
||||
"String to be shown in place of the startup banner
|
||||
if `dashboard-startup-banner' is set to `ascii'."
|
||||
:type 'string
|
||||
:group 'dashboard)
|
||||
|
||||
(defcustom dashboard-navigator-buttons nil
|
||||
"Specify the navigator buttons.
|
||||
The format is: 'icon title help action face prefix suffix'.
|
||||
The format is: `icon title help action face prefix suffix`.
|
||||
|
||||
Example:
|
||||
'((\"☆\" \"Star\" \"Show stars\" (lambda (&rest _)
|
||||
(show-stars)) 'warning \"[\" \"]\"))"
|
||||
`((\"☆\" \"Star\" \"Show stars\" (lambda (&rest _)
|
||||
(show-stars)) warning \"[\" \"]\"))"
|
||||
:type '(repeat (repeat (list string string string function symbol string string)))
|
||||
:group 'dashboard)
|
||||
|
||||
@@ -175,6 +241,8 @@ Example:
|
||||
(when (boundp 'straight--profile-cache)
|
||||
(setq package-count (+ (hash-table-count straight--profile-cache) package-count)))
|
||||
(when (fboundp 'elpaca--queued)
|
||||
(setq time (format "%f seconds" (float-time (time-subtract elpaca-after-init-time
|
||||
before-init-time))))
|
||||
(setq package-count (length (elpaca--queued))))
|
||||
(if (zerop package-count)
|
||||
(format "Emacs started in %s" time)
|
||||
@@ -183,21 +251,75 @@ Example:
|
||||
:type '(function string)
|
||||
:group 'dashboard)
|
||||
|
||||
(defcustom dashboard-footer
|
||||
(nth (random (1- (1+ (length dashboard-footer-messages)))) dashboard-footer-messages)
|
||||
"A footer with some short message."
|
||||
:type 'string
|
||||
(defcustom dashboard-display-icons-p #'display-graphic-p
|
||||
"Predicate to determine whether dashboard should show icons.
|
||||
Can be nil to not show icons and any truthy value to show them. When set to a
|
||||
function the result of the function will be interpreted as the predicate value."
|
||||
:type '(choice (function :tag "Predicate function")
|
||||
(boolean :tag "Predicate value"))
|
||||
:group 'dashboard)
|
||||
|
||||
(defun dashboard-replace-displayable (str &optional rep)
|
||||
"Replace non-displayable character from STR.
|
||||
|
||||
Optional argument REP is the replacement string of non-displayable character."
|
||||
(if (stringp str)
|
||||
(let ((rep (or rep ""))
|
||||
(results (list)))
|
||||
(dolist (string (split-string str ""))
|
||||
(let* ((char (string-to-char string))
|
||||
(string (if (char-displayable-p char)
|
||||
string
|
||||
rep)))
|
||||
(push string results)))
|
||||
(string-join (reverse results)))
|
||||
""))
|
||||
|
||||
(defun dashboard-display-icons-p ()
|
||||
"Assert whether to show icons based on the `dashboard-display-icons-p' variable."
|
||||
(if (functionp dashboard-display-icons-p)
|
||||
(funcall dashboard-display-icons-p)
|
||||
dashboard-display-icons-p))
|
||||
|
||||
(defun dashboard-icon-for-dir (dir &rest args)
|
||||
"Get the formatted icon for DIR.
|
||||
ARGS should be a plist containing `:height', `:v-adjust',
|
||||
or `:face' properties."
|
||||
(dashboard-replace-displayable
|
||||
(pcase dashboard-icon-type
|
||||
('all-the-icons (apply #'all-the-icons-icon-for-dir dir args))
|
||||
('nerd-icons (apply #'nerd-icons-icon-for-dir dir args)))))
|
||||
|
||||
(defun dashboard-icon-for-file (file &rest args)
|
||||
"Get the formatted icon for FILE.
|
||||
ARGS should be a plist containing `:height', `:v-adjust', or `:face' properties."
|
||||
(dashboard-replace-displayable
|
||||
(pcase dashboard-icon-type
|
||||
('all-the-icons (apply #'all-the-icons-icon-for-file file args))
|
||||
('nerd-icons (apply #'nerd-icons-icon-for-file file args)))))
|
||||
|
||||
(defun dashboard-octicon (name &rest args)
|
||||
"Get the formatted octicon by NAME.
|
||||
ARGS should be a plist containing `:height', `:v-adjust', or `:face' properties."
|
||||
(dashboard-replace-displayable
|
||||
(pcase dashboard-icon-type
|
||||
('all-the-icons (apply #'all-the-icons-octicon name args))
|
||||
('nerd-icons (apply #'nerd-icons-octicon name args)))))
|
||||
|
||||
(defcustom dashboard-footer-icon
|
||||
(if (and (display-graphic-p)
|
||||
(or (fboundp 'all-the-icons-fileicon)
|
||||
(require 'all-the-icons nil 'noerror)))
|
||||
(all-the-icons-fileicon "emacs"
|
||||
:height 1.1
|
||||
:v-adjust -0.05
|
||||
:face 'font-lock-keyword-face)
|
||||
(propertize ">" 'face 'dashboard-footer))
|
||||
(if (dashboard-display-icons-p)
|
||||
(pcase dashboard-icon-type
|
||||
('all-the-icons
|
||||
(all-the-icons-fileicon "emacs"
|
||||
:height 1.1
|
||||
:v-adjust -0.05
|
||||
:face 'dashboard-footer-icon-face))
|
||||
('nerd-icons
|
||||
(nerd-icons-sucicon "nf-custom-emacs"
|
||||
:height 1.1
|
||||
:v-adjust -0.05
|
||||
:face 'dashboard-footer-icon-face)))
|
||||
(propertize ">" 'face 'dashboard-footer-icon-face))
|
||||
"Footer's icon."
|
||||
:type 'string
|
||||
:group 'dashboard)
|
||||
@@ -205,12 +327,14 @@ Example:
|
||||
(defcustom dashboard-startup-banner 'official
|
||||
"Specify the startup banner.
|
||||
Default value is `official', it displays the Emacs logo. `logo' displays Emacs
|
||||
alternative logo. An integer value is the index of text banner. A string
|
||||
value must be a path to a .PNG or .TXT file. If the value is nil then no banner
|
||||
is displayed."
|
||||
alternative logo. If set to `ascii', the value of `dashboard-banner-ascii'
|
||||
will be used as the banner. An integer value is the index of text banner.
|
||||
A string value must be a path to a .PNG or .TXT file. If the value is
|
||||
nil then no banner is displayed."
|
||||
:type '(choice (const :tag "no banner" nil)
|
||||
(const :tag "offical" official)
|
||||
(const :tag "logo" logo)
|
||||
(const :tag "ascii" ascii)
|
||||
(integer :tag "index of a text banner")
|
||||
(string :tag "a path to an image or text banner")
|
||||
(cons :tag "an image and text banner"
|
||||
@@ -244,6 +368,11 @@ installed."
|
||||
(const :tag "Use project.el" project-el))
|
||||
:group 'dashboard)
|
||||
|
||||
(defcustom dashboard-remove-missing-entry nil
|
||||
"If non-nil, try to remove missing entries."
|
||||
:type 'boolean
|
||||
:group 'dashboard)
|
||||
|
||||
(defcustom dashboard-items
|
||||
'((recents . 5)
|
||||
(bookmarks . 5)
|
||||
@@ -283,19 +412,6 @@ Set to nil for unbounded."
|
||||
:type 'integer
|
||||
:group 'dashboard)
|
||||
|
||||
(defcustom dashboard-heading-icons
|
||||
'((recents . "history")
|
||||
(bookmarks . "bookmark")
|
||||
(agenda . "calendar")
|
||||
(projects . "rocket")
|
||||
(registers . "database"))
|
||||
"Association list for the icons of the heading sections.
|
||||
Will be of the form `(list-type . icon-name-string)`.
|
||||
If nil it is disabled. Possible values for list-type are:
|
||||
`recents' `bookmarks' `projects' `agenda' `registers'"
|
||||
:type '(repeat (alist :key-type symbol :value-type string))
|
||||
:group 'dashboard)
|
||||
|
||||
(defcustom dashboard-path-style nil
|
||||
"Style to display path."
|
||||
:type '(choice
|
||||
@@ -352,9 +468,14 @@ If nil it is disabled. Possible values for list-type are:
|
||||
"Face used for no items."
|
||||
:group 'dashboard)
|
||||
|
||||
(defface dashboard-footer
|
||||
(defface dashboard-footer-face
|
||||
'((t (:inherit font-lock-doc-face)))
|
||||
"Face used for widget headings."
|
||||
"Face used for footer text."
|
||||
:group 'dashboard)
|
||||
|
||||
(defface dashboard-footer-icon-face
|
||||
'((t (:inherit dashboard-footer-face)))
|
||||
"Face used for icon in footer."
|
||||
:group 'dashboard)
|
||||
|
||||
(define-obsolete-face-alias
|
||||
@@ -388,7 +509,7 @@ If nil it is disabled. Possible values for list-type are:
|
||||
|
||||
(defun dashboard-str-len (str)
|
||||
"Calculate STR in pixel width."
|
||||
(let ((width (window-font-width))
|
||||
(let ((width (frame-char-width))
|
||||
(len (dashboard-string-pixel-width str)))
|
||||
(+ (/ len width)
|
||||
(if (zerop (% len width)) 0 1)))) ; add one if exceeed
|
||||
@@ -415,6 +536,9 @@ If nil it is disabled. Possible values for list-type are:
|
||||
search-label
|
||||
&optional no-next-line)
|
||||
"Insert a shortcut SHORTCUT-CHAR for a given SEARCH-LABEL.
|
||||
|
||||
SHORTCUT-ID is the section identifier.
|
||||
|
||||
Optionally, provide NO-NEXT-LINE to move the cursor forward a line."
|
||||
(let* (;; Ensure punctuation and upper case in search string is not
|
||||
;; used to construct the `defun'
|
||||
@@ -438,7 +562,7 @@ Optionally, provide NO-NEXT-LINE to move the cursor forward a line."
|
||||
If MESSAGEBUF is not nil then MSG is also written in message buffer."
|
||||
(with-current-buffer (get-buffer-create dashboard-buffer-name)
|
||||
(goto-char (point-max))
|
||||
(let (buffer-read-only) (insert msg))))
|
||||
(let ((inhibit-read-only t)) (insert msg))))
|
||||
|
||||
(defun dashboard-modify-heading-icons (alist)
|
||||
"Append ALIST items to `dashboard-heading-icons' to modify icons."
|
||||
@@ -449,33 +573,32 @@ If MESSAGEBUF is not nil then MSG is also written in message buffer."
|
||||
"Insert a page break line in dashboard buffer."
|
||||
(dashboard-append dashboard-page-separator))
|
||||
|
||||
(defun dashboard-insert-heading (heading &optional shortcut)
|
||||
"Insert a widget HEADING in dashboard buffer, adding SHORTCUT if provided."
|
||||
(when (and (display-graphic-p) dashboard-set-heading-icons)
|
||||
;; Try loading `all-the-icons'
|
||||
(unless (or (fboundp 'all-the-icons-octicon)
|
||||
(require 'all-the-icons nil 'noerror))
|
||||
(error "Package `all-the-icons' isn't installed"))
|
||||
|
||||
(insert (cond
|
||||
((string-equal heading "Recent Files:")
|
||||
(all-the-icons-octicon (cdr (assoc 'recents dashboard-heading-icons))
|
||||
:height 1.2 :v-adjust 0.0 :face 'dashboard-heading))
|
||||
((string-equal heading "Bookmarks:")
|
||||
(all-the-icons-octicon (cdr (assoc 'bookmarks dashboard-heading-icons))
|
||||
:height 1.2 :v-adjust 0.0 :face 'dashboard-heading))
|
||||
((or (string-equal heading "Agenda for today:")
|
||||
(string-equal heading "Agenda for the coming week:"))
|
||||
(all-the-icons-octicon (cdr (assoc 'agenda dashboard-heading-icons))
|
||||
:height 1.2 :v-adjust 0.0 :face 'dashboard-heading))
|
||||
((string-equal heading "Registers:")
|
||||
(all-the-icons-octicon (cdr (assoc 'registers dashboard-heading-icons))
|
||||
:height 1.2 :v-adjust 0.0 :face 'dashboard-heading))
|
||||
((string-equal heading "Projects:")
|
||||
(all-the-icons-octicon (cdr (assoc 'projects dashboard-heading-icons))
|
||||
:height 1.2 :v-adjust 0.0 :face 'dashboard-heading))
|
||||
(t " ")))
|
||||
(insert " "))
|
||||
(defun dashboard-insert-heading (heading &optional shortcut icon)
|
||||
"Insert a widget HEADING in dashboard buffer, adding SHORTCUT, ICON if provided."
|
||||
(when (and (dashboard-display-icons-p) dashboard-set-heading-icons)
|
||||
(let ((args `( :height ,dashboard-heading-icon-height
|
||||
:v-adjust ,dashboard-heading-icon-v-adjust
|
||||
:face dashboard-heading)))
|
||||
(insert
|
||||
(pcase heading
|
||||
("Recent Files:"
|
||||
(apply #'dashboard-octicon (cdr (assoc 'recents dashboard-heading-icons)) args))
|
||||
("Bookmarks:"
|
||||
(apply #'dashboard-octicon (cdr (assoc 'bookmarks dashboard-heading-icons)) args))
|
||||
((or "Agenda for today:"
|
||||
"Agenda for the coming week:")
|
||||
(apply #'dashboard-octicon (cdr (assoc 'agenda dashboard-heading-icons)) args))
|
||||
("Registers:"
|
||||
(apply #'dashboard-octicon (cdr (assoc 'registers dashboard-heading-icons)) args))
|
||||
("Projects:"
|
||||
(apply #'dashboard-octicon (cdr (assoc 'projects dashboard-heading-icons)) args))
|
||||
("List Directories:"
|
||||
(apply #'dashboard-octicon (cdr (assoc 'ls-directories dashboard-heading-icons)) args))
|
||||
("List Files:"
|
||||
(apply #'dashboard-octicon (cdr (assoc 'ls-files dashboard-heading-icons)) args))
|
||||
(_
|
||||
(if (null icon) " " icon))))
|
||||
(insert " ")))
|
||||
|
||||
(insert (propertize heading 'face 'dashboard-heading))
|
||||
|
||||
@@ -496,7 +619,8 @@ If MESSAGEBUF is not nil then MSG is also written in message buffer."
|
||||
(goto-char start)
|
||||
(let ((width 0))
|
||||
(while (< (point) end)
|
||||
(let ((line-length (- (line-end-position) (line-beginning-position))))
|
||||
(let* ((line-str (buffer-substring (line-beginning-position) (line-end-position)))
|
||||
(line-length (dashboard-str-len line-str)))
|
||||
(setq width (max width line-length)))
|
||||
(forward-line 1))
|
||||
(let ((prefix (propertize " " 'display `(space . (:align-to (- center ,(/ width 2)))))))
|
||||
@@ -535,6 +659,8 @@ If MESSAGEBUF is not nil then MSG is also written in message buffer."
|
||||
(append (when (image-type-available-p 'png)
|
||||
(list :image dashboard-banner-logo-png))
|
||||
(list :text (dashboard-get-banner-path 1))))
|
||||
('ascii
|
||||
(append (list :text dashboard-banner-ascii)))
|
||||
((pred integerp)
|
||||
(list :text (dashboard-get-banner-path dashboard-startup-banner)))
|
||||
((pred stringp)
|
||||
@@ -580,10 +706,12 @@ Argument IMAGE-PATH path to the image."
|
||||
buffer-read-only
|
||||
text-width
|
||||
image-spec)
|
||||
(insert "\n")
|
||||
(when (display-graphic-p) (insert "\n"))
|
||||
;; If specified, insert a text banner.
|
||||
(when-let (txt (plist-get banner :text))
|
||||
(insert-file-contents txt)
|
||||
(if (eq dashboard-startup-banner 'ascii)
|
||||
(save-excursion (insert txt))
|
||||
(insert-file-contents txt))
|
||||
(put-text-property (point) (point-max) 'face 'dashboard-text-banner)
|
||||
(setq text-width 0)
|
||||
(while (not (eobp))
|
||||
@@ -687,6 +815,8 @@ Argument IMAGE-PATH path to the image."
|
||||
|
||||
(defmacro dashboard-insert-section (section-name list list-size shortcut-id shortcut-char action &rest widget-params)
|
||||
"Add a section with SECTION-NAME and LIST of LIST-SIZE items to the dashboard.
|
||||
|
||||
SHORTCUT-ID is the section identifier.
|
||||
SHORTCUT-CHAR is the keyboard shortcut used to access the section.
|
||||
ACTION is theaction taken when the user activates the widget button.
|
||||
WIDGET-PARAMS are passed to the \"widget-create\" function."
|
||||
@@ -715,22 +845,20 @@ to widget creation."
|
||||
(let ((tag ,@rest))
|
||||
(insert "\n ")
|
||||
|
||||
(when (and (display-graphic-p)
|
||||
dashboard-set-file-icons
|
||||
(or (fboundp 'all-the-icons-icon-for-dir)
|
||||
(require 'all-the-icons nil 'noerror)))
|
||||
(when (and (dashboard-display-icons-p)
|
||||
dashboard-set-file-icons)
|
||||
(let* ((path (car (last (split-string ,@rest " - "))))
|
||||
(icon (if (and (not (file-remote-p path))
|
||||
(file-directory-p path))
|
||||
(all-the-icons-icon-for-dir path nil "")
|
||||
(dashboard-icon-for-dir path nil "")
|
||||
(cond
|
||||
((or (string-equal ,section-name "Agenda for today:")
|
||||
(string-equal ,section-name "Agenda for the coming week:"))
|
||||
(all-the-icons-octicon "primitive-dot" :height 1.0 :v-adjust 0.01))
|
||||
dashboard-agenda-item-icon)
|
||||
((file-remote-p path)
|
||||
(all-the-icons-octicon "radio-tower" :height 1.0 :v-adjust 0.01))
|
||||
(t (all-the-icons-icon-for-file (file-name-nondirectory path)
|
||||
:v-adjust -0.05))))))
|
||||
dashboard-remote-path-icon)
|
||||
(t (dashboard-icon-for-file (file-name-nondirectory path)
|
||||
:v-adjust -0.05))))))
|
||||
(setq tag (concat icon " " ,@rest))))
|
||||
|
||||
(widget-create 'item
|
||||
@@ -750,12 +878,13 @@ to widget creation."
|
||||
|
||||
(defun dashboard-insert-footer ()
|
||||
"Insert footer of dashboard."
|
||||
(when-let ((footer (and dashboard-set-footer (dashboard-random-footer))))
|
||||
(when-let ((footer (and dashboard-set-footer (dashboard-random-footer)))
|
||||
(footer-icon (dashboard-replace-displayable dashboard-footer-icon)))
|
||||
(insert "\n")
|
||||
(dashboard-insert-center
|
||||
dashboard-footer-icon
|
||||
" "
|
||||
(propertize footer 'face 'dashboard-footer)
|
||||
(if (string-empty-p footer-icon) footer-icon
|
||||
(concat footer-icon " "))
|
||||
(propertize footer 'face 'dashboard-footer-face)
|
||||
"\n")))
|
||||
|
||||
;;
|
||||
@@ -933,7 +1062,10 @@ to widget creation."
|
||||
(defun dashboard-insert-recents (list-size)
|
||||
"Add the list of LIST-SIZE items from recently edited files."
|
||||
(setq dashboard--recentf-cache-item-format nil)
|
||||
(dashboard-mute-apply (recentf-mode 1) (recentf-cleanup))
|
||||
(dashboard-mute-apply
|
||||
(recentf-mode 1)
|
||||
(when dashboard-remove-missing-entry
|
||||
(ignore-errors (recentf-cleanup))))
|
||||
(dashboard-insert-section
|
||||
"Recent Files:"
|
||||
(dashboard-shorten-paths recentf-list 'dashboard-recentf-alist 'recents)
|
||||
@@ -1064,11 +1196,16 @@ Return function that returns a list of projects."
|
||||
(cl-case dashboard-projects-backend
|
||||
(`projectile
|
||||
(require 'projectile)
|
||||
(dashboard-mute-apply (projectile-cleanup-known-projects))
|
||||
(when dashboard-remove-missing-entry
|
||||
(dashboard-mute-apply
|
||||
(ignore-errors (projectile-cleanup-known-projects))))
|
||||
(projectile-load-known-projects))
|
||||
(`project-el
|
||||
(require 'project)
|
||||
(dashboard-mute-apply (dashboard-funcall-fboundp #'project-forget-zombie-projects))
|
||||
(when dashboard-remove-missing-entry
|
||||
(dashboard-mute-apply
|
||||
(ignore-errors
|
||||
(dashboard-funcall-fboundp #'project-forget-zombie-projects))))
|
||||
(project-known-project-roots))
|
||||
(t
|
||||
(display-warning '(dashboard)
|
||||
@@ -1141,6 +1278,15 @@ each agenda entry."
|
||||
:type 'string
|
||||
:group 'dashboard)
|
||||
|
||||
(defcustom dashboard-agenda-tags-format 'identity
|
||||
"Function to format the org agenda tags.
|
||||
Any custom function would receives the tags from `org-get-tags'"
|
||||
:type '(choice
|
||||
(const :tag "Show tags" identity)
|
||||
(const :tag "Hide tags" ignore)
|
||||
(function :tag "Custom function"))
|
||||
:group 'dashboard)
|
||||
|
||||
(defun dashboard-agenda-entry-format ()
|
||||
"Format agenda entry to show it on dashboard.
|
||||
Also,it set text properties that latter are used to sort entries and perform different actions."
|
||||
@@ -1153,7 +1299,7 @@ Also,it set text properties that latter are used to sort entries and perform dif
|
||||
(dashboard-agenda--formatted-headline)
|
||||
(org-outline-level)
|
||||
(org-get-category)
|
||||
(org-get-tags)))
|
||||
(dashboard-agenda--formatted-tags)))
|
||||
(todo-state (org-get-todo-state))
|
||||
(item-priority (org-get-priority (org-get-heading t t t t)))
|
||||
(todo-index (and todo-state
|
||||
@@ -1177,18 +1323,27 @@ Also,it set text properties that latter are used to sort entries and perform dif
|
||||
(todo (or (org-get-todo-state) ""))
|
||||
(org-level-face (nth (- (org-outline-level) 1) org-level-faces))
|
||||
(todo-state (format org-agenda-todo-keyword-format todo)))
|
||||
(when (null (get-text-property 0 'face headline))
|
||||
(add-face-text-property 0 (length headline) org-level-face t headline))
|
||||
(when (null (get-text-property 0 'face todo-state))
|
||||
(add-face-text-property 0 (length todo-state) (org-get-todo-face todo) t todo-state))
|
||||
(dashboard-agenda--set-face org-level-face headline)
|
||||
(dashboard-agenda--set-face (org-get-todo-face todo) todo-state)
|
||||
(concat todo-state " " headline)))
|
||||
|
||||
(defun dashboard-agenda--set-face (face text)
|
||||
"Add FACE to TEXT but inherit height from `dashboard-items-face'.
|
||||
If not height is found on FACE or `dashboard-items-face' use `default'."
|
||||
(let ((height (face-attribute 'dashboard-items-face :height nil 'default)))
|
||||
(add-face-text-property 0 (length text) `((:height ,height) ,face) nil text)))
|
||||
|
||||
(defun dashboard-agenda--formatted-time ()
|
||||
"Get the scheduled or dead time of an entry. If no time is found return nil."
|
||||
(when-let ((time (or (org-get-scheduled-time (point)) (org-get-deadline-time (point))
|
||||
(dashboard-agenda--entry-timestamp (point)))))
|
||||
(format-time-string dashboard-agenda-time-string-format time)))
|
||||
|
||||
(defun dashboard-agenda--formatted-tags ()
|
||||
"Apply `dashboard-agenda-tags-format' to org-element tags."
|
||||
(when dashboard-agenda-tags-format
|
||||
(funcall dashboard-agenda-tags-format (org-get-tags))))
|
||||
|
||||
(defun dashboard-due-date-for-agenda ()
|
||||
"Return due-date for agenda period."
|
||||
(if dashboard-week-agenda
|
||||
@@ -1202,7 +1357,8 @@ point."
|
||||
(let ((scheduled-time (org-get-scheduled-time (point)))
|
||||
(deadline-time (org-get-deadline-time (point)))
|
||||
(entry-timestamp (dashboard-agenda--entry-timestamp (point)))
|
||||
(due-date (dashboard-due-date-for-agenda)))
|
||||
(due-date (dashboard-due-date-for-agenda))
|
||||
(now (current-time)))
|
||||
(unless (and (not (org-entry-is-done-p))
|
||||
(not (org-in-archived-heading-p))
|
||||
(or (and scheduled-time
|
||||
@@ -1210,6 +1366,7 @@ point."
|
||||
(and deadline-time
|
||||
(org-time-less-p deadline-time due-date))
|
||||
(and entry-timestamp
|
||||
(org-time-less-p now entry-timestamp)
|
||||
(org-time-less-p entry-timestamp due-date))))
|
||||
(point))))
|
||||
|
||||
@@ -1247,14 +1404,16 @@ This is what `org-agenda-exit' do."
|
||||
|
||||
(defun dashboard-agenda--sorted-agenda ()
|
||||
"Return agenda sorted by time.
|
||||
For now, it only works when dashboard-agenda has been filter by time
|
||||
and dashboard-agenda-sort is not nil."
|
||||
|
||||
For now, it only works when dashboard-agenda has been filter by time and
|
||||
dashboard-agenda-sort is not nil."
|
||||
(let ((agenda (dashboard-get-agenda))
|
||||
(sort-function (dashboard-agenda--sort-function)))
|
||||
(sort agenda sort-function)))
|
||||
|
||||
(defun dashboard-agenda--sort-function ()
|
||||
"Get the function use to sorted the agenda.
|
||||
|
||||
Depending on the list `dashboard-agenda-sorting-strategy' use this strategies to
|
||||
build a predicate to compare each enty.
|
||||
This is similar as `org-entries-lessp' but with a different aproach."
|
||||
@@ -1262,6 +1421,7 @@ This is similar as `org-entries-lessp' but with a different aproach."
|
||||
|
||||
(defun dashboard-agenda--build-sort-function (strategies)
|
||||
"Build a predicate to sort the dashboard agenda.
|
||||
|
||||
If `STRATEGIES' is nil then sort using the nil predicate. Look for the strategy
|
||||
predicate, the attributes of the entry and compare entries. If no predicate is
|
||||
found for the strategy it uses nil predicate."
|
||||
|
||||
Reference in New Issue
Block a user