summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/helpers.el
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2013-12-07 19:21:57 +0200
committerEli Zaretskii <eliz@gnu.org>2013-12-07 19:21:57 +0200
commitce1d7b61f12dcc1b67535b68d9b0655b45fcadb6 (patch)
tree881d03f4f486933482cd2e3851184cd3b172ef1b /lisp/emacs-lisp/helpers.el
parent6630df25238c5a1efa2bc6a0fa7889782e8c91b5 (diff)
parentfa6fa1a1773f255b5efbe52a743b017f4908a6cb (diff)
downloademacs-ce1d7b61f12dcc1b67535b68d9b0655b45fcadb6.tar.gz
emacs-ce1d7b61f12dcc1b67535b68d9b0655b45fcadb6.tar.bz2
emacs-ce1d7b61f12dcc1b67535b68d9b0655b45fcadb6.zip
Merge from trunk.
Diffstat (limited to 'lisp/emacs-lisp/helpers.el')
-rw-r--r--lisp/emacs-lisp/helpers.el32
1 files changed, 32 insertions, 0 deletions
diff --git a/lisp/emacs-lisp/helpers.el b/lisp/emacs-lisp/helpers.el
index 73c2ff1c15c..8049f4e1d1d 100644
--- a/lisp/emacs-lisp/helpers.el
+++ b/lisp/emacs-lisp/helpers.el
@@ -37,6 +37,38 @@
(maphash (lambda (_k v) (push v values)) hash-table)
values))
+(defsubst string-empty-p (string)
+ "Check whether STRING is empty."
+ (string= string ""))
+
+(defsubst string-join (strings &optional separator)
+ "Join all STRINGS using SEPARATOR."
+ (mapconcat 'identity strings separator))
+
+(defsubst string-reverse (str)
+ "Reverse the string STR."
+ (apply 'string (nreverse (string-to-list str))))
+
+(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)))
+
+(defsubst string-blank-p (string)
+ "Check whether STRING is either empty or only whitespace."
+ (string-empty-p (string-trim string)))
+
(provide 'helpers)
;;; helpers.el ends here