From f6da761bea5048abd1f6f26c6e144e4ab4e023cb Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=BCdiger=20Sonderfeld?= Date: Fri, 10 Jan 2014 13:41:19 +0100 Subject: [PATCH] Document `subr-x' functions. * doc/lispref/hash.texi (Hash Tables): Add cindex entry for `subr-x' functions. * doc/lispref/strings.texi (Creating Strings, Text Comparison): Document functions from `subr-x'. --- doc/lispref/ChangeLog | 8 ++++ doc/lispref/hash.texi | 1 + doc/lispref/strings.texi | 91 ++++++++++++++++++++++++++++++++++++++++ etc/NEWS | 4 +- 4 files changed, 101 insertions(+), 3 deletions(-) diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index 2963ffc9a60..3a362c7daa5 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog @@ -1,3 +1,11 @@ +2014-01-10 Rüdiger Sonderfeld + + * hash.texi (Hash Tables): Add cindex entry for `subr-x' + functions. + + * strings.texi (Creating Strings, Text Comparison): Document + functions from `subr-x'. + 2014-01-09 Rüdiger Sonderfeld * text.texi (Parsing HTML/XML): Document `shr-insert-document'. diff --git a/doc/lispref/hash.texi b/doc/lispref/hash.texi index 5d0d6b6c89e..9d6302f4073 100644 --- a/doc/lispref/hash.texi +++ b/doc/lispref/hash.texi @@ -354,6 +354,7 @@ This returns the rehash threshold of @var{table}. This returns the current nominal size of @var{table}. @end defun +@cindex Hash table functions in subr-x. The following two functions are provided by the @file{subr-x} library. To use them, you need to load this library first. diff --git a/doc/lispref/strings.texi b/doc/lispref/strings.texi index 5c814b22b2d..b6972ad9cc5 100644 --- a/doc/lispref/strings.texi +++ b/doc/lispref/strings.texi @@ -365,6 +365,83 @@ The default value of @var{separators} for @code{split-string}. Its usual value is @w{@code{"[ \f\t\n\r\v]+"}}. @end defvar +@cindex String creation functions in subr-x + The following functions are provided by the @file{subr-x} library. +To use them, you need to load this library first. + +@defun string-join strings &optional separator +This joins all strings in @var{strings}. If the optional argument +@var{separator} is non-@code{nil} then its value is added between each +string. + +@example +(string-join '("foo" "bar")) + @result{} "foobar" +(string-join '("foo" "bar") ", ") + @result{} "foo, bar" +@end example +@end defun + +@defun string-reverse string +This function returns the reversed value of @var{string}. + +@example +(string-reverse "ung olleh") + @result{} "hello gnu" +@end example +@end defun + +@defun string-trim-left string +This function returns a string with all the leading whitespace removed +from @var{string}. Trailing whitespace are left. + +@example +(string-trim-left "\r\n\t abc ") + @result{} "abc " +@end example +@end defun + +@defun string-trim-right string +This function returns a string with all the trailing whitespace +removed from @var{string}. Leading whitespace are left. + +@example +(string-trim-left " abc ") + @result{} " abc" +@end example +@end defun + +@defun string-trim string +This function returns a string with all leading and trailing +whitespace from @var{string} removed. This has the same effect as +calling @code{string-trim-left} and @code{string-trim-right} on +@var{string}. +@end defun + +@defun string-remove-prefix prefix string +This removes the string @var{prefix} from the beginning of +@var{string} if present. + +@example +(string-remove-prefix "foo" "foobar") + @result{} "bar" +(string-remove-prefix "not" "foobar") + @result{} "foobar" +@end example +@end defun + +@defun string-remove-suffix suffix string +This removes the string @var{suffix} from the end of @var{string} if +present. + +@example +(string-remove-suffix "bar" "foobar") + @result{} "foo" +(string-remove-suffix "not" "foobar") + @result{} "foobar" +@end example +@end defun + @node Modifying Strings @section Modifying Strings @@ -571,6 +648,20 @@ function @code{string-match}, which matches a regular expression against a string, can be used for a kind of string comparison; see @ref{Regexp Search}. +@cindex String comparisson functions in subr-x + The following functions are provided by the @file{subr-x} library. +To use them, you need to load this library first. + +@defun string-empty-p string +This function returns non-@code{nil} if @var{string} is an empty +string. +@end defun + +@defun string-blank-p string +This function returns non-@code{nil} if @var{string} is either empty +or only whitespace. +@end defun + @node String Conversion @section Conversion of Characters and Strings @cindex conversion of strings diff --git a/etc/NEWS b/etc/NEWS index da1ecbca4d4..26574a11e54 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1099,12 +1099,10 @@ displaying the buffer in a window. +++ ** New macro with-eval-after-load. Like eval-after-load, but better behaved. -** New library subr-x.el for misc helper functions +++ +** New library subr-x.el for misc helper functions *** `hash-table-keys' -+++ *** `hash-table-values' - *** `string-blank-p` *** `string-empty-p` *** `string-join` -- 2.39.2