mirror of
https://github.com/ryuslash/mode-icons.git
synced 2024-11-22 01:50:28 +01:00
Speed up mode-line calculation
This commit is contained in:
parent
a18ec9cfc7
commit
3388b75efe
1 changed files with 34 additions and 24 deletions
|
@ -330,6 +330,9 @@ Grayscale colors are aslo changed by `mode-icons-interpolate-from-scale'."
|
||||||
(or (gethash sym mode-icons-get-icon-display-xpm-bw-face)
|
(or (gethash sym mode-icons-get-icon-display-xpm-bw-face)
|
||||||
(puthash sym (mode-icons-get-icon-display-xpm-replace icon-path lst name) mode-icons-get-icon-display-xpm-bw-face))))
|
(puthash sym (mode-icons-get-icon-display-xpm-replace icon-path lst name) mode-icons-get-icon-display-xpm-bw-face))))
|
||||||
|
|
||||||
|
(defvar mode-icons-get-icon-display (make-hash-table :test 'equal)
|
||||||
|
"Hash table of `mode-icons-get-icon-display'.")
|
||||||
|
|
||||||
(defun mode-icons-get-icon-display (icon type &optional face)
|
(defun mode-icons-get-icon-display (icon type &optional face)
|
||||||
"Get the value for the display property of ICON having TYPE.
|
"Get the value for the display property of ICON having TYPE.
|
||||||
|
|
||||||
|
@ -339,14 +342,17 @@ the icon.
|
||||||
|
|
||||||
FACE should be the face for rendering black and white xpm icons
|
FACE should be the face for rendering black and white xpm icons
|
||||||
specified by type 'xpm-bw."
|
specified by type 'xpm-bw."
|
||||||
(let ((icon-path (mode-icons-get-icon-file
|
(or (gethash (list icon type (or face 'mode-line)) mode-icons-get-icon-display)
|
||||||
(concat icon "." (or (and (eq type 'xpm-bw) "xpm")
|
(puthash (list icon type (or face 'mode-line))
|
||||||
(symbol-name type))))))
|
(let ((icon-path (mode-icons-get-icon-file
|
||||||
(if (eq type 'xpm-bw)
|
(concat icon "." (or (and (eq type 'xpm-bw) "xpm")
|
||||||
(create-image (mode-icons-get-icon-display-xpm-bw-face icon-path face)
|
(symbol-name type))))))
|
||||||
'xpm t :ascent 'center
|
(if (eq type 'xpm-bw)
|
||||||
:face (or face 'mode-line))
|
(create-image (mode-icons-get-icon-display-xpm-bw-face icon-path face)
|
||||||
`(image :type ,(or (and (eq type 'jpg) 'jpeg) type) :file ,icon-path :ascent center))))
|
'xpm t :ascent 'center
|
||||||
|
:face (or face 'mode-line))
|
||||||
|
`(image :type ,(or (and (eq type 'jpg) 'jpeg) type) :file ,icon-path :ascent center)))
|
||||||
|
mode-icons-get-icon-display)))
|
||||||
|
|
||||||
(defcustom mode-icons-minor-mode-base-text-properties
|
(defcustom mode-icons-minor-mode-base-text-properties
|
||||||
'('help-echo nil
|
'('help-echo nil
|
||||||
|
@ -520,23 +526,27 @@ ICON-SPEC should be a specification from `mode-icons'."
|
||||||
(buffer-string)))
|
(buffer-string)))
|
||||||
(t (propertize (format "%s" mode) 'display (mode-icons-get-icon-display (nth 1 icon-spec) (nth 2 icon-spec)) 'mode-icons-p icon-spec)))))
|
(t (propertize (format "%s" mode) 'display (mode-icons-get-icon-display (nth 1 icon-spec) (nth 2 icon-spec)) 'mode-icons-p icon-spec)))))
|
||||||
|
|
||||||
|
(defvar mode-icons-get-icon-spec (make-hash-table :test 'equal)
|
||||||
|
"Hash table of icon-specifications.")
|
||||||
(defun mode-icons-get-icon-spec (mode)
|
(defun mode-icons-get-icon-spec (mode)
|
||||||
"Get icon spec for MODE based on regular expression."
|
"Get icon spec for MODE based on regular expression."
|
||||||
(let (case-fold-search)
|
(or (gethash mode mode-icons-get-icon-spec)
|
||||||
(catch 'found-mode
|
(puthash mode (let (case-fold-search)
|
||||||
(dolist (item mode-icons)
|
(catch 'found-mode
|
||||||
(when (and (mode-icons-supported-p item)
|
(dolist (item mode-icons)
|
||||||
(or
|
(when (and (mode-icons-supported-p item)
|
||||||
(and
|
(or
|
||||||
(stringp (car item))
|
(and
|
||||||
(stringp mode)
|
(stringp (car item))
|
||||||
(string-match-p (car item) mode))
|
(stringp mode)
|
||||||
(and
|
(string-match-p (car item) mode))
|
||||||
(symbolp (car item))
|
(and
|
||||||
(symbolp mode)
|
(symbolp (car item))
|
||||||
(eq mode (car item)))))
|
(symbolp mode)
|
||||||
(throw 'found-mode item)))
|
(eq mode (car item)))))
|
||||||
nil)))
|
(throw 'found-mode item)))
|
||||||
|
nil))
|
||||||
|
mode-icons-get-icon-spec)))
|
||||||
|
|
||||||
(defcustom mode-icons-show-mode-name nil
|
(defcustom mode-icons-show-mode-name nil
|
||||||
"Show Icon and `mode-name'."
|
"Show Icon and `mode-name'."
|
||||||
|
@ -949,7 +959,7 @@ When ENABLE is non-nil, enable the changes to the mode line."
|
||||||
(mode-icons-set-current-mode-icon)
|
(mode-icons-set-current-mode-icon)
|
||||||
;; FIXME -- undo to allow `ergoemacs-mode' and color changing
|
;; FIXME -- undo to allow `ergoemacs-mode' and color changing
|
||||||
;; XPMs. Seems a bit heavy handed.
|
;; XPMs. Seems a bit heavy handed.
|
||||||
(mode-icons-set-minor-mode-icon-undo t)
|
;; (mode-icons-set-minor-mode-icon-undo t)
|
||||||
(mode-icons-set-minor-mode-icon)))
|
(mode-icons-set-minor-mode-icon)))
|
||||||
|
|
||||||
(defun mode-icons-reset ()
|
(defun mode-icons-reset ()
|
||||||
|
|
Loading…
Reference in a new issue