diff options
author | Bozhidar Batsov <bozhidar@batsov.com> | 2016-02-13 11:13:22 +0200 |
---|---|---|
committer | Bozhidar Batsov <bozhidar@batsov.com> | 2016-02-13 11:13:22 +0200 |
commit | 9f5af95671b3628255d69380a943657027d1bc77 (patch) | |
tree | 78bf3055583ec8efe80c355213ee7e91647c668d /cider-compat.el | |
parent | 82fac2ffd407a4584610c61cff6db10dd788a541 (diff) |
Backport string-trim and friends from subr-x
Diffstat (limited to 'cider-compat.el')
-rw-r--r-- | cider-compat.el | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/cider-compat.el b/cider-compat.el index 3449a94e..87a5324f 100644 --- a/cider-compat.el +++ b/cider-compat.el @@ -153,5 +153,23 @@ 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))))) +(eval-and-compile + (unless (fboundp 'string-trim) + (defsubst string-trim-left (string) + "Remove leading whitespace from STRING." + (if (string-match "\\`[ \t\n\r]+" string) + (replace-match "" t t string) + string)) + + (defsubst string-trim-right (string) + "Remove trailing whitespace from STRING." + (if (string-match "[ \t\n\r]+\\'" string) + (replace-match "" t t string) + string)) + + (defsubst string-trim (string) + "Remove leading and trailing whitespace from STRING." + (string-trim-left (string-trim-right string))))) + (provide 'cider-compat) ;;; cider-compat.el ends here |