Mercurial > hg > xemacs-beta
changeset 5281:aa20a889ff14
Remove a couple of redundant functions, backquote.el
2010-10-10 Aidan Kehoe <kehoea@parhasard.net>
* backquote.el (bq-vector-contents, bq-list*): Remove; the former
is equivalent to (append VECTOR nil), the latter to (list* ...).
(bq-process-2): Use (append VECTOR nil) instead of using
#'bq-vector-contents to convert to a list.
(bq-process-1): Now we use list* instead of bq-list
* subr.el (list*): Moved from cl.el, since it is now required to
be available the first time a backquoted form is encountered.
* cl.el (list*): Move to subr.el.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Sun, 10 Oct 2010 12:13:32 +0100 |
parents | 59a6419f7504 |
children | dcc34e28cd84 |
files | lisp/ChangeLog lisp/backquote.el lisp/cl.el lisp/subr.el |
diffstat | 4 files changed, 28 insertions(+), 42 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/ChangeLog Mon Sep 20 23:22:50 2010 +0100 +++ b/lisp/ChangeLog Sun Oct 10 12:13:32 2010 +0100 @@ -1,3 +1,14 @@ +2010-10-10 Aidan Kehoe <kehoea@parhasard.net> + + * backquote.el (bq-vector-contents, bq-list*): Remove; the former + is equivalent to (append VECTOR nil), the latter to (list* ...). + (bq-process-2): Use (append VECTOR nil) instead of using + #'bq-vector-contents to convert to a list. + (bq-process-1): Now we use list* instead of bq-list + * subr.el (list*): Moved from cl.el, since it is now required to + be available the first time a backquoted form is encountered. + * cl.el (list*): Move to subr.el. + 2010-09-16 Aidan Kehoe <kehoea@parhasard.net> * test-harness.el (Check-Message):
--- a/lisp/backquote.el Mon Sep 20 23:22:50 2010 +0100 +++ b/lisp/backquote.el Sun Oct 10 12:13:32 2010 +0100 @@ -184,19 +184,10 @@ ;;; ---------------------------------------------------------------- -(defun bq-vector-contents (vec) - (let ((contents nil) - (n (length vec))) - (while (> n 0) - (setq n (1- n)) - (setq contents (cons (aref vec n) contents))) - contents)) - ;;; This does the expansion from table 2. (defun bq-process-2 (code) (cond ((vectorp code) - (let* ((dflag-d - (bq-process-2 (bq-vector-contents code)))) + (let* ((dflag-d (bq-process-2 (append code nil)))) (cons 'vector (bq-process-1 (car dflag-d) (cdr dflag-d))))) ((atom code) (cond ((null code) (cons nil nil)) @@ -278,26 +269,7 @@ (list 'quote thing)) ((eq flag 'vector) (list 'apply '(function vector) thing)) - (t (cons (cdr - (assq flag - '((cons . cons) - (list* . bq-list*) - (list . list) - (append . append) - (nconc . nconc)))) - thing)))) - -;;; ---------------------------------------------------------------- - -(defmacro bq-list* (&rest args) - "Return a list of its arguments with last cons a dotted pair." - (setq args (reverse args)) - (let ((result (car args))) - (setq args (cdr args)) - (while args - (setq result (list 'cons (car args) result)) - (setq args (cdr args))) - result)) + (t (cons flag thing)))) (provide 'backquote)
--- a/lisp/cl.el Mon Sep 20 23:22:50 2010 +0100 +++ b/lisp/cl.el Sun Oct 10 12:13:32 2010 +0100 @@ -519,17 +519,7 @@ ;;; `last' is implemented as a C primitive, as of 1998-11 -(defun list* (arg &rest rest) ; See compiler macro in cl-macs.el - "Return a new list with specified args as elements, cons'd to last arg. -Thus, `(list* A B C D)' is equivalent to `(nconc (list A B C) D)', or to -`(cons A (cons B (cons C D)))'." - (cond ((not rest) arg) - ((not (cdr rest)) (cons arg (car rest))) - (t (let* ((n (length rest)) - (copy (copy-sequence rest)) - (last (nthcdr (- n 2) copy))) - (setcdr last (car (cdr last))) - (cons arg copy))))) +;;; XEmacs: `list*' is in subr.el. (defun ldiff (list sublist) "Return a copy of LIST with the tail SUBLIST removed."
--- a/lisp/subr.el Mon Sep 20 23:22:50 2010 +0100 +++ b/lisp/subr.el Sun Oct 10 12:13:32 2010 +0100 @@ -66,7 +66,20 @@ (message "Unknown declaration %s" d))))) (setq macro-declaration-function 'macro-declaration-function) - + +;; XEmacs; this is here because we use it in backquote.el, so it needs to be +;; available the first time a `(...) form is expanded. +(defun list* (first &rest rest) ; See compiler macro in cl-macs.el + "Return a new list with specified args as elements, cons'd to last arg. +Thus, `(list* A B C D)' is equivalent to `(nconc (list A B C) D)', or to +`(cons A (cons B (cons C D)))'." + (cond ((not rest) first) + ((not (cdr rest)) (cons first (car rest))) + (t (let* ((n (length rest)) + (copy (copy-sequence rest)) + (last (nthcdr (- n 2) copy))) + (setcdr last (car (cdr last))) + (cons first copy))))) ;;;; Lisp language features.