update packages

This commit is contained in:
2021-01-08 19:32:30 +01:00
parent ce8f24d28a
commit f5649dceab
467 changed files with 26642 additions and 22487 deletions

View File

@@ -1,6 +1,6 @@
;;; treemacs.el --- A tree style file viewer package -*- lexical-binding: t -*-
;; Copyright (C) 2020 Alexander Miller
;; Copyright (C) 2021 Alexander Miller
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
@@ -39,7 +39,7 @@
;; gap wherever treemacs places an icon, regardess of transparency.
;; Using xpm instead of png images is one way to work around this, but it degrades icon
;; quality to an unacceptable degree. Another way is to directly change images' :background
;; property. The backgrounds colors are derived from the current theme with `treemacs--setup-icon-highlight'
;; property. The backgrounds colours are derived from the current theme with `treemacs--setup-icon-highlight'
;; and saved in `treemacs--selected-icon-background' and `treemacs--not-selected-icon-background'.
;; Every icon string stores two images with the proper :background values in its properties
;; 'img-selected and 'img-unselected. The 'display property of the icon in the current line
@@ -53,12 +53,12 @@
(pcase (face-attribute 'default :background nil t)
('unspecified
(prog1 "#2d2d31"
(unless (boundp 'treemacs-no-load-time-warnings)
(message "[Treemacs] Warning: coudn't find default background color for icons, falling back on #2d2d31."))))
(unless (or noninteractive (boundp 'treemacs-no-load-time-warnings))
(message "[Treemacs] Warning: coudn't find default background colour for icons, falling back on #2d2d31."))))
('unspecified-bg
(prog1 "#2d2d31"
(unless (boundp 'treemacs-no-load-time-warnings)
(message "[Treemacs] Warning: background color is unspecified, icons will likely look wrong. Falling back on #2d2d31."))))
(unless (or noninteractive (boundp 'treemacs-no-load-time-warnings))
(message "[Treemacs] Warning: background colour is unspecified, icons will likely look wrong. Falling back on #2d2d31."))))
(other other)))
"Background for non-selected icons.")
@@ -67,7 +67,7 @@
(-let [bg (face-attribute 'hl-line :background nil t)]
(if (memq bg '(unspecified unspecified-b))
(prog1 treemacs--not-selected-icon-background
(unless (boundp 'treemacs-no-load-time-warnings)
(unless (or noninteractive (boundp 'treemacs-no-load-time-warnings))
(message "[Treemacs] Warning: couldn't find hl-line-mode's background color for icons, falling back on %s."
treemacs--not-selected-icon-background)))
bg)))
@@ -106,13 +106,24 @@ does not exist."
`(treemacs-theme->gui-icons theme))))
(ht-get icons ,ext)))
(define-inline treemacs--get-local-face-background (face)
"Get the `:background' of the given face.
Unlike `face-attribute' this will take the `faces-remapping-alist' into
account."
(declare (side-effect-free t))
(inline-letevals (face)
(inline-quote
(--if-let (car (alist-get ,face face-remapping-alist))
(plist-get it :background)
(face-attribute ,face :background nil t)))))
(defun treemacs--setup-icon-background-colors (&rest _)
"Align icon backgrounds with current Emacs theme.
Fetch the current Emacs theme's background & hl-line colors and inject them into
the gui icons of every theme in `treemacs--themes'.
Fetch the current Emacs theme's background & hl-line colours and inject them
into the gui icons of every theme in `treemacs--themes'.
Also called as advice after `load-theme', hence the ignored argument."
(let* ((default-background (face-attribute 'default :background nil t))
(hl-line-background (face-attribute 'hl-line :background nil t))
(let* ((default-background (treemacs--get-local-face-background 'default))
(hl-line-background (treemacs--get-local-face-background 'hl-line))
(test-icon (treemacs-get-icon-value 'dir-open))
(icon-background (treemacs--get-img-property (get-text-property 0 'img-unselected test-icon) :background))
(icon-hl-background (treemacs--get-img-property (get-text-property 0 'img-selected test-icon) :background)))
@@ -157,7 +168,7 @@ Aliased to the current theme's gui or tui icons.")
"List of icons with variables.
Every symbol S maps to a variable named \"treemacs-icons-S\". In addition S is
also the key for the icon in both `treemacs-gui-icons' and `treemacs-tui-icons'.
This combination alllows these icons-with-variables to be correctly changed in
This combination allows these icons-with-variables to be correctly changed in
`treemacs--select-icon-set'.")
(defvar treemacs--icon-size 22
@@ -181,11 +192,11 @@ Necessary since root icons are not rectangular."
(let ((height treemacs--icon-size)
(width treemacs--icon-size))
(when (and (integerp treemacs--icon-size)
(s-ends-with? "root.png" ,file-path))
(s-starts-with? "root-" ,file-path))
(treemacs--root-icon-size-adjust width height))
(if (and (integerp treemacs--icon-size) (image-type-available-p 'imagemagick))
(create-image ,file-path 'imagemagick nil :ascent 'center :width width :height height)
(create-image ,file-path 'png nil :ascent 'center))))))
(create-image ,file-path 'png nil :ascent 'center :width width :height height))))))
(define-inline treemacs--create-icon-strings (file fallback)
"Create propertized icon strings for a given FILE image and TUI FALLBACK."
@@ -215,17 +226,17 @@ Necessary since root icons are not rectangular."
(cl-defmacro treemacs-create-icon (&key file icon (fallback " ") icons-dir extensions)
"Create an icon for the current theme.
- FILE is a file path relative to the icon directory of the current theme.
- ICON is a string of an already created icon. Mutually exclusive with FILE.
- ICON is a string of an already created icon. Mutually exclusive with FILE.
- FALLBACK is the fallback string for situations where png images are
unavailable.
- ICONS-DIR can optionally be used to overwrite the path used to find icons.
Normally the current theme's icon-path is used, but it may be convenient to
use another when calling `treemacs-modify-theme'.
- FALLBACK is the fallback string for situations where png images are
unavailable.
- EXTENSIONS is a list of file extensions the icon should be used for.
Note that treemacs has a loose understanding of what constitutes an extension:
it's either the text past the last period or the entire filename, so names
like \".gitignore\" and \"Makefile\" can be matched as well.
An extension may also be a symbol instead of a string. In this case treemacs
An extension may also be a symbol instead of a string. In this case treemacs
will also create a variable named \"treemacs-icon-%s\" making it universally
accessible."
(treemacs-static-assert (or (null icon) (null file))
@@ -258,25 +269,28 @@ Necessary since root icons are not rectangular."
:config
(progn
;; directory and other icons
(treemacs-create-icon :file "vsc/root-closed.png" :extensions (root) :fallback "")
(treemacs-create-icon :file "vsc/dir-closed.png" :extensions (dir-closed) :fallback (propertize "+ " 'face 'treemacs-term-node-face))
(treemacs-create-icon :file "vsc/dir-open.png" :extensions (dir-open) :fallback (propertize "- " 'face 'treemacs-term-node-face))
(treemacs-create-icon :file "tags-leaf.png" :extensions (tag-leaf) :fallback (propertize "" 'face 'font-lock-constant-face))
(treemacs-create-icon :file "tags-open.png" :extensions (tag-open) :fallback (propertize " " 'face 'font-lock-string-face))
(treemacs-create-icon :file "tags-closed.png" :extensions (tag-closed) :fallback (propertize " " 'face 'font-lock-string-face))
(treemacs-create-icon :file "error.png" :extensions (error) :fallback (propertize "" 'face 'font-lock-string-face))
(treemacs-create-icon :file "warning.png" :extensions (warning) :fallback (propertize " " 'face 'font-lock-string-face))
(treemacs-create-icon :file "info.png" :extensions (info) :fallback (propertize " " 'face 'font-lock-string-face))
(treemacs-create-icon :file "mail.png" :extensions (mail) :fallback " ")
(treemacs-create-icon :file "bookmark.png" :extensions (bookmark) :fallback " ")
(treemacs-create-icon :file "svgrepo/screen.png" :extensions (screen) :fallback " ")
(treemacs-create-icon :file "svgrepo/house.png" :extensions (house) :fallback " ")
(treemacs-create-icon :file "svgrepo/list.png" :extensions (list) :fallback " ")
(treemacs-create-icon :file "svgrepo/repeat.png" :extensions (repeat) :fallback " ")
(treemacs-create-icon :file "svgrepo/suitcase.png" :extensions (suitcase) :fallback " ")
(treemacs-create-icon :file "svgrepo/close.png" :extensions (close) :fallback " ")
(treemacs-create-icon :file "svgrepo/cal.png" :extensions (calendar) :fallback " ")
(treemacs-create-icon :file "svgrepo/briefcase.png" :extensions (briefcase) :fallback " ")
;; TODO(2020/12/30): temporary workaround for issues like #752, to be removed in 2 months
(treemacs-create-icon :file "vsc/root-closed.png" :extensions (root) :fallback "")
(treemacs-create-icon :file "vsc/root-closed.png" :extensions (root-closed) :fallback "")
(treemacs-create-icon :file "vsc/root-open.png" :extensions (root-open) :fallback "")
(treemacs-create-icon :file "vsc/dir-closed.png" :extensions (dir-closed) :fallback (propertize "+ " 'face 'treemacs-term-node-face))
(treemacs-create-icon :file "vsc/dir-open.png" :extensions (dir-open) :fallback (propertize "- " 'face 'treemacs-term-node-face))
(treemacs-create-icon :file "tags-leaf.png" :extensions (tag-leaf) :fallback (propertize "" 'face 'font-lock-constant-face))
(treemacs-create-icon :file "tags-open.png" :extensions (tag-open) :fallback (propertize " " 'face 'font-lock-string-face))
(treemacs-create-icon :file "tags-closed.png" :extensions (tag-closed) :fallback (propertize " " 'face 'font-lock-string-face))
(treemacs-create-icon :file "error.png" :extensions (error) :fallback (propertize " " 'face 'font-lock-string-face))
(treemacs-create-icon :file "warning.png" :extensions (warning) :fallback (propertize " " 'face 'font-lock-string-face))
(treemacs-create-icon :file "info.png" :extensions (info) :fallback (propertize " " 'face 'font-lock-string-face))
(treemacs-create-icon :file "mail.png" :extensions (mail) :fallback " ")
(treemacs-create-icon :file "bookmark.png" :extensions (bookmark) :fallback " ")
(treemacs-create-icon :file "svgrepo/screen.png" :extensions (screen) :fallback " ")
(treemacs-create-icon :file "svgrepo/house.png" :extensions (house) :fallback " ")
(treemacs-create-icon :file "svgrepo/list.png" :extensions (list) :fallback " ")
(treemacs-create-icon :file "svgrepo/repeat.png" :extensions (repeat) :fallback " ")
(treemacs-create-icon :file "svgrepo/suitcase.png" :extensions (suitcase) :fallback " ")
(treemacs-create-icon :file "svgrepo/close.png" :extensions (close) :fallback " ")
(treemacs-create-icon :file "svgrepo/cal.png" :extensions (calendar) :fallback " ")
(treemacs-create-icon :file "svgrepo/briefcase.png" :extensions (briefcase) :fallback " ")
;; file icons
(treemacs-create-icon :file "txt.png" :extensions (fallback))
@@ -391,7 +405,7 @@ Necessary since root icons are not rectangular."
(treemacs-create-icon :file "vsc/locale.png" :extensions ("locale"))
(treemacs-create-icon :file "vsc/manifest.png" :extensions ("manifest"))
(treemacs-create-icon :file "vsc/maven.png" :extensions ("pom.xml" "maven.config" "extensions.xml" "settings.xml"))
(treemacs-create-icon :file "vsc/meson.png" :extensions ("meson"))
(treemacs-create-icon :file "vsc/meson.png" :extensions ("meson" "meson.build"))
(treemacs-create-icon :file "vsc/nginx.png" :extensions ("nginx.conf" "nginx"))
(treemacs-create-icon :file "vsc/npm.png" :extensions ("npmignore" "npmrc" "package.json" "package-lock.json" "npm-shrinwrap.json"))
(treemacs-create-icon :file "vsc/wasm.png" :extensions ("wasm" "wat"))
@@ -433,11 +447,10 @@ Uses `treemacs-icon-fallback' as fallback."
(inline-letevals (file)
(inline-quote
(let ((file-downcased (-> ,file (treemacs--filename) (downcase))))
(ht-get treemacs-icons
file-downcased
(ht-get treemacs-icons
(treemacs--file-extension file-downcased)
(with-no-warnings treemacs-icon-fallback)))))))
(or (ht-get treemacs-icons file-downcased)
(ht-get treemacs-icons
(treemacs--file-extension file-downcased)
(with-no-warnings treemacs-icon-fallback)))))))
;;;###autoload
(defun treemacs-resize-icons (size)
@@ -509,7 +522,7 @@ name if there is no period. This makes it possible to match file names like
'.gitignore' and 'Makefile'.
Additionally FILE-EXTENSIONS are also not case sensitive and will be stored in a
downcased state."
down-cased state."
(unless icon
(user-error "Custom icon cannot be nil"))
(dolist (ext file-extensions)
@@ -523,7 +536,7 @@ downcased state."
EXTENSIONS should be a list of file extensions such that they match the regex
stored in `auto-mode-alist', for example '\(\".cc\"\).
MODE-ICON-ALIST is an alist that maps which mode from `auto-mode-alist' should
be assigned which treemacs icon, for exmaple
be assigned which treemacs icon, for example
'\(\(c-mode . treemacs-icon-c\)
\(c++-mode . treemacs-icon-cpp\)\)"
(dolist (extension extensions)