Save buffer state more often

This commit is contained in:
Matthew Fidler 2016-04-21 08:20:36 -05:00
parent 46b2659225
commit 7a12fb28d2

View file

@ -285,7 +285,7 @@ without the extension. And the third being the type of icon."
If ICON-PATH is a string, return that." If ICON-PATH is a string, return that."
(or (and (file-exists-p icon-path) (or (and (file-exists-p icon-path)
(or (gethash icon-path mode-icons-get-xpm-string) (or (gethash icon-path mode-icons-get-xpm-string)
(puthash icon-path (with-temp-buffer (insert-file-contents icon-path) (buffer-string)) (puthash icon-path (mode-icons-save-buffer-state (with-temp-buffer (insert-file-contents icon-path) (buffer-string)))
mode-icons-get-xpm-string))) mode-icons-get-xpm-string)))
(and (stringp icon-path) icon-path))) (and (stringp icon-path) icon-path)))
@ -349,11 +349,12 @@ Grayscale colors are aslo changed by `mode-icons-interpolate-from-scale'."
"Get a list of rgb colors based on ICON-PATH xpm icon. "Get a list of rgb colors based on ICON-PATH xpm icon.
ICON-PATH can be a XPM string or a XPM file." ICON-PATH can be a XPM string or a XPM file."
(let (colors) (let (colors)
(mode-icons-save-buffer-state
(with-temp-buffer (with-temp-buffer
(insert (mode-icons-get-xpm-string icon-path)) (insert (mode-icons-get-xpm-string icon-path))
(goto-char (point-min)) (goto-char (point-min))
(while (re-search-forward "#[0-9A-Fa-f]\\{6\\}" nil t) (while (re-search-forward "#[0-9A-Fa-f]\\{6\\}" nil t)
(push (color-name-to-rgb (match-string 0)) colors))) (push (color-name-to-rgb (match-string 0)) colors))))
colors)) colors))
(defun mode-icons-desaturate-colors (colors &optional foreground background) (defun mode-icons-desaturate-colors (colors &optional foreground background)
@ -1109,6 +1110,7 @@ ACTIVE if a flag for if the current window is active."
xpm-name 'xpm face active) xpm-name 'xpm face active)
'mode-icons-p (list (nth 0 icon-spec) xpm-name 'xpm-bw) 'mode-icons-p (list (nth 0 icon-spec) xpm-name 'xpm-bw)
'face face) 'face face)
(mode-icons-save-buffer-state
(with-temp-buffer (with-temp-buffer
(if (stringp mode) (if (stringp mode)
(insert mode) (insert mode)
@ -1122,7 +1124,7 @@ ACTIVE if a flag for if the current window is active."
'face face) 'face face)
(put-text-property (point-min) (point-max) (put-text-property (point-min) (point-max)
'mode-icons-p icon-spec) 'mode-icons-p icon-spec)
(buffer-string))))) (buffer-string))))))
(defun mode-icons-propertize-mode (mode icon-spec &optional face active) (defun mode-icons-propertize-mode (mode icon-spec &optional face active)
"Propertize MODE with ICON-SPEC. "Propertize MODE with ICON-SPEC.