diff options
author | Bozhidar Batsov <bozhidar@batsov.com> | 2013-12-20 18:37:10 +0200 |
---|---|---|
committer | Bozhidar Batsov <bozhidar@batsov.com> | 2013-12-20 18:37:10 +0200 |
commit | 3cbfb9354082c9e3466156d81da3dfe9d7d9f99f (patch) | |
tree | f6f89c3d4c22cff7744bb58e1910c236b5ab307e /lisp/emacs-lisp | |
parent | 131e4695b2fc814c27e806860d9f4da8673ff505 (diff) | |
download | emacs-3cbfb9354082c9e3466156d81da3dfe9d7d9f99f.tar.gz emacs-3cbfb9354082c9e3466156d81da3dfe9d7d9f99f.tar.bz2 emacs-3cbfb9354082c9e3466156d81da3dfe9d7d9f99f.zip |
* lisp/emacs-lisp/subr-x.el: (string-remove-prefix): New function.
(string-remove-suffix): New function.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r-- | lisp/emacs-lisp/subr-x.el | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lisp/emacs-lisp/subr-x.el b/lisp/emacs-lisp/subr-x.el index 07e47794134..41c3ff63ae4 100644 --- a/lisp/emacs-lisp/subr-x.el +++ b/lisp/emacs-lisp/subr-x.el @@ -73,6 +73,18 @@ "Check whether STRING is either empty or only whitespace." (string-match-p "\\`[ \t\n\r]*\\'" string)) +(defsubst string-remove-prefix (prefix string) + "Remove PREFIX from STRING if present." + (if (string-prefix-p prefix string) + (substring string (length prefix)) + string)) + +(defsubst string-remove-suffix (suffix string) + "Remove SUFFIX from STRING if present." + (if (string-suffix-p suffix string) + (substring string 0 (- (length string) (length suffix))) + string)) + (provide 'subr-x) ;;; subr-x.el ends here |