[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] trunk r115646: * lisp/emacs-lisp/subr-x.el: (string-remove
From: |
Bozhidar Batsov |
Subject: |
[Emacs-diffs] trunk r115646: * lisp/emacs-lisp/subr-x.el: (string-remove-prefix): New function. |
Date: |
Fri, 20 Dec 2013 16:38:49 +0000 |
User-agent: |
Bazaar (2.6b2) |
------------------------------------------------------------
revno: 115646
revision-id: address@hidden
parent: address@hidden
committer: Bozhidar Batsov <address@hidden>
branch nick: master
timestamp: Fri 2013-12-20 18:37:10 +0200
message:
* lisp/emacs-lisp/subr-x.el: (string-remove-prefix): New function.
(string-remove-suffix): New function.
modified:
etc/NEWS news-20100311060928-aoit31wvzf25yr1z-1
lisp/ChangeLog changelog-20091113204419-o5vbwnq5f7feedwu-1432
lisp/emacs-lisp/subr-x.el
lispemacslispsubrx.e-20131220162210-eh2g3gvs6rzsm10k-1
=== modified file 'etc/NEWS'
--- a/etc/NEWS 2013-12-20 16:21:45 +0000
+++ b/etc/NEWS 2013-12-20 16:37:10 +0000
@@ -885,6 +885,8 @@
*** `string-trim-left'
*** `string-trim-right'
*** `string-trim'
+*** `string-remove-prefix'
+*** `string-remove-suffix'
** Obsoleted functions:
*** `log10'
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2013-12-20 16:21:45 +0000
+++ b/lisp/ChangeLog 2013-12-20 16:37:10 +0000
@@ -2,6 +2,8 @@
* emacs-lisp/subr-x.el: Renamed from helpers.el.
helpers.el was a poor choice of name.
+ (string-remove-prefix): New function.
+ (string-remove-suffix): New function.
2013-12-20 Martin Rudalics <address@hidden>
=== modified file 'lisp/emacs-lisp/subr-x.el'
--- a/lisp/emacs-lisp/subr-x.el 2013-12-20 16:21:45 +0000
+++ b/lisp/emacs-lisp/subr-x.el 2013-12-20 16:37:10 +0000
@@ -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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] trunk r115646: * lisp/emacs-lisp/subr-x.el: (string-remove-prefix): New function.,
Bozhidar Batsov <=