update packages
This commit is contained in:
@@ -16,8 +16,10 @@
|
||||
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
;;; Most of everything related to icons is handled here. Specifically the
|
||||
;;; definition, instantiation, customization, resizing and resetting of icons.
|
||||
|
||||
;; Most of everything related to icons is handled here. Specifically
|
||||
;; the definition, instantiation, customization, resizing and
|
||||
;; resetting of icons.
|
||||
|
||||
;;; Code:
|
||||
|
||||
@@ -51,21 +53,17 @@
|
||||
(eval-and-compile
|
||||
(defvar treemacs--not-selected-icon-background
|
||||
(pcase (face-attribute 'default :background nil t)
|
||||
('unspecified
|
||||
(prog1 "#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 (or noninteractive (boundp 'treemacs-no-load-time-warnings))
|
||||
(message "[Treemacs] Warning: background colour is unspecified, icons will likely look wrong. Falling back on #2d2d31."))))
|
||||
((or 'unspecified 'unspecified-bg "unspecified" "unspecified-bg")
|
||||
(unless (or noninteractive (boundp 'treemacs-no-load-time-warnings))
|
||||
(message "[Treemacs] Warning: coudn't find default background colour for icons, falling back on #2d2d31."))
|
||||
"#2d2d31" )
|
||||
(other other)))
|
||||
"Background for non-selected icons.")
|
||||
|
||||
(eval-and-compile
|
||||
(defvar treemacs--selected-icon-background
|
||||
(-let [bg (face-attribute 'hl-line :background nil t)]
|
||||
(if (memq bg '(unspecified unspecified-b))
|
||||
(if (member bg '(unspecified unspecified-b "unspecified" "unspecified-bg"))
|
||||
(prog1 treemacs--not-selected-icon-background
|
||||
(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."
|
||||
@@ -148,7 +146,7 @@ Also called as advice after `load-theme', hence the ignored argument."
|
||||
"Will return non-nil when Emacs is unable to create images.
|
||||
In this scenario (usually caused by running Emacs without a graphical
|
||||
environment) treemacs will not create any of its icons and will be forced to
|
||||
permanently use its simple string icon fallack."
|
||||
permanently use its simple string icon fallback."
|
||||
(declare (pure t) (side-effect-free t))
|
||||
(inline-quote (not (image-type-available-p 'png))))
|
||||
|
||||
@@ -228,7 +226,7 @@ Necessary since root icons are not rectangular."
|
||||
- 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.
|
||||
- FALLBACK is the fallback string for situations where png images are
|
||||
unavailable.
|
||||
unavailable. Can be set to `same-as-icon' to use the same value as ICON.
|
||||
- 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'.
|
||||
@@ -241,36 +239,39 @@ Necessary since root icons are not rectangular."
|
||||
accessible."
|
||||
(treemacs-static-assert (or (null icon) (null file))
|
||||
"FILE and ICON arguments are mutually exclusive")
|
||||
`(let* ((icons-dir ,(if icons-dir icons-dir `(treemacs-theme->path treemacs--current-theme)))
|
||||
(icon-path ,(if file `(f-join icons-dir ,file) nil))
|
||||
(icon-pair ,(if file `(treemacs--create-icon-strings icon-path ,fallback)
|
||||
`(cons ,(treemacs--splice-icon icon) ,fallback)))
|
||||
(gui-icons (treemacs-theme->gui-icons treemacs--current-theme))
|
||||
(tui-icons (treemacs-theme->tui-icons treemacs--current-theme))
|
||||
(gui-icon (car icon-pair))
|
||||
(tui-icon (cdr icon-pair)))
|
||||
,(unless file
|
||||
`(progn
|
||||
(ignore icon-path)
|
||||
(ignore icons-dir)))
|
||||
;; prefer to have icons as empty strings with a display property for compatibility
|
||||
;; in e.g. dired, where an actual text icon would break `dired-goto-file-1'
|
||||
(unless (get-text-property 0 'display gui-icon)
|
||||
(setf gui-icon (propertize " " 'display gui-icon)))
|
||||
,@(->> (-filter #'symbolp extensions)
|
||||
(--map `(progn (add-to-list 'treemacs--icon-symbols ',it)
|
||||
(defvar ,(intern (format "treemacs-icon-%s" it)) nil))))
|
||||
(--each ',extensions
|
||||
(ht-set! gui-icons it gui-icon)
|
||||
(ht-set! tui-icons it tui-icon))))
|
||||
(-let [ext-list (--map (if (stringp it) (downcase it) it)
|
||||
(if (symbolp extensions) (symbol-value extensions) extensions))]
|
||||
`(let* ((fallback ,(if (equal fallback (quote 'same-as-icon))
|
||||
icon
|
||||
fallback))
|
||||
(icons-dir ,(if icons-dir icons-dir `(treemacs-theme->path treemacs--current-theme)))
|
||||
(icon-path ,(if file `(treemacs-join-path icons-dir ,file) nil))
|
||||
(icon-pair ,(if file `(treemacs--create-icon-strings icon-path fallback)
|
||||
`(cons ,(treemacs--splice-icon icon) fallback)))
|
||||
(gui-icons (treemacs-theme->gui-icons treemacs--current-theme))
|
||||
(tui-icons (treemacs-theme->tui-icons treemacs--current-theme))
|
||||
(gui-icon (car icon-pair))
|
||||
(tui-icon (cdr icon-pair)))
|
||||
,(unless file
|
||||
`(progn
|
||||
(ignore icon-path)
|
||||
(ignore icons-dir)))
|
||||
;; prefer to have icons as empty strings with a display property for compatibility
|
||||
;; in e.g. dired, where an actual text icon would break `dired-goto-file-1'
|
||||
(unless (get-text-property 0 'display gui-icon)
|
||||
(setf gui-icon (propertize " " 'display gui-icon)))
|
||||
,@(->> (-filter #'symbolp ext-list)
|
||||
(--map `(progn (add-to-list 'treemacs--icon-symbols ',it)
|
||||
(defvar ,(intern (format "treemacs-icon-%s" it)) nil))))
|
||||
(--each (quote ,ext-list)
|
||||
(ht-set! gui-icons it gui-icon)
|
||||
(ht-set! tui-icons it tui-icon)))))
|
||||
|
||||
(treemacs-create-theme "Default"
|
||||
:icon-directory (f-join treemacs-dir "icons/default")
|
||||
:icon-directory (treemacs-join-path treemacs-dir "icons/default")
|
||||
:config
|
||||
(progn
|
||||
;; directory and other icons
|
||||
;; 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))
|
||||
@@ -297,7 +298,10 @@ Necessary since root icons are not rectangular."
|
||||
(treemacs-create-icon :file "emacs.png" :extensions ("el" "elc"))
|
||||
(treemacs-create-icon :file "ledger.png" :extensions ("ledger"))
|
||||
(treemacs-create-icon :file "yaml.png" :extensions ("yml" "yaml" "travis.yml"))
|
||||
(treemacs-create-icon :file "shell.png" :extensions ("sh" "zsh" "fish"))
|
||||
(treemacs-create-icon
|
||||
:file "shell.png"
|
||||
:extensions ("sh" "zsh" "zshrc" "zshenv" "fish" "zprofile" "zlogin" "zlogout" "bash"
|
||||
"bash_profile" "bashrc" "bash_login" "profile" "bash_aliases"))
|
||||
(treemacs-create-icon :file "pdf.png" :extensions ("pdf"))
|
||||
(treemacs-create-icon :file "c.png" :extensions ("c" "h"))
|
||||
(treemacs-create-icon :file "haskell.png" :extensions ("hs" "lhs"))
|
||||
@@ -308,7 +312,6 @@ Necessary since root icons are not rectangular."
|
||||
(treemacs-create-icon :file "asciidoc.png" :extensions ("adoc" "asciidoc"))
|
||||
(treemacs-create-icon :file "rust.png" :extensions ("rs"))
|
||||
(treemacs-create-icon :file "image.png" :extensions ("jpg" "jpeg" "bmp" "svg" "png" "xpm" "gif"))
|
||||
(treemacs-create-icon :file "emacs.png" :extensions ("el" "elc"))
|
||||
(treemacs-create-icon :file "clojure.png" :extensions ("clj" "cljs" "cljc"))
|
||||
(treemacs-create-icon :file "ts.png" :extensions ("ts" "tsx"))
|
||||
(treemacs-create-icon :file "vue.png" :extensions ("vue"))
|
||||
@@ -320,6 +323,7 @@ Necessary since root icons are not rectangular."
|
||||
(treemacs-create-icon :file "jar.png" :extensions ("jar"))
|
||||
(treemacs-create-icon :file "kotlin.png" :extensions ("kt"))
|
||||
(treemacs-create-icon :file "scala.png" :extensions ("scala"))
|
||||
(treemacs-create-icon :file "gradle.png" :extensions ("gradle"))
|
||||
(treemacs-create-icon :file "sbt.png" :extensions ("sbt"))
|
||||
(treemacs-create-icon :file "go.png" :extensions ("go"))
|
||||
(treemacs-create-icon :file "systemd.png" :extensions ("service" "timer"))
|
||||
@@ -433,7 +437,7 @@ Necessary since root icons are not rectangular."
|
||||
(treemacs-create-icon :file "vsc/sql.png" :extensions ("sql"))
|
||||
(treemacs-create-icon :file "vsc/toml.png" :extensions ("toml"))
|
||||
(treemacs-create-icon :file "vsc/nim.png" :extensions ("nim"))
|
||||
(treemacs-create-icon :file "vsc/org.png" :extensions ("org"))
|
||||
(treemacs-create-icon :file "vsc/org.png" :extensions ("org" "org_archive"))
|
||||
(treemacs-create-icon :file "vsc/perl.png" :extensions ("pl" "pm" "perl"))
|
||||
(treemacs-create-icon :file "vsc/vim.png" :extensions ("vimrc" "tridactylrc" "vimperatorrc" "ideavimrc" "vrapperrc"))
|
||||
(treemacs-create-icon :file "vsc/deps.png" :extensions ("cask"))
|
||||
@@ -530,6 +534,20 @@ down-cased state."
|
||||
(downcase ext)
|
||||
(concat icon " "))))
|
||||
|
||||
;;;###autoload
|
||||
(defun treemacs-define-custom-image-icon (file &rest file-extensions)
|
||||
"Same as `treemacs-define-custom-icon' but for image icons instead of strings.
|
||||
FILE is the path to an icon image (and not the actual icon string).
|
||||
FILE-EXTENSIONS are all the (not case-sensitive) file extensions the icon
|
||||
should be used for."
|
||||
(unless file
|
||||
(user-error "Custom icon cannot be nil"))
|
||||
(-let [icon (car (treemacs--create-icon-strings file " "))]
|
||||
(dolist (ext file-extensions)
|
||||
(ht-set! (treemacs-theme->gui-icons treemacs--current-theme)
|
||||
(downcase ext)
|
||||
icon))))
|
||||
|
||||
;;;###autoload
|
||||
(defun treemacs-map-icons-with-auto-mode-alist (extensions mode-icon-alist)
|
||||
"Remaps icons for EXTENSIONS according to `auto-mode-alist'.
|
||||
|
||||
Reference in New Issue
Block a user