[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] trunk r115209: * lisp/emacs-lisp/helpers.el: Add some stri
From: |
Bozhidar Batsov |
Subject: |
[Emacs-diffs] trunk r115209: * lisp/emacs-lisp/helpers.el: Add some string helpers. |
Date: |
Sun, 24 Nov 2013 09:34:02 +0000 |
User-agent: |
Bazaar (2.6b2) |
------------------------------------------------------------
revno: 115209
revision-id: address@hidden
parent: address@hidden
committer: Bozhidar Batsov <address@hidden>
branch nick: master
timestamp: Sun 2013-11-24 11:31:51 +0200
message:
* lisp/emacs-lisp/helpers.el: Add some string helpers.
(string-trim-left): Removes leading whitespace.
(string-trim-right): Removes trailing whitespace.
(string-trim): Removes leading and trailing whitespace.
modified:
etc/NEWS news-20100311060928-aoit31wvzf25yr1z-1
lisp/ChangeLog changelog-20091113204419-o5vbwnq5f7feedwu-1432
lisp/emacs-lisp/helpers.el helpers.el-20131104130751-8dd4wji5crsqfatf-1
=== modified file 'etc/NEWS'
--- a/etc/NEWS 2013-11-24 08:49:44 +0000
+++ b/etc/NEWS 2013-11-24 09:31:51 +0000
@@ -769,6 +769,9 @@
** New library helpers.el for misc helper functions
*** `hash-table-keys'
*** `hash-table-values'
+*** `string-trim-left'
+*** `string-trim-right'
+*** `string-trim'
** Obsoleted functions:
*** `log10'
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2013-11-24 08:49:44 +0000
+++ b/lisp/ChangeLog 2013-11-24 09:31:51 +0000
@@ -1,5 +1,10 @@
2013-11-24 Bozhidar Batsov <address@hidden>
+ * emacs-lisp/helpers.el: Add some string helpers.
+ (string-trim-left): Removes leading whitespace.
+ (string-trim-right): Removes trailing whitespace.
+ (string-trim): Removes leading and trailing whitespace.
+
* subr.el (string-suffix-p): New function.
2013-11-23 Glenn Morris <address@hidden>
=== modified file 'lisp/emacs-lisp/helpers.el'
--- a/lisp/emacs-lisp/helpers.el 2013-11-04 19:25:09 +0000
+++ b/lisp/emacs-lisp/helpers.el 2013-11-24 09:31:51 +0000
@@ -37,6 +37,22 @@
(maphash (lambda (_k v) (push v values)) hash-table)
values))
+(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)))
+
(provide 'helpers)
;;; helpers.el ends here
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] trunk r115209: * lisp/emacs-lisp/helpers.el: Add some string helpers.,
Bozhidar Batsov <=