summaryrefslogtreecommitdiff
path: root/cider-util.el
diff options
context:
space:
mode:
authorBozhidar Batsov <bozhidar@batsov.com>2016-02-13 11:50:08 +0200
committerBozhidar Batsov <bozhidar@batsov.com>2016-02-13 11:50:08 +0200
commit5ef2cadcc18269c1f1fcbd67a11fb1f59773a04c (patch)
treeb8a9704b620be62f089974b3c26faeebbedf70e3 /cider-util.el
parent10acc018bbf22adb6a612ddd77ed7632c16104e2 (diff)
Move string compatibility functions to cider-util
I can't figure out what's bothering the byte-compiler in the old approach... this should solve the problem, though.
Diffstat (limited to 'cider-util.el')
-rw-r--r--cider-util.el16
1 files changed, 16 insertions, 0 deletions
diff --git a/cider-util.el b/cider-util.el
index 9ec214e1..0fcc7fd9 100644
--- a/cider-util.el
+++ b/cider-util.el
@@ -285,6 +285,22 @@ Unless you specify a BUFFER it will default to the current one."
;;; Strings
+(defun cider-string-trim-left (string)
+ "Remove leading whitespace from STRING."
+ (if (string-match "\\`[ \t\n\r]+" string)
+ (replace-match "" t t string)
+ string))
+
+(defun cider-string-trim-right (string)
+ "Remove trailing whitespace from STRING."
+ (if (string-match "[ \t\n\r]+\\'" string)
+ (replace-match "" t t string)
+ string))
+
+(defun cider-string-trim (string)
+ "Remove leading and trailing whitespace from STRING."
+ (string-trim-left (string-trim-right string)))
+
(defun cider-string-join (strings &optional separator)
"Join all STRINGS using SEPARATOR."
(mapconcat #'identity strings separator))