mirror of
https://github.com/ryuslash/mode-icons.git
synced 2024-11-21 17:40:30 +01:00
Add mode-icons-grayscale-transform option
This commit is contained in:
parent
6fe8f3d1b6
commit
fd94d1a276
2 changed files with 45 additions and 36 deletions
70
README.org
70
README.org
|
@ -28,39 +28,6 @@ Some of the modes that have icons instead of names now:
|
||||||
| Slim | [[https://raw.githubusercontent.com/rhoit/mode-icons/dump/icons/slim.png]] |
|
| Slim | [[https://raw.githubusercontent.com/rhoit/mode-icons/dump/icons/slim.png]] |
|
||||||
| YAML | [[https://raw.githubusercontent.com/rhoit/mode-icons/dump/icons/yaml.png]] |
|
| YAML | [[https://raw.githubusercontent.com/rhoit/mode-icons/dump/icons/yaml.png]] |
|
||||||
|
|
||||||
When looking at buffers with commands like ~ibuffer~, they display the
|
|
||||||
icons for the mode names as well. If you don't like this behavior you
|
|
||||||
can change ~mode-icons-change-mode-name~ to be nil:
|
|
||||||
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
|
||||||
(setq mode-icons-change-mode-name nil)
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
This only displays the icon in the plain emacs mode-line.
|
|
||||||
|
|
||||||
This may not work with enhanced mode-lines like ~poweline~ or
|
|
||||||
~smart-mode-line~, since they typically look at the ~mode-name~
|
|
||||||
variable.
|
|
||||||
|
|
||||||
Additionally, if the image icon was an ~xpm~ icon, then you can have
|
|
||||||
it changed to match your mode-line face. In the example below, the
|
|
||||||
inactive mode-line shows the emacs and yasnippet icon changed to match
|
|
||||||
the inactive mode-line:
|
|
||||||
|
|
||||||
[[http://i.imgur.com/QOM9wYM.png]]
|
|
||||||
|
|
||||||
This is enabled by default, and can be disabled by:
|
|
||||||
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
|
||||||
(setq mode-icons-desaturate-inactive nil)
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
You can also change the icon to match the active mode line (disabled by default):
|
|
||||||
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
|
||||||
(setq mode-icons-desaturate-active t)
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
* Requirements
|
* Requirements
|
||||||
|
|
||||||
As of version 0.3.0 you can also use icons from some icon fonts,
|
As of version 0.3.0 you can also use icons from some icon fonts,
|
||||||
|
@ -82,5 +49,40 @@ You can also change the icon to match the active mode line (disabled by default)
|
||||||
[[http://gnu.org/software/emacs][Emacs]] init file.
|
[[http://gnu.org/software/emacs][Emacs]] init file.
|
||||||
|
|
||||||
* Usage
|
* Usage
|
||||||
|
|
||||||
Once installed you can add =(mode-icons-mode)= to your init file.
|
Once installed you can add =(mode-icons-mode)= to your init file.
|
||||||
|
** Ignoring mode-icons in other buffers
|
||||||
|
When looking at buffers with commands like ~ibuffer~, they display the
|
||||||
|
icons for the mode names as well. If you don't like this behavior you
|
||||||
|
can change ~mode-icons-change-mode-name~ to be nil:
|
||||||
|
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(setq mode-icons-change-mode-name nil)
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
** Changing how mode-icons recolors images
|
||||||
|
Additionally, if the image icon was an ~xpm~ icon, then you can have
|
||||||
|
it changed to match your mode-line face. In the example below, the
|
||||||
|
inactive mode-line shows the emacs and yasnippet icon changed to match
|
||||||
|
the inactive mode-line:
|
||||||
|
|
||||||
|
[[http://i.imgur.com/QOM9wYM.png]]
|
||||||
|
|
||||||
|
This is enabled by default, and can be disabled by:
|
||||||
|
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(setq mode-icons-desaturate-inactive nil)
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
You can also change the icon to match the active mode line (disabled by default):
|
||||||
|
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(setq mode-icons-desaturate-active t)
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
Some of the black and white images are tagged as black and white and
|
||||||
|
are automatically recolored to match the mode-line face. You can turn this off
|
||||||
|
and use the black and white image by setting:
|
||||||
|
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(setq mode-icons-grayscale-transform nil)
|
||||||
|
#+END_SRC
|
||||||
|
|
|
@ -411,6 +411,11 @@ This only works with xpm files."
|
||||||
:type 'boolean
|
:type 'boolean
|
||||||
:group 'mode-icons)
|
:group 'mode-icons)
|
||||||
|
|
||||||
|
(defcustom mode-icons-grayscale-transform t
|
||||||
|
"Should grayscale 'xpm-bw images match mode-line colors?"
|
||||||
|
:type 'boolean
|
||||||
|
:group 'mode-icons)
|
||||||
|
|
||||||
(defvar mode-icons-get-icon-display (make-hash-table :test 'equal)
|
(defvar mode-icons-get-icon-display (make-hash-table :test 'equal)
|
||||||
"Hash table of `mode-icons-get-icon-display'.")
|
"Hash table of `mode-icons-get-icon-display'.")
|
||||||
|
|
||||||
|
@ -427,17 +432,19 @@ specified by type 'xpm-bw."
|
||||||
(face (or face (and active 'mode-line) 'mode-line-inactive))
|
(face (or face (and active 'mode-line) 'mode-line-inactive))
|
||||||
(key (list icon type face active
|
(key (list icon type face active
|
||||||
mode-icons-desaturate-inactive mode-icons-desaturate-active
|
mode-icons-desaturate-inactive mode-icons-desaturate-active
|
||||||
custom-enabled-themes)))
|
mode-icons-grayscale-transform custom-enabled-themes)))
|
||||||
(or (gethash key mode-icons-get-icon-display)
|
(or (gethash key mode-icons-get-icon-display)
|
||||||
(puthash key
|
(puthash key
|
||||||
(let ((icon-path (mode-icons-get-icon-file
|
(let ((icon-path (mode-icons-get-icon-file
|
||||||
(concat icon "." (or (and (eq type 'xpm-bw) "xpm")
|
(concat icon "." (or (and (eq type 'xpm-bw) "xpm")
|
||||||
(symbol-name type))))))
|
(symbol-name type))))))
|
||||||
(cond
|
(cond
|
||||||
((eq type 'xpm-bw)
|
((and mode-icons-grayscale-transform (eq type 'xpm-bw))
|
||||||
(create-image (mode-icons-get-icon-display-xpm-bw-face icon-path face)
|
(create-image (mode-icons-get-icon-display-xpm-bw-face icon-path face)
|
||||||
'xpm t :ascent 'center
|
'xpm t :ascent 'center
|
||||||
:face face))
|
:face face))
|
||||||
|
((eq type 'xpm-bw)
|
||||||
|
`(image :type xpm :file ,icon-path :ascent center :face ',face))
|
||||||
((and (eq type 'xpm)
|
((and (eq type 'xpm)
|
||||||
(or (and active mode-icons-desaturate-active)
|
(or (and active mode-icons-desaturate-active)
|
||||||
(and (not active) mode-icons-desaturate-inactive)))
|
(and (not active) mode-icons-desaturate-inactive)))
|
||||||
|
|
Loading…
Reference in a new issue