GNU bug report logs - #16963
A patch to create a list-with-tail primitive.

Previous Next

Package: emacs;

Reported by: Demetrios Obenour <demetriobenour <at> gmail.com>

Date: Fri, 7 Mar 2014 16:48:02 UTC

Severity: wishlist

Tags: patch

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Demetrios Obenour <demetriobenour <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: A patch to create a list-with-tail primitive.
Date: Fri, 07 Mar 2014 08:58:28 -0500
Since a comment in backquote.el said that backquote-list* needed to be a
primitive, here is an implementation of it as one, under the name
list-with-tail.

=== modified file 'src/alloc.c'
--- src/alloc.c	2014-02-28 21:45:34 +0000
+++ src/alloc.c	2014-03-07 13:27:33 +0000
@@ -2593,6 +2593,26 @@
   return val;
 }
 
+DEFUN ("list-with-tail", Flist_with_tail, Slist_with_tail, 0, MANY, 0,
+       doc: /* Return a newly created list with specified arguments as
elements,
+except for the last argument, which becomes the tail of the list.
+At least one argument is required.
+usage: (list &rest OBJECTS &last TAIL)  */)
+  (ptrdiff_t nargs, Lisp_Object *args)
+{
+  if (nargs == 0)
+    error ("Wrong number of arguments");
+  register Lisp_Object val;
+  nargs--;
+  val = args[nargs];
+
+  while (nargs > 0)
+    {
+      nargs--;
+      val = Fcons (args[nargs], val);
+    }
+  return val;
+}
 
 DEFUN ("make-list", Fmake_list, Smake_list, 2, 2, 0,
        doc: /* Return a newly created list of length LENGTH, with each
element being INIT.  */)
@@ -6921,6 +6941,7 @@
 
   defsubr (&Scons);
   defsubr (&Slist);
+  defsubr (&Slist_with_tail);
   defsubr (&Svector);
   defsubr (&Smake_byte_code);
   defsubr (&Smake_list);


Change Log:

  This creates a built-in function, list-with-tail,
  that is identical to backquote-list*-function
  in backquote.el except that it is a primitive.
  This follows the suggestion made in a backquote.el

Sincerely,

Demetrios Obenour





This bug report was last modified 6 years and 24 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.