From cc0e6f241c6a64152d912b5b7a9d50a2035e7b3d Mon Sep 17 00:00:00 2001 From: kissge Date: Tue, 10 Jan 2017 22:08:39 +0900 Subject: [PATCH 1/3] Fix the wrong color replacement problem in xpm images With specific color combinations, some of the colors could be replaced twice. This commit avoids that problem. --- mode-icons.el | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mode-icons.el b/mode-icons.el index 4556133..28b06f1 100644 --- a/mode-icons.el +++ b/mode-icons.el @@ -318,9 +318,15 @@ If ICON-PATH is a string, return that." "Get xpm image from ICON-PATH and reaplce REP-ALIST in file. When NAME is non-nil, also replace the internal xpm image name." (let ((case-fold-search t) - (img (mode-icons-get-xpm-string icon-path))) + (img (mode-icons-get-xpm-string icon-path)) + (i 0)) (dolist (c rep-alist) - (setq img (replace-regexp-in-string (regexp-quote (car c)) (cdr c) img t t))) + (setq img (replace-regexp-in-string (regexp-quote (car c)) (format "COLOR<%d>" i) img t t) + i (1+ i))) + (let ((i 0)) + (dolist (c rep-alist) + (setq img (replace-regexp-in-string (format "COLOR<%d>" i) (cdr c) img t t) + i (1+ i)))) (when name (setq img (replace-regexp-in-string "^[ ]*static[ ]+char[ ]+[*][ ]+.*?\\[" (concat "static char * " name "[") img t t))) img)) From 4d333f3c5d10aaefffd36934dd3a1e78ea90a615 Mon Sep 17 00:00:00 2001 From: kissge Date: Tue, 10 Jan 2017 22:08:58 +0900 Subject: [PATCH 2/3] Fix typo --- mode-icons.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mode-icons.el b/mode-icons.el index 28b06f1..2a6e30c 100644 --- a/mode-icons.el +++ b/mode-icons.el @@ -315,7 +315,7 @@ If ICON-PATH is a string, return that." (and (stringp icon-path) icon-path))) (defun mode-icons-get-icon-display-xpm-replace (icon-path rep-alist &optional name) - "Get xpm image from ICON-PATH and reaplce REP-ALIST in file. + "Get xpm image from ICON-PATH and replace REP-ALIST in file. When NAME is non-nil, also replace the internal xpm image name." (let ((case-fold-search t) (img (mode-icons-get-xpm-string icon-path)) @@ -389,7 +389,7 @@ In order, will try to get the foreground color from: "Change xpm at ICON-PATH to match FACE. The white is changed to the background color. The black is changed to the foreground color. -Grayscale colors are aslo changed by `mode-icons-interpolate-from-scale'." +Grayscale colors are also changed by `mode-icons-interpolate-from-scale'." (let* ((background (mode-icons-background-color face)) (foreground (mode-icons-foreground-color face)) (lst (mode-icons-interpolate-from-scale foreground background)) From f843f06b84f5ee1a29147e9fe1d782353ec7afe0 Mon Sep 17 00:00:00 2001 From: kissge Date: Tue, 10 Jan 2017 22:17:42 +0900 Subject: [PATCH 3/3] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88e8e3b..c020100 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). missing from the system - mode-icons now allows for a default icon. This can be turned on with the new option `mode-icons-use-default-icon` +- Fix coloring algorithm for xpm images. ## [0.4.0]