aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew L. Fidler2016-02-22 19:15:16 -0600
committerMatthew L. Fidler2016-02-22 19:15:16 -0600
commit3ffef2230fe7b1e0f34dee9bbcc743b3d58a566e (patch)
treeaf58c52ffb8a80a647cb16e1130adde2b2c3c1bc
parentd2c9926a8e79e13ef9942fe96b8109add24a9978 (diff)
downloadmode-icons-3ffef2230fe7b1e0f34dee9bbcc743b3d58a566e.tar.gz
mode-icons-3ffef2230fe7b1e0f34dee9bbcc743b3d58a566e.zip
Make sure the functions return a string (not nil)
-rw-r--r--mode-icons.el85
1 files changed, 44 insertions, 41 deletions
diff --git a/mode-icons.el b/mode-icons.el
index 49d085b..75cbc3d 100644
--- a/mode-icons.el
+++ b/mode-icons.el
@@ -528,15 +528,16 @@ ICON-SPEC should be a specification from `mode-icons'."
(eval `(propertize
,(let ((ro (format-mode-line "%1*"))
icon-spec)
- (setq ro (cond
- ((string= "%" ro)
- (if (setq icon-spec (mode-icons-get-icon-spec 'read-only))
- (mode-icons-propertize-mode 'read-only icon-spec)
- ro))
- (t
- (if (setq icon-spec (mode-icons-get-icon-spec 'writable))
- (mode-icons-propertize-mode 'writable icon-spec)
- ro))))
+ (setq ro (or (cond
+ ((string= "%" ro)
+ (if (setq icon-spec (mode-icons-get-icon-spec 'read-only))
+ (mode-icons-propertize-mode 'read-only icon-spec)
+ ro))
+ (t
+ (if (setq icon-spec (mode-icons-get-icon-spec 'writable))
+ (mode-icons-propertize-mode 'writable icon-spec)
+ ro)))
+ ""))
(when (and mode-icons-read-only-space
(not (string= ro "")))
(setq ro (concat ro " ")))
@@ -553,15 +554,16 @@ ICON-SPEC should be a specification from `mode-icons'."
(eval `(propertize
,(let ((mod (format-mode-line "%1+"))
icon-spec)
- (setq mod (cond
- ((string= "*" mod)
- (if (setq icon-spec (mode-icons-get-icon-spec 'save))
- (mode-icons-propertize-mode 'save icon-spec)
- mod))
- (t
- (if (setq icon-spec (mode-icons-get-icon-spec 'saved))
- (mode-icons-propertize-mode 'saved icon-spec)
- mod))))
+ (setq mod (or (cond
+ ((string= "*" mod)
+ (if (setq icon-spec (mode-icons-get-icon-spec 'save))
+ (mode-icons-propertize-mode 'save icon-spec)
+ mod))
+ (t
+ (if (setq icon-spec (mode-icons-get-icon-spec 'saved))
+ (mode-icons-propertize-mode 'saved icon-spec)
+ mod)))
+ ""))
(when (and mode-icons-modified-status-space
(not (string= mod "")))
(setq mod (concat mod " "))))
@@ -620,29 +622,30 @@ STRING is the string to modify, or if absent, the value from `mode-line-eol-desc
(props (text-properties-at 0 str))
(lt2 "")
icon-spec)
- (setq str (cond
- ((string= "(Unix)" str)
- (setq lt2 " LF")
- (if (setq icon-spec (mode-icons-get-icon-spec 'unix))
- (mode-icons-propertize-mode 'unix icon-spec)
- str))
- ((or (string= str "(DOS)")
- (string= str "\\"))
- (setq lt2 " CRLF")
- (if (setq icon-spec (mode-icons-get-icon-spec 'win))
- (mode-icons-propertize-mode 'win icon-spec)
- str))
- ((string= str "(Mac)")
- (setq lt2 " CR")
- (if (setq icon-spec (mode-icons-get-icon-spec 'apple))
- (mode-icons-propertize-mode 'apple icon-spec)
- str))
- ((string= str ":")
- (setq lt2 " Undecided")
- (if (setq icon-spec (mode-icons-get-icon-spec 'undecided))
- (mode-icons-propertize-mode 'undecided icon-spec)
- str))
- (t str)))
+ (setq str (or (cond
+ ((string= "(Unix)" str)
+ (setq lt2 " LF")
+ (if (setq icon-spec (mode-icons-get-icon-spec 'unix))
+ (mode-icons-propertize-mode 'unix icon-spec)
+ str))
+ ((or (string= str "(DOS)")
+ (string= str "\\"))
+ (setq lt2 " CRLF")
+ (if (setq icon-spec (mode-icons-get-icon-spec 'win))
+ (mode-icons-propertize-mode 'win icon-spec)
+ str))
+ ((string= str "(Mac)")
+ (setq lt2 " CR")
+ (if (setq icon-spec (mode-icons-get-icon-spec 'apple))
+ (mode-icons-propertize-mode 'apple icon-spec)
+ str))
+ ((string= str ":")
+ (setq lt2 " Undecided")
+ (if (setq icon-spec (mode-icons-get-icon-spec 'undecided))
+ (mode-icons-propertize-mode 'undecided icon-spec)
+ str))
+ (t str))
+ ""))
(when mode-icons-eol-text
(setq str (concat str lt2)))
(when (and mode-icons-eol-space