aboutsummaryrefslogtreecommitdiffstats
path: root/mode-icons.el
diff options
context:
space:
mode:
authorGravatar Matthew L. Fidler2016-02-09 09:29:58 -0600
committerGravatar Matthew L. Fidler2016-02-09 09:29:58 -0600
commit11c523da66eed895f31fdc048cbdd203b102cff2 (patch)
tree35af03f2670088dff8bdf55bf3619b539ab74ee5 /mode-icons.el
parentba648eb5b32f361cb7784a7d0ff4345b2f092515 (diff)
downloadmode-icons-11c523da66eed895f31fdc048cbdd203b102cff2.tar.gz
mode-icons-11c523da66eed895f31fdc048cbdd203b102cff2.zip
Add font-based icons for supported platforms & jpg support
Diffstat (limited to 'mode-icons.el')
-rw-r--r--mode-icons.el17
1 files changed, 14 insertions, 3 deletions
diff --git a/mode-icons.el b/mode-icons.el
index 97a6f72..cfa1452 100644
--- a/mode-icons.el
+++ b/mode-icons.el
@@ -98,6 +98,7 @@ without the extension. And the third being the type of icon."
(const :tag "png" png)
(const :tag "gif" gif)
(const :tag "jpeg" jpeg)
+ (const :tag "jpg" jpg)
(const :tag "xbm" xbm)
(const :tag "xpm" xpm))))
:group 'mode-icons)
@@ -110,7 +111,7 @@ extension. Type should be a symbol designating the file type for
the icon."
(let ((icon-path (mode-icons-get-icon-file
(concat icon "." (symbol-name type)))))
- `(image :type ,type :file ,icon-path :ascent center)))
+ `(image :type ,(or (and (eq type 'jpg) 'jpeg) type) :file ,icon-path :ascent center)))
(defcustom mode-icons-minor-mode-base-text-properties
'('help-echo nil
@@ -135,6 +136,14 @@ the icon."
(member 'sml/pos-id-separator mode-line-format)
(string-match-p "powerline" (prin1-to-string mode-line-format)))))
+(defvar mode-icons-supported-p (icon-spec)
+ "Determine if ICON-SPEC is suppored on your system."
+ (or
+ (and (eq (nth 2 icon-spec) 'octicons) mode-icons-octicons-font (not (eq system-type 'windows-nt))
+ (stringp (nth 1 icon-spec)))
+ (and (eq (nth 2 icon-spec) 'jpg) (image-type-available-p 'jpeg))
+ (and (image-type-available-p (nth 2 icon-spec)))))
+
(defun mode-icons-propertize-mode (mode icon-spec)
"Propertize MODE with ICON-SPEC.
@@ -145,7 +154,8 @@ ICON-SPEC should be a specification from `mode-icons'."
mode)
((not (nth 1 icon-spec))
"")
- ((and mode-icons-octicons-font (stringp (nth 1 icon-spec)) (eq (nth 2 icon-spec) 'octicons))
+ ((and mode-icons-octicons-font (not (eq system-type 'windows-nt))
+ (stringp (nth 1 icon-spec)) (eq (nth 2 icon-spec) 'octicons))
(propertize mode 'display (nth 1 icon-spec)
'font 'mode-icons-octicons-font
'mode-icons-p t))
@@ -159,7 +169,8 @@ ICON-SPEC should be a specification from `mode-icons'."
"Get icon spec for MODE based on regular expression."
(catch 'found-mode
(dolist (item mode-icons)
- (when (string-match-p (car item) mode)
+ (when (and (mode-icons-supported-p item)
+ (string-match-p (car item) mode))
(throw 'found-mode item)))
nil))