From: Leo Liu Date: Wed, 21 May 2014 03:49:58 +0000 (+0800) Subject: * doc/lispref/sequences.texi (Sequence Functions): Update nreverse. X-Git-Tag: emacs-25.0.90~2640^2~75 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=254b7645f30f67abd00b773f2b0eac63d4c382dd;p=emacs.git * doc/lispref/sequences.texi (Sequence Functions): Update nreverse. * src/fns.c (Fnreverse): Accept strings for SEQ and update doc-string. --- diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index 6de8adf1215..7d13d06b580 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog @@ -1,3 +1,7 @@ +2014-05-21 Leo Liu + + * sequences.texi (Sequence Functions): Update nreverse. + 2014-05-19 Paul Eggert Allow any non-nil value to count as true in bool-vector. diff --git a/doc/lispref/sequences.texi b/doc/lispref/sequences.texi index 68467830a67..9b3df17ceb3 100644 --- a/doc/lispref/sequences.texi +++ b/doc/lispref/sequences.texi @@ -261,13 +261,16 @@ x @end defun @defun nreverse seq +@cindex reversing a string @cindex reversing a list @cindex reversing a vector This function reverses the order of the elements of @var{seq}. -If @var{seq} is a list, @code{nreverse} alters its by reversing the @sc{cdr}s +If @var{seq} is a list, @code{nreverse} alters it by reversing the @sc{cdr}s in the cons cells. The cons cell that used to be the last one in @var{seq} becomes the first cons cell of the value. If @var{seq} is a vector or -bool vector, its items are placed in the same vector in a reversed order. +bool vector, its items are placed in the same vector in a reversed +order. If @var{seq} is a string, it works like @code{reverse} i.e., no +destructive modifcation in preference to treat strings as immutable. For example: diff --git a/src/ChangeLog b/src/ChangeLog index 0ca3deaec9c..d6e21a777c2 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2014-05-21 Leo Liu + + * fns.c (Fnreverse): Accept strings for SEQ and update doc-string. + 2014-05-20 Michael Albinus * dbusbind.c (xd_signature): Revert last 2 patches. diff --git a/src/fns.c b/src/fns.c index 1694f1c798d..5074ae3b41b 100644 --- a/src/fns.c +++ b/src/fns.c @@ -1697,16 +1697,15 @@ changing the value of a sequence `foo'. */) } DEFUN ("nreverse", Fnreverse, Snreverse, 1, 1, 0, - doc: /* Reverse order of items in a list or vector SEQ. -If SEQ is a list, it should be nil-terminated, and reversed -by modifying cdr pointers. Return the reversed SEQ. - -Note that unlike `reverse', this function doesn't work with strings. -It is strongly encouraged to treat them as immutable. */) + doc: /* Reverse order of items in a list, vector or string SEQ. +If SEQ is a list, it should be nil-terminated. +This function may destructively modify SEQ to produce the value. */) (Lisp_Object seq) { if (NILP (seq)) return seq; + else if (STRINGP (seq)) + return Freverse (seq); else if (CONSP (seq)) { Lisp_Object prev, tail, next;