diff options
| author | Jean-Christophe Helary | 2017-05-19 14:44:33 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2017-05-19 14:44:33 +0300 |
| commit | d35da215cdc6e3734a967417f2df41b312fac854 (patch) | |
| tree | 8d0cc9e0970c3ccf3deba04f03fcd6e9ad1d75ce | |
| parent | 4b04d8a7d550b9d4a0e83334c80b97d6e8a60ca2 (diff) | |
| download | emacs-d35da215cdc6e3734a967417f2df41b312fac854.tar.gz emacs-d35da215cdc6e3734a967417f2df41b312fac854.zip | |
Improve documentation of 'split-string'
* doc/lispref/strings.texi (Creating Strings): Rearrange text to
make it more readable. (Bug#26925)
| -rw-r--r-- | doc/lispref/strings.texi | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/doc/lispref/strings.texi b/doc/lispref/strings.texi index 1d766869b1f..9436a96ead4 100644 --- a/doc/lispref/strings.texi +++ b/doc/lispref/strings.texi | |||
| @@ -279,17 +279,26 @@ expression @var{separators} (@pxref{Regular Expressions}). Each match | |||
| 279 | for @var{separators} defines a splitting point; the substrings between | 279 | for @var{separators} defines a splitting point; the substrings between |
| 280 | splitting points are made into a list, which is returned. | 280 | splitting points are made into a list, which is returned. |
| 281 | 281 | ||
| 282 | If @var{separators} is @code{nil} (or omitted), the default is the | ||
| 283 | value of @code{split-string-default-separators} and the function | ||
| 284 | behaves as if @var{omit-nulls} were @code{t}. | ||
| 285 | |||
| 282 | If @var{omit-nulls} is @code{nil} (or omitted), the result contains | 286 | If @var{omit-nulls} is @code{nil} (or omitted), the result contains |
| 283 | null strings whenever there are two consecutive matches for | 287 | null strings whenever there are two consecutive matches for |
| 284 | @var{separators}, or a match is adjacent to the beginning or end of | 288 | @var{separators}, or a match is adjacent to the beginning or end of |
| 285 | @var{string}. If @var{omit-nulls} is @code{t}, these null strings are | 289 | @var{string}. If @var{omit-nulls} is @code{t}, these null strings are |
| 286 | omitted from the result. | 290 | omitted from the result. |
| 287 | 291 | ||
| 288 | If @var{separators} is @code{nil} (or omitted), the default is the | 292 | If the optional argument @var{trim} is non-@code{nil}, it should be a |
| 289 | value of @code{split-string-default-separators}. | 293 | regular expression to match text to trim from the beginning and end of |
| 294 | each substring. If trimming makes the substring empty, it is treated | ||
| 295 | as null. | ||
| 296 | |||
| 297 | If you need to split a string into a list of individual command-line | ||
| 298 | arguments suitable for @code{call-process} or @code{start-process}, | ||
| 299 | see @ref{Shell Arguments, split-string-and-unquote}. | ||
| 290 | 300 | ||
| 291 | As a special case, when @var{separators} is @code{nil} (or omitted), | 301 | Examples: |
| 292 | null strings are always omitted from the result. Thus: | ||
| 293 | 302 | ||
| 294 | @example | 303 | @example |
| 295 | (split-string " two words ") | 304 | (split-string " two words ") |
| @@ -306,8 +315,6 @@ useful. If you need such a result, use an explicit value for | |||
| 306 | @result{} ("" "two" "words" "") | 315 | @result{} ("" "two" "words" "") |
| 307 | @end example | 316 | @end example |
| 308 | 317 | ||
| 309 | More examples: | ||
| 310 | |||
| 311 | @example | 318 | @example |
| 312 | (split-string "Soup is good food" "o") | 319 | (split-string "Soup is good food" "o") |
| 313 | @result{} ("S" "up is g" "" "d f" "" "d") | 320 | @result{} ("S" "up is g" "" "d f" "" "d") |
| @@ -354,15 +361,6 @@ practice: | |||
| 354 | (split-string "ooo" "\\|o+" t) | 361 | (split-string "ooo" "\\|o+" t) |
| 355 | @result{} ("o" "o" "o") | 362 | @result{} ("o" "o" "o") |
| 356 | @end example | 363 | @end example |
| 357 | |||
| 358 | If the optional argument @var{trim} is non-@code{nil}, it should be a | ||
| 359 | regular expression to match text to trim from the beginning and end of | ||
| 360 | each substring. If trimming makes the substring empty, it is treated | ||
| 361 | as null. | ||
| 362 | |||
| 363 | If you need to split a string into a list of individual command-line | ||
| 364 | arguments suitable for @code{call-process} or @code{start-process}, | ||
| 365 | see @ref{Shell Arguments, split-string-and-unquote}. | ||
| 366 | @end defun | 364 | @end defun |
| 367 | 365 | ||
| 368 | @defvar split-string-default-separators | 366 | @defvar split-string-default-separators |