spacemacs/core/emacs-backports.el
2015-01-02 22:21:35 -05:00

28 lines
893 B
EmacsLisp

(unless (featurep 'subr-x)
;; `subr-x' function for Emacs 24.3 and below
(defsubst string-join (strings &optional separator)
"Join all STRINGS using SEPARATOR."
(mapconcat 'identity strings separator))
(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-empty-p (string)
"Check whether STRING is empty."
(string= string "")))
(provide 'emacs-backports)