update packages and add valign

This commit is contained in:
2026-04-05 20:00:27 +02:00
parent b062fb98e3
commit 03fb00e374
640 changed files with 109768 additions and 39311 deletions

View File

@@ -1,6 +1,6 @@
;;; dashboard-widgets.el --- A startup screen extracted from Spacemacs -*- lexical-binding: t -*-
;; Copyright (c) 2016-2025 emacs-dashboard maintainers
;; Copyright (c) 2016-2026 emacs-dashboard maintainers
;; This file is not part of GNU Emacs.
;;
@@ -27,6 +27,7 @@
(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 ansi-color-apply-on-region "ext:ansi-color.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")
@@ -35,6 +36,8 @@
(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 dashboard-cycle-section-forward "ext:dashboard.el")
(declare-function dashboard-cycle-section-backward "ext:dashboard.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")
@@ -62,6 +65,8 @@
(declare-function org-time-string-to-time "ext:org.el")
(declare-function org-today "ext:org.el")
(declare-function recentf-cleanup "ext:recentf.el")
(declare-function ansi-color-apply-on-region "ext:ansi-color")
(defvar dashboard-mode-map)
(defvar org-level-faces)
(defvar org-agenda-new-buffers)
(defvar org-agenda-prefix-format)
@@ -251,6 +256,18 @@ nerd-icons or (all-the-icons-faicon \"newspaper-o\") using all-the-icons."
(concat dashboard-banners-directory "emacs.png")
"Emacs banner image.")
(defconst dashboard-banner-logo-ansi-256color
(concat dashboard-banners-directory "logo-256color.ans")
"Emacs banner image.")
(defconst dashboard-banner-logo-ansi-truecolor
(concat dashboard-banners-directory "logo-truecolor.ans")
"Emacs banner image.")
(defconst dashboard-banner-logo-braille
(concat dashboard-banners-directory "logo-braille.txt")
"Emacs banner image.")
(defconst dashboard-banner-logo-png
(concat dashboard-banners-directory "logo.png")
"Emacs banner image.")
@@ -261,7 +278,7 @@ nerd-icons or (all-the-icons-faicon \"newspaper-o\") using all-the-icons."
:group 'dashboard)
(defcustom dashboard-banner-ascii "EMACS"
"String to be shown in place of the startup banner
"String to be shown in place of the startup banner.
if `dashboard-startup-banner' is set to `ascii'."
:type 'string
:group 'dashboard)
@@ -409,6 +426,29 @@ It can be a string or a string list for display random icons."
Value can be
- \\='official displays the official Emacs logo.
- \\='logo displays an alternative Emacs logo.
The logo can be displayed as a PNG image, or
using unicode braille, depending on if Emacs is
running as a GUI or in no-window mode.
Assumes that the installed font includes braille.
- \\='ascii: displays the logo using ASCII characters.
- \\='logo-ansi-truecolor displays the logo using 24 bit
ANSI color escape sequences, or using unicode braille,
depending on what your device supports.
Assumes that the installed font includes braille.
Assumes the installed font includes block characters,
without adding gaps around the edges of the cell.
See Terminal Image Viewer README for more information:
https://github.com/stefanhaustein/TerminalImageViewer
- \\='logo-ansi-256color displays the logo using 256 color
ANSI color escape sequences, or using unicode braille,
depending on what your device supports.
Assumes that the installed font includes braille.
Assumes the installed font includes block characters,
without adding gaps around the edges of the cell.
See Terminal Image Viewer README for more information:
https://github.com/stefanhaustein/TerminalImageViewer
- \\='logo-braille displays the logo using unicode braille.
Assumes that the installed font includes braille.
- an integer which displays one of the text banners.
- a string that specifies the path of an custom banner
supported files types are gif/image/text/xbm.
@@ -416,9 +456,12 @@ Value can be
and other path of a text file to use if image isn't supported.
- a list that can display an random banner, supported values are:
string (filepath), \\='official, \\='logo and integers."
:type '(choice (const :tag "official" official)
(const :tag "logo" logo)
(const :tag "ascii" ascii)
:type '(choice (const :tag "official" official)
(const :tag "logo" logo)
(const :tag "ascii" ascii)
(const :tag "logo-ansi-truecolor" logo-ansi-truecolor)
(const :tag "logo-ansi-256color" logo-ansi-256color)
(const :tag "logo-braille" logo-braille)
(integer :tag "index of a text banner")
(string :tag "path to an image or text banner")
(cons :tag "image and text banner"
@@ -426,9 +469,12 @@ Value can be
(string :tag "text banner path"))
(repeat :tag "random banners"
(choice (string :tag "a path to an image or text banner")
(const :tag "official" official)
(const :tag "logo" logo)
(const :tag "ascii" ascii)
(const :tag "official" official)
(const :tag "logo" logo)
(const :tag "ascii" ascii)
(const :tag "logo-ansi-truecolor" logo-ansi-truecolor)
(const :tag "logo-ansi-256color" logo-ansi-256color)
(const :tag "logo-braille" logo-braille)
(integer :tag "index of a text banner"))))
:group 'dashboard)
@@ -589,7 +635,7 @@ Set to nil for unbounded."
;; TODO: Use function `string-pixel-width' after 29.1
(defun dashboard-string-pixel-width (str)
"Return the width of STR in pixels."
(if (fboundp #'string-pixel-width)
(if (fboundp 'string-pixel-width)
(string-pixel-width str)
(require 'shr)
(shr-string-pixel-width str)))
@@ -623,9 +669,7 @@ Set to nil for unbounded."
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'
@@ -633,17 +677,25 @@ Optionally, provide NO-NEXT-LINE to move the cursor forward a line."
;; remove symbol quote
(sym (intern (replace-regexp-in-string "'" "" (format "dashboard-jump-to-%s" shortcut-id)))))
`(progn
(eval-when-compile (defvar dashboard-mode-map))
(defun ,sym nil
,(concat "Jump to " name ".
This code is dynamically generated in `dashboard-insert-shortcut'.")
(interactive)
(unless (search-forward ,search-label (point-max) t)
(search-backward ,search-label (point-min) t))
,@(unless no-next-line '((forward-line 1)))
(back-to-indentation))
(interactive)
(unless (search-forward ,search-label (point-max) t)
(search-backward ,search-label (point-min) t))
,@(unless no-next-line '((forward-line 1)))
(back-to-indentation))
(eval-after-load 'dashboard
(define-key dashboard-mode-map ,shortcut-char ',sym)))))
(dashboard--define-shorcut-key-binding ,shortcut-id ,shortcut-char)))))
(defun dashboard--define-shorcut-key-binding (section keybinding)
"Set `cycle-section's function for SECTION to KEYBINDING.
in `dashboard-mode-map'."
(define-key dashboard-mode-map (kbd keybinding)
(dashboard-cycle-section-forward section))
(define-key dashboard-mode-map
(kbd (upcase keybinding))
(dashboard-cycle-section-backward section)))
(defun dashboard-append (msg &optional _messagebuf)
"Append MSG to dashboard buffer.
@@ -735,7 +787,17 @@ When called with TIMES return a function that insert TIMES number of newlines."
('logo
(append (when (image-type-available-p 'png)
(list :image dashboard-banner-logo-png))
(list :text (dashboard-get-banner-path 1))))
(list :text dashboard-banner-logo-braille)))
('logo-ansi-truecolor
(append (when (>= (display-color-cells) (expt 2 24))
(list :text dashboard-banner-logo-ansi-truecolor))
(list :text dashboard-banner-logo-braille)))
('logo-ansi-256color
(append (when (>= (display-color-cells) 256)
(list :text dashboard-banner-logo-ansi-256color))
(list :text dashboard-banner-logo-braille)))
('logo-braille
(append (list :text dashboard-banner-logo-braille)))
('ascii
(append (list :text dashboard-banner-ascii)))
((pred integerp)
@@ -809,6 +871,10 @@ Argument IMAGE-PATH path to the image."
(if (file-exists-p txt)
(insert-file-contents txt)
(insert txt)))
;; escape sequences will throw off text-width, must be done before
(when (member txt (list dashboard-banner-logo-ansi-256color
dashboard-banner-logo-ansi-truecolor))
(ansi-color-apply-on-region start (point-max)))
(put-text-property start (point-max) 'face 'dashboard-text-banner)
(setq text-width (dashboard--find-max-width start (point-max)))
(goto-char (point-max)))
@@ -955,33 +1021,39 @@ Return a space if icon is not found."
;;; Section list
(defmacro dashboard-insert-section-list (section-name list action &rest rest)
"Insert into SECTION-NAME a LIST of items, expanding ACTION and passing REST
to widget creation."
"Insert into SECTION-NAME a LIST of items, expanding ACTION.
REST is for widget creation."
`(when (car ,list)
(mapc
(lambda (el)
(let ((tag ,@rest))
(let* ((tag ,@rest)
(item tag))
(insert "\n")
(insert (spaces-string (or standard-indent tab-width 4)))
(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))
(dashboard-icon-for-dir path
:height dashboard-icon-file-height
:v-adjust dashboard-icon-file-v-adjust)
(cond
((or (string-equal ,section-name "Agenda for today:")
(string-equal ,section-name "Agenda for the coming week:"))
dashboard-agenda-item-icon)
((file-remote-p path)
dashboard-remote-path-icon)
(t (dashboard-icon-for-file (file-name-nondirectory path)
:height dashboard-icon-file-height
:v-adjust dashboard-icon-file-v-adjust))))))
(setq tag (concat icon " " ,@rest))))
(let* ((path (get-text-property 0 'dashboard-path item))
(icon (cond
((or (string-equal ,section-name "Agenda for today:")
(string-equal ,section-name "Agenda for the coming week:"))
dashboard-agenda-item-icon)
((and (stringp path)
(file-remote-p path))
dashboard-remote-path-icon)
((and (stringp path)
(file-directory-p path))
(dashboard-icon-for-dir
path
:height dashboard-icon-file-height
:v-adjust dashboard-icon-file-v-adjust))
((stringp path)
(dashboard-icon-for-file
(file-name-nondirectory path)
:height dashboard-icon-file-height
:v-adjust dashboard-icon-file-v-adjust))
(t ""))))
(setq tag (concat icon " " item))))
(widget-create 'item
:tag tag
@@ -992,7 +1064,6 @@ to widget creation."
:button-suffix ""
:format "%[%t%]")))
,list)))
;;
;;; Footer
@@ -1198,6 +1269,26 @@ to widget creation."
(defvar dashboard--recentf-cache-item-format nil
"Cache to record the new generated align format.")
(defun dashboard-recentf--propertize-item (el)
"Format EL from `dashboard-recentf-alist' and attach its real path."
(let* ((file (dashboard-expand-path-alist el dashboard-recentf-alist))
(filename (dashboard-f-filename file))
(path (dashboard-extract-key-path-alist el dashboard-recentf-alist))
(display
(cl-case dashboard-recentf-show-base
(`align
(unless dashboard--recentf-cache-item-format
(let* ((len-align (dashboard--align-length-by-type 'recents))
(new-fmt (dashboard--generate-align-format
dashboard-recentf-item-format len-align)))
(setq dashboard--recentf-cache-item-format new-fmt)))
(format dashboard--recentf-cache-item-format filename path))
(`nil path)
(t (format dashboard-recentf-item-format filename path)))))
(if file
(propertize display 'dashboard-path file)
display)))
(defun dashboard-insert-recents (list-size)
"Add the list of LIST-SIZE items from recently edited files."
(setq dashboard--recentf-cache-item-format nil)
@@ -1212,20 +1303,9 @@ to widget creation."
'recents
(dashboard-get-shortcut 'recents)
`(lambda (&rest _)
(find-file-existing (dashboard-expand-path-alist ,el dashboard-recentf-alist)))
(let* ((file (dashboard-expand-path-alist el dashboard-recentf-alist))
(filename (dashboard-f-filename file))
(path (dashboard-extract-key-path-alist el dashboard-recentf-alist)))
(cl-case dashboard-recentf-show-base
(`align
(unless dashboard--recentf-cache-item-format
(let* ((len-align (dashboard--align-length-by-type 'recents))
(new-fmt (dashboard--generate-align-format
dashboard-recentf-item-format len-align)))
(setq dashboard--recentf-cache-item-format new-fmt)))
(format dashboard--recentf-cache-item-format filename path))
(`nil path)
(t (format dashboard-recentf-item-format filename path))))))
(find-file-existing
(dashboard-expand-path-alist ,el dashboard-recentf-alist)))
(dashboard-recentf--propertize-item el)))
;;
;;; Bookmarks
@@ -1246,6 +1326,31 @@ to widget creation."
(defvar dashboard--bookmarks-cache-item-format nil
"Cache to record the new generated align format.")
(defun dashboard-bookmarks--format-name-and-path (filename short-path)
"Format FILENAME and SHORT-PATH according to `dashboard-bookmarks-show-base'.
Populate cache if needed."
(cl-case dashboard-bookmarks-show-base
(`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 short-path))
(`nil short-path)
(t (format dashboard-bookmarks-item-format filename short-path))))
(defun dashboard-bookmarks--propertize-name-and-path (bookmark)
"Format BOOKMARK before insertion.
Get path and name from bookmark and add `dashboard-bookmarks-name' to properties"
(if-let* ((path (bookmark-get-filename bookmark))
(short-path (dashboard-shorten-path path 'bookmarks)))
(propertize (dashboard-bookmarks--format-name-and-path
bookmark short-path)
'dashboard-bookmarks-name bookmark
'dashboard-path path)
bookmark))
(defun dashboard-insert-bookmarks (list-size)
"Add the list of LIST-SIZE items of bookmarks."
(require 'bookmark)
@@ -1256,20 +1361,7 @@ to widget creation."
'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-base
(`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 path-shorten)
(t (format dashboard-bookmarks-item-format filename path-shorten)))
el)))
(dashboard-bookmarks--propertize-name-and-path el)))
;;
;;; Projects
@@ -1318,16 +1410,21 @@ be called with the root directory of the project to switch to."
(let* ((file (dashboard-expand-path-alist el dashboard-projects-alist))
(filename (dashboard-f-base file))
(path (dashboard-extract-key-path-alist el dashboard-projects-alist)))
(cl-case dashboard-projects-show-base
(`align
(unless dashboard--projects-cache-item-format
(let* ((len-align (dashboard--align-length-by-type 'projects))
(new-fmt (dashboard--generate-align-format
dashboard-projects-item-format len-align)))
(setq dashboard--projects-cache-item-format new-fmt)))
(format dashboard--projects-cache-item-format filename path))
(`nil path)
(t (format dashboard-projects-item-format filename path))))))
(let ((display
(cl-case dashboard-projects-show-base
(`align
(unless dashboard--projects-cache-item-format
(let* ((len-align (dashboard--align-length-by-type
'projects))
(new-fmt (dashboard--generate-align-format
dashboard-projects-item-format len-align)))
(setq dashboard--projects-cache-item-format new-fmt)))
(format dashboard--projects-cache-item-format filename path))
(`nil path)
(t (format dashboard-projects-item-format filename path)))))
(if file
(propertize display 'dashboard-path file)
display)))))
(defun dashboard-projects-backend-load-projects ()
"Depending on `dashboard-projects-backend' load corresponding backend.
@@ -1344,8 +1441,8 @@ Return function that returns a list of projects."
(when dashboard-remove-missing-entry
(dashboard-mute-apply
(ignore-errors
(dashboard-funcall-fboundp #'project-forget-zombie-projects))))
(project-known-project-roots))
(dashboard-funcall-fboundp 'project-forget-zombie-projects))))
(dashboard-funcall-fboundp 'project-known-project-roots))
(t
(display-warning '(dashboard)
"Invalid value for `dashboard-projects-backend'"
@@ -1358,11 +1455,7 @@ over custom backends."
(or dashboard-projects-switch-function
(cl-case dashboard-projects-backend
(`projectile 'projectile-switch-project-by-name)
(`project-el
(lambda (project)
"This function is used to switch to `PROJECT'."
(let ((default-directory project))
(project-find-file))))
(`project-el 'project-switch-project)
(t
(display-warning '(dashboard)
"Invalid value for `dashboard-projects-backend'"
@@ -1419,13 +1512,21 @@ each agenda entry."
(defcustom dashboard-agenda-tags-format 'identity
"Function to format the org agenda tags.
Any custom function would receives the tags from `org-get-tags'"
Any custom function would receives the local tags from `org-get-tags'"
:type '(choice
(const :tag "Show tags" identity)
(const :tag "Hide tags" ignore)
(function :tag "Custom function"))
:group 'dashboard)
(defcustom dashboard-agenda-tags-scope 'local
"Scope when getting agenda tags for headline using `org-get-tags'."
:type '(choice
(const :tag "No tags" nil)
(const :tag "Local tags (default)" local)
(const :tag "Inherited tags" inherited))
:group 'dashboard)
(defun dashboard-agenda-entry-format ()
"Format agenda entry to show it on dashboard.
@@ -1481,9 +1582,14 @@ If not height is found on FACE or `dashboard-items-face' use `default'."
(format-time-string dashboard-agenda-time-string-format time)))
(defun dashboard-agenda--formatted-tags ()
"Apply `dashboard-agenda-tags-format' to org-element tags."
"Apply `dashboard-agenda-tags-format' to the list of local `org-get-tags'."
(when dashboard-agenda-tags-format
(funcall dashboard-agenda-tags-format (org-get-tags))))
(let ((tags (pcase dashboard-agenda-tags-scope
((pred null) nil)
('local (org-get-tags (point) t))
('inherited (org-get-tags))
(_ (user-error "Wrong value for `dashboard-agenda-tags-scope'")))))
(funcall dashboard-agenda-tags-format tags))))
(defun dashboard-due-date-for-agenda ()
"Return due-date for agenda period."