diff --git a/README.org b/README.org index 228be99..0fba777 100644 --- a/README.org +++ b/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]] | | 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 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. * Usage - 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 diff --git a/mode-icons.el b/mode-icons.el index c05a134..336d18b 100644 --- a/mode-icons.el +++ b/mode-icons.el @@ -411,6 +411,11 @@ This only works with xpm files." :type 'boolean :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) "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)) (key (list icon type face 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) (puthash key (let ((icon-path (mode-icons-get-icon-file (concat icon "." (or (and (eq type 'xpm-bw) "xpm") (symbol-name type)))))) (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) 'xpm t :ascent 'center :face face)) + ((eq type 'xpm-bw) + `(image :type xpm :file ,icon-path :ascent center :face ',face)) ((and (eq type 'xpm) (or (and active mode-icons-desaturate-active) (and (not active) mode-icons-desaturate-inactive)))