Mercurial > emacs
comparison lisp/emacs-lisp/backquote.el @ 89909:68c22ea6027c
Sync to HEAD
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Fri, 16 Apr 2004 12:51:06 +0000 |
parents | 375f2633d815 |
children | f9a65d7ebd29 |
comparison
equal
deleted
inserted
replaced
89908:ee1402f7b568 | 89909:68c22ea6027c |
---|---|
1 ;;; backquote.el --- implement the ` Lisp construct | 1 ;;; backquote.el --- implement the ` Lisp construct |
2 | 2 |
3 ;;; Copyright (C) 1990, 1992, 1994, 2001 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1990, 92, 1994, 2001, 2004 Free Software Foundation, Inc. |
4 | 4 |
5 ;; Author: Rick Sladkey <jrs@world.std.com> | 5 ;; Author: Rick Sladkey <jrs@world.std.com> |
6 ;; Maintainer: FSF | 6 ;; Maintainer: FSF |
7 ;; Keywords: extensions, internal | 7 ;; Keywords: extensions, internal |
8 | 8 |
42 | 42 |
43 (defun backquote-list*-function (first &rest list) | 43 (defun backquote-list*-function (first &rest list) |
44 "Like `list' but the last argument is the tail of the new list. | 44 "Like `list' but the last argument is the tail of the new list. |
45 | 45 |
46 For example (backquote-list* 'a 'b 'c) => (a b . c)" | 46 For example (backquote-list* 'a 'b 'c) => (a b . c)" |
47 ;; The recursive solution is much nicer: | |
48 ;; (if list (cons first (apply 'backquote-list*-function list)) first)) | |
49 ;; but Emacs is not very good at efficiently processing recursion. | |
47 (if list | 50 (if list |
48 (let* ((rest list) (newlist (cons first nil)) (last newlist)) | 51 (let* ((rest list) (newlist (cons first nil)) (last newlist)) |
49 (while (cdr rest) | 52 (while (cdr rest) |
50 (setcdr last (cons (car rest) nil)) | 53 (setcdr last (cons (car rest) nil)) |
51 (setq last (cdr last) | 54 (setq last (cdr last) |
56 | 59 |
57 (defmacro backquote-list*-macro (first &rest list) | 60 (defmacro backquote-list*-macro (first &rest list) |
58 "Like `list' but the last argument is the tail of the new list. | 61 "Like `list' but the last argument is the tail of the new list. |
59 | 62 |
60 For example (backquote-list* 'a 'b 'c) => (a b . c)" | 63 For example (backquote-list* 'a 'b 'c) => (a b . c)" |
61 (setq list (reverse (cons first list)) | 64 ;; The recursive solution is much nicer: |
65 ;; (if list (list 'cons first (cons 'backquote-list*-macro list)) first)) | |
66 ;; but Emacs is not very good at efficiently processing such things. | |
67 (setq list (nreverse (cons first list)) | |
62 first (car list) | 68 first (car list) |
63 list (cdr list)) | 69 list (cdr list)) |
64 (if list | 70 (if list |
65 (let* ((second (car list)) | 71 (let* ((second (car list)) |
66 (rest (cdr list)) | 72 (rest (cdr list)) |
212 (cons (if use-list* 'backquote-list* 'cons) | 218 (cons (if use-list* 'backquote-list* 'cons) |
213 (append heads (list tail)))) | 219 (append heads (list tail)))) |
214 tail)) | 220 tail)) |
215 (t (cons 'list heads))))) | 221 (t (cons 'list heads))))) |
216 | 222 |
223 ;;; arch-tag: 1a26206a-6b5e-4c56-8e24-2eef0f7e0e7a | |
217 ;;; backquote.el ends here | 224 ;;; backquote.el ends here |