branch: elpa/telephone-line
commit 778d435ad2182ad7ffd344721ad7b4c720739a36
Author: Daniel Bordak <[email protected]>
Commit: Daniel Bordak <[email protected]>
Fix support for Emacs<25
---
telephone-line-utils.el | 8 ++++++++
telephone-line.el | 4 ++--
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/telephone-line-utils.el b/telephone-line-utils.el
index 198151b0a2..9becfdb01b 100644
--- a/telephone-line-utils.el
+++ b/telephone-line-utils.el
@@ -41,6 +41,14 @@
:type 'boolean
:group 'telephone-line-evil)
+(if (fboundp #'alist-get)
+ (defalias 'telephone-line-alist-get #'alist-get)
+ (defun telephone-line-alist-get (key alist &optional default remove)
+ "Backport of alist-get for Emacs<25"
+ (ignore remove)
+ (let ((x (assq key alist)))
+ (if x (cdr x) default))))
+
(defun telephone-line-create-axis (length)
"Create an axis of length LENGTH.
For odd lengths, this is a sequence from -floor(LENGTH/2) to
diff --git a/telephone-line.el b/telephone-line.el
index f3c2139edd..0e33443673 100644
--- a/telephone-line.el
+++ b/telephone-line.el
@@ -169,14 +169,14 @@ Secondary separators do not incur a background color
change."
(defun telephone-line--face-map (sym active)
"Return the face corresponding to SYM for the given ACTIVE state."
- (let ((pair-or-func (alist-get sym telephone-line-faces)))
+ (let ((pair-or-func (telephone-line-alist-get sym telephone-line-faces)))
(cond ((functionp pair-or-func) (funcall pair-or-func active))
(active (car pair-or-func))
(t (cdr pair-or-func)))))
(defun telephone-line-subseparator-foreground (sym)
"Get the foreground color for a subseparator on a given SYM."
- (let ((subseparator-sym (alist-get sym telephone-line-subseparator-faces)))
+ (let ((subseparator-sym (telephone-line-alist-get sym
telephone-line-subseparator-faces)))
(if (equal sym subseparator-sym)
(face-attribute (telephone-line-face-map sym) :foreground)
(face-attribute (telephone-line-face-map subseparator-sym)
:background))))