summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Matthew L. Fidler2016-02-11 08:43:27 -0600
committerGravatar Matthew L. Fidler2016-02-11 08:43:27 -0600
commit74bf0499968bf16fa092f22b616926aa4b62c003 (patch)
treeb8b492f0b4bac86d432fdabd2ab0d1252dd4ce96
parente33fd86eb9645f547988dc27f4a7775161877e83 (diff)
downloadmode-icons-74bf0499968bf16fa092f22b616926aa4b62c003.tar.gz
mode-icons-74bf0499968bf16fa092f22b616926aa4b62c003.zip
Make minor-modes have menus by using `compose-region'
Also make every system register the font for the icon
-rw-r--r--mode-icons.el47
1 files changed, 24 insertions, 23 deletions
diff --git a/mode-icons.el b/mode-icons.el
index 5e8d697..e9f211c 100644
--- a/mode-icons.el
+++ b/mode-icons.el
@@ -160,25 +160,24 @@ the icon."
(defun mode-icons-supported-font-p (char font &optional dont-register)
"Determine if the CHAR is supported in FONT.
When DONT-REGISTER is non-nil, don't register the font.
-Otherwise, under windows 32, register the font for use in
-the mode-line."
+Otherwise, register the font for use in the mode-line and
+everywhere else."
(when (and (or (integerp char)
(and (stringp char) (= 1 (length char))))
(boundp (intern (format "mode-icons-font-spec-%s" font)))
(symbol-value (intern (format "mode-icons-font-spec-%s" font))))
- (if (not (eq system-type 'windows-nt)) 'direct-font
- (let* ((char (or (and (integerp char) char)
- (and (stringp char) (= 1 (length char))
- (aref (vconcat char) 0))))
- (found-char-p (assoc char mode-icons-font-register-alist))
- (char-font-p (and found-char-p (eq (cdr found-char-p) font))))
- (cond
- (char-font-p t)
- (found-char-p t)
- (t ;; not yet registered.
- (set-fontset-font t (cons char char) (symbol-value (intern (format "mode-icons-font-spec-%s" font))))
- (push (cons char font) mode-icons-font-register-alist)
- t))))))
+ (let* ((char (or (and (integerp char) char)
+ (and (stringp char) (= 1 (length char))
+ (aref (vconcat char) 0))))
+ (found-char-p (assoc char mode-icons-font-register-alist))
+ (char-font-p (and found-char-p (eq (cdr found-char-p) font))))
+ (cond
+ (char-font-p t)
+ (found-char-p t)
+ (t ;; not yet registered.
+ (set-fontset-font t (cons char char) (symbol-value (intern (format "mode-icons-font-spec-%s" font))))
+ (push (cons char font) mode-icons-font-register-alist)
+ t)))))
(defun mode-icons-supported-p (icon-spec)
"Determine if ICON-SPEC is suppored on your system."
@@ -202,12 +201,14 @@ ICON-SPEC should be a specification from `mode-icons'."
((and (stringp (nth 1 icon-spec)) (not (nth 2 icon-spec)))
(propertize mode 'display (mode-icons-get-icon-display (nth 1 icon-spec) (nth 2 icon-spec))
'mode-icons-p t))
- ((setq tmp (mode-icons-supported-font-p (nth 1 icon-spec) (nth 2 icon-spec)))
- (if (eq 'direct-font tmp)
- (propertize mode 'display (nth 1 icon-spec)
- 'font (symbol-value (intern (format "mode-icons-font-%s" font)))
- 'mode-icons-p t)
- (propertize mode 'display (nth 1 icon-spec) 'mode-icons-p t)))
+ ((mode-icons-supported-font-p (nth 1 icon-spec) (nth 2 icon-spec))
+ ;; (propertize mode 'display (nth 1 icon-spec) 'mode-icons-p t)
+ ;; Use `compose-region' because it allows clicable text.
+ (with-temp-buffer
+ (insert mode)
+ (compose-region (point-min) (point-max) (nth 1 icon-spec))
+ (put-text-property (point-min) (point-max) 'mode-icons-p t)
+ (buffer-string)))
(t (propertize mode 'display (mode-icons-get-icon-display (nth 1 icon-spec) (nth 2 icon-spec)) 'mode-icons-p t)))))
(defun mode-icons-get-icon-spec (mode)
@@ -238,7 +239,7 @@ ICON-SPEC should be a specification from `mode-icons'."
(setq mode-name (mode-icons-get-mode-icon mode))))
(defun mode-icons-major-mode-icons-undo ()
- "Undo the mode-name changes"
+ "Undo the `mode-name' icons."
(dolist (b (buffer-list))
(with-current-buffer b
(when mode-icons-cached-mode-name
@@ -246,7 +247,7 @@ ICON-SPEC should be a specification from `mode-icons'."
mode-icons-cached-mode-name nil)))))
(defun mode-icons-major-mode-icons ()
- "Apply mode name changes on all buffers."
+ "Apply mode name icons on all buffers."
(dolist (b (buffer-list))
(with-current-buffer b
(mode-icons-set-current-mode-icon))))