]> git.eshelyaron.com Git - emacs.git/commitdiff
* doc/lispref/sequences.texi (Sequence Functions): Update nreverse.
authorLeo Liu <sdl.web@gmail.com>
Wed, 21 May 2014 03:49:58 +0000 (11:49 +0800)
committerLeo Liu <sdl.web@gmail.com>
Wed, 21 May 2014 03:49:58 +0000 (11:49 +0800)
* src/fns.c (Fnreverse): Accept strings for SEQ and update doc-string.

doc/lispref/ChangeLog
doc/lispref/sequences.texi
src/ChangeLog
src/fns.c

index 6de8adf1215694a7f1b97927dc3e74927ce3f7bf..7d13d06b5808ccdbc50c7096616f053e93375fc3 100644 (file)
@@ -1,3 +1,7 @@
+2014-05-21  Leo Liu  <sdl.web@gmail.com>
+
+       * sequences.texi (Sequence Functions): Update nreverse.
+
 2014-05-19  Paul Eggert  <eggert@cs.ucla.edu>
 
        Allow any non-nil value to count as true in bool-vector.
index 68467830a670f26c72b404d73f285108232755d4..9b3df17ceb3e37390ce018ee67cc0813e91016a5 100644 (file)
@@ -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:
 
index 0ca3deaec9c1a79de0ed21f38462111ee2e5a282..d6e21a777c2b1219086f5a5a5dc9fc9c496bbaa2 100644 (file)
@@ -1,3 +1,7 @@
+2014-05-21  Leo Liu  <sdl.web@gmail.com>
+
+       * fns.c (Fnreverse): Accept strings for SEQ and update doc-string.
+
 2014-05-20  Michael Albinus  <michael.albinus@gmx.de>
 
        * dbusbind.c (xd_signature): Revert last 2 patches.
index 1694f1c798d559240787bb91906584eec92c4e2c..5074ae3b41b2eeca8c6f8332e2c3f61ea07d7563 100644 (file)
--- 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;