diff options
Diffstat (limited to 'lisp/subr.el')
-rw-r--r-- | lisp/subr.el | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/lisp/subr.el b/lisp/subr.el index 163a1c419d4..00acdb6541f 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -339,20 +339,41 @@ configuration." ;;;; List functions. -(defsubst caar (x) +;; Note: `internal--compiler-macro-cXXr' was copied from +;; `cl--compiler-macro-cXXr' in cl-macs.el. If you amend either one, +;; you may want to amend the other, too. +(defun internal--compiler-macro-cXXr (form x) + (let* ((head (car form)) + (n (symbol-name (car form))) + (i (- (length n) 2))) + (if (not (string-match "c[ad]+r\\'" n)) + (if (and (fboundp head) (symbolp (symbol-function head))) + (internal--compiler-macro-cXXr (cons (symbol-function head) (cdr form)) + x) + (error "Compiler macro for cXXr applied to non-cXXr form")) + (while (> i (match-beginning 0)) + (setq x (list (if (eq (aref n i) ?a) 'car 'cdr) x)) + (setq i (1- i))) + x))) + +(defun caar (x) "Return the car of the car of X." + (declare (compiler-macro internal--compiler-macro-cXXr)) (car (car x))) -(defsubst cadr (x) +(defun cadr (x) "Return the car of the cdr of X." + (declare (compiler-macro internal--compiler-macro-cXXr)) (car (cdr x))) -(defsubst cdar (x) +(defun cdar (x) "Return the cdr of the car of X." + (declare (compiler-macro internal--compiler-macro-cXXr)) (cdr (car x))) -(defsubst cddr (x) +(defun cddr (x) "Return the cdr of the cdr of X." + (declare (compiler-macro internal--compiler-macro-cXXr)) (cdr (cdr x))) (defun last (list &optional n) |