diff options
author | Bozhidar Batsov <bozhidar@batsov.com> | 2016-02-13 11:50:08 +0200 |
---|---|---|
committer | Bozhidar Batsov <bozhidar@batsov.com> | 2016-02-13 11:50:08 +0200 |
commit | 5ef2cadcc18269c1f1fcbd67a11fb1f59773a04c (patch) | |
tree | b8a9704b620be62f089974b3c26faeebbedf70e3 | |
parent | 10acc018bbf22adb6a612ddd77ed7632c16104e2 (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.
-rw-r--r-- | cider-browse-ns.el | 3 | ||||
-rw-r--r-- | cider-compat.el | 18 | ||||
-rw-r--r-- | cider-util.el | 16 |
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)) |