From a4ececf004e5442fc245ccff910000fe407f7212 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Wed, 24 Mar 2021 09:22:40 +0100 Subject: Move string-trim functions to subr.el * doc/lispref/strings.texi (Creating Strings): Document them. * lisp/faces.el: Don't require subr-x, because that leads to build errors. * lisp/subr.el (string-trim, string-trim-right) (string-trim-left): Move here from subr-x.el. * lisp/emacs-lisp/shortdoc.el (string): Adjust. --- lisp/emacs-lisp/subr-x.el | 22 ---------------------- 1 file changed, 22 deletions(-) (limited to 'lisp/emacs-lisp/subr-x.el') diff --git a/lisp/emacs-lisp/subr-x.el b/lisp/emacs-lisp/subr-x.el index a4514454c0b..9c8c967ee9c 100644 --- a/lisp/emacs-lisp/subr-x.el +++ b/lisp/emacs-lisp/subr-x.el @@ -215,28 +215,6 @@ The variable list SPEC is the same as in `if-let'." (define-obsolete-function-alias 'string-reverse 'reverse "25.1") -(defsubst string-trim-left (string &optional regexp) - "Trim STRING of leading string matching REGEXP. - -REGEXP defaults to \"[ \\t\\n\\r]+\"." - (if (string-match (concat "\\`\\(?:" (or regexp "[ \t\n\r]+") "\\)") string) - (substring string (match-end 0)) - string)) - -(defsubst string-trim-right (string &optional regexp) - "Trim STRING of trailing string matching REGEXP. - -REGEXP defaults to \"[ \\t\\n\\r]+\"." - (let ((i (string-match-p (concat "\\(?:" (or regexp "[ \t\n\r]+") "\\)\\'") - string))) - (if i (substring string 0 i) string))) - -(defsubst string-trim (string &optional trim-left trim-right) - "Trim STRING of leading and trailing strings matching TRIM-LEFT and TRIM-RIGHT. - -TRIM-LEFT and TRIM-RIGHT default to \"[ \\t\\n\\r]+\"." - (string-trim-left (string-trim-right string trim-right) trim-left)) - ;;;###autoload (defun string-truncate-left (string length) "Truncate STRING to LENGTH, replacing initial surplus with \"...\"." -- cgit v1.2.3