summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cider-browse-ns.el3
-rw-r--r--cider-compat.el18
-rw-r--r--cider-util.el16
3 files changed, 18 insertions, 19 deletions
diff --git a/cider-browse-ns.el b/cider-browse-ns.el
index 371068ec..0b09ad16 100644
--- a/cider-browse-ns.el
+++ b/cider-browse-ns.el
@@ -38,6 +38,7 @@
(require 'cider-interaction)
(require 'cider-client)
(require 'cider-compat)
+(require 'cider-util)
(defconst cider-browse-ns-buffer "*cider-ns-browser*")
(defvar-local cider-browse-ns-current-ns nil)
@@ -133,7 +134,7 @@ contents of the buffer are not reset before inserting TITLE and ITEMS."
(defun cider-browse-ns--thing-at-point ()
"Get the thing at point.
Return a list of the type ('ns or 'var) and the value."
- (let ((line (string-trim (thing-at-point 'line))))
+ (let ((line (cider-string-trim (thing-at-point 'line))))
(if (string-match "\\." line)
(list 'ns line)
(list 'var (format "%s/%s"
diff --git a/cider-compat.el b/cider-compat.el
index 3c0b1107..d551d64f 100644
--- a/cider-compat.el
+++ b/cider-compat.el
@@ -153,23 +153,5 @@ 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)
- (defun string-trim-left (string)
- "Remove leading whitespace from STRING."
- (if (string-match "\\`[ \t\n\r]+" string)
- (replace-match "" t t string)
- string))
-
- (defun string-trim-right (string)
- "Remove trailing whitespace from STRING."
- (if (string-match "[ \t\n\r]+\\'" string)
- (replace-match "" t t string)
- string))
-
- (defun 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
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))