summaryrefslogtreecommitdiff
path: root/cider-compat.el
diff options
context:
space:
mode:
authorBozhidar Batsov <bozhidar@batsov.com>2015-12-19 21:27:55 +0200
committerBozhidar Batsov <bozhidar@batsov.com>2015-12-19 21:27:55 +0200
commitb01848ec21baa075f7d0a778a81565fec7ffd382 (patch)
tree20942eb55958c2eb987217507a79f9234bf6c258 /cider-compat.el
parentf182fbc18827ae84751c93bb3d91bdc404a1e0f0 (diff)
Backport string-remove-suffix
Diffstat (limited to 'cider-compat.el')
-rw-r--r--cider-compat.el9
1 files changed, 8 insertions, 1 deletions
diff --git a/cider-compat.el b/cider-compat.el
index c506cf38..4c0f2939 100644
--- a/cider-compat.el
+++ b/cider-compat.el
@@ -151,7 +151,14 @@ bound and (optionally) used in BODY, and its cadr is a sexp to be
evalled to set symbol's value. In the special case you only want
to bind a single value, BINDINGS can just be a plain tuple."
(declare (indent 1) (debug if-let))
- (list 'if-let bindings (macroexp-progn body)))))
+ (list 'if-let bindings (macroexp-progn body))))
+
+ (unless (fboundp 'string-remove-suffix)
+ (defsubst string-remove-suffix (suffix string)
+ "Remove SUFFIX from STRING if present."
+ (if (string-suffix-p suffix string)
+ (substring string 0 (- (length string) (length suffix)))
+ string))))
(provide 'cider-compat)
;;; cider-compat.el ends here