diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2012-06-11 16:35:00 -0400 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2012-06-11 16:35:00 -0400 |
commit | 71adb94b713138836225744c8ed9281b558e2c51 (patch) | |
tree | ad614df00327a48008f751e1e54dc1c9c7d98b2c /lisp/emacs-lisp/cl-lib.el | |
parent | a66744021faeb2ce105b1001a380c4a46384c5f4 (diff) | |
download | emacs-71adb94b713138836225744c8ed9281b558e2c51.tar.gz |
Fix compiler-expansion of CL's cXXr functions.
* emacs-lisp/cl-lib.el (cl--defalias): New function.
(cl-values, cl-values-list, cl-copy-seq, cl-svref, cl-first)
(cl-second, cl-rest, cl-endp, cl-third, cl-fourth): Use it.
(cl-plusp, cl-minusp, cl-fifth, cl-sixth, cl-seventh, cl-eighth)
(cl-ninth, cl-tenth): Mark them as inlinable.
(cl-caaar, cl-caadr, cl-cadar, cl-caddr, cl-cdaar, cl-cdadr)
(cl-cddar, cl-cdddr, cl-caaaar, cl-caaadr, cl-caadar, cl-caaddr)
(cl-cadaar, cl-cadadr, cl-caddar, cl-cadddr, cl-cdaaar, cl-cdaadr)
(cl-cdadar, cl-cdaddr, cl-cddaar, cl-cddadr, cl-cdddar, cl-cddddr):
Add a compiler-macro declaration to use cl--compiler-macro-cXXr.
(cl-list*, cl-adjoin): Don't put an autoload manually.
* emacs-lisp/cl-macs.el (cl--compiler-macro-adjoin)
(cl--compiler-macro-list*): Add autoload cookie.
(cl--compiler-macro-cXXr): New function.
* help-fns.el (help-fns--compiler-macro): New function extracted from
describe-function-1; follow aliases and use `compiler-macro' property.
(describe-function-1): Use it.
Fixes: debbugs:11673
Diffstat (limited to 'lisp/emacs-lisp/cl-lib.el')
-rw-r--r-- | lisp/emacs-lisp/cl-lib.el | 85 |
1 files changed, 52 insertions, 33 deletions
diff --git a/lisp/emacs-lisp/cl-lib.el b/lisp/emacs-lisp/cl-lib.el index e3cf0d3a520..223067c600f 100644 --- a/lisp/emacs-lisp/cl-lib.el +++ b/lisp/emacs-lisp/cl-lib.el @@ -217,21 +217,23 @@ an element already on the list. ;; simulated. Instead, cl-multiple-value-bind and friends simply expect ;; the target form to return the values as a list. -(defalias 'cl-values #'list +(defun cl--defalias (cl-f el-f &optional doc) + (defalias cl-f el-f doc) + (put cl-f 'byte-optimizer 'byte-compile-inline-expand)) + +(cl--defalias 'cl-values #'list "Return multiple values, Common Lisp style. The arguments of `cl-values' are the values that the containing function should return. \(fn &rest VALUES)") -(put 'cl-values 'byte-optimizer 'byte-compile-inline-expand) -(defalias 'cl-values-list #'identity +(cl--defalias 'cl-values-list #'identity "Return multiple values, Common Lisp style, taken from a list. LIST specifies the list of values that the containing function should return. \(fn LIST)") -(put 'cl-values-list 'byte-optimizer 'byte-compile-inline-expand) (defsubst cl-multiple-value-list (expression) "Return a list of the multiple values produced by EXPRESSION. @@ -300,11 +302,11 @@ On Emacs versions that lack floating-point support, this function always returns nil." (and (numberp object) (not (integerp object)))) -(defun cl-plusp (number) +(defsubst cl-plusp (number) "Return t if NUMBER is positive." (> number 0)) -(defun cl-minusp (number) +(defsubst cl-minusp (number) "Return t if NUMBER is negative." (< number 0)) @@ -367,7 +369,7 @@ Call `cl-float-limits' to set this.") ;;; Sequence functions. -(defalias 'cl-copy-seq 'copy-sequence) +(cl--defalias 'cl-copy-seq 'copy-sequence) (declare-function cl--mapcar-many "cl-extra" (cl-func cl-seqs)) @@ -387,141 +389,160 @@ SEQ, this is like `mapcar'. With several, it is like the Common Lisp (nreverse cl-res))) (mapcar cl-func cl-x))) -(defalias 'cl-svref 'aref) +(cl--defalias 'cl-svref 'aref) ;;; List functions. -(defalias 'cl-first 'car) -(defalias 'cl-second 'cadr) -(defalias 'cl-rest 'cdr) -(defalias 'cl-endp 'null) - -(defun cl-third (x) - "Return the cl-third element of the list X." - (car (cdr (cdr x)))) +(cl--defalias 'cl-first 'car) +(cl--defalias 'cl-second 'cadr) +(cl--defalias 'cl-rest 'cdr) +(cl--defalias 'cl-endp 'null) -(defun cl-fourth (x) - "Return the cl-fourth element of the list X." - (nth 3 x)) +(cl--defalias 'cl-third 'cl-caddr "Return the third element of the list X.") +(cl--defalias 'cl-fourth 'cl-cadddr "Return the fourth element of the list X.") -(defun cl-fifth (x) - "Return the cl-fifth element of the list X." +(defsubst cl-fifth (x) + "Return the fifth element of the list X." (nth 4 x)) -(defun cl-sixth (x) - "Return the cl-sixth element of the list X." +(defsubst cl-sixth (x) + "Return the sixth element of the list X." (nth 5 x)) -(defun cl-seventh (x) - "Return the cl-seventh element of the list X." +(defsubst cl-seventh (x) + "Return the seventh element of the list X." (nth 6 x)) -(defun cl-eighth (x) - "Return the cl-eighth element of the list X." +(defsubst cl-eighth (x) + "Return the eighth element of the list X." (nth 7 x)) -(defun cl-ninth (x) - "Return the cl-ninth element of the list X." +(defsubst cl-ninth (x) + "Return the ninth element of the list X." (nth 8 x)) -(defun cl-tenth (x) - "Return the cl-tenth element of the list X." +(defsubst cl-tenth (x) + "Return the tenth element of the list X." (nth 9 x)) (defun cl-caaar (x) "Return the `car' of the `car' of the `car' of X." + (declare (compiler-macro cl--compiler-macro-cXXr)) (car (car (car x)))) (defun cl-caadr (x) "Return the `car' of the `car' of the `cdr' of X." + (declare (compiler-macro cl--compiler-macro-cXXr)) (car (car (cdr x)))) (defun cl-cadar (x) "Return the `car' of the `cdr' of the `car' of X." + (declare (compiler-macro cl--compiler-macro-cXXr)) (car (cdr (car x)))) (defun cl-caddr (x) "Return the `car' of the `cdr' of the `cdr' of X." + (declare (compiler-macro cl--compiler-macro-cXXr)) (car (cdr (cdr x)))) (defun cl-cdaar (x) "Return the `cdr' of the `car' of the `car' of X." + (declare (compiler-macro cl--compiler-macro-cXXr)) (cdr (car (car x)))) (defun cl-cdadr (x) "Return the `cdr' of the `car' of the `cdr' of X." + (declare (compiler-macro cl--compiler-macro-cXXr)) (cdr (car (cdr x)))) (defun cl-cddar (x) "Return the `cdr' of the `cdr' of the `car' of X." + (declare (compiler-macro cl--compiler-macro-cXXr)) (cdr (cdr (car x)))) (defun cl-cdddr (x) "Return the `cdr' of the `cdr' of the `cdr' of X." + (declare (compiler-macro cl--compiler-macro-cXXr)) (cdr (cdr (cdr x)))) (defun cl-caaaar (x) "Return the `car' of the `car' of the `car' of the `car' of X." + (declare (compiler-macro cl--compiler-macro-cXXr)) (car (car (car (car x))))) (defun cl-caaadr (x) "Return the `car' of the `car' of the `car' of the `cdr' of X." + (declare (compiler-macro cl--compiler-macro-cXXr)) (car (car (car (cdr x))))) (defun cl-caadar (x) "Return the `car' of the `car' of the `cdr' of the `car' of X." + (declare (compiler-macro cl--compiler-macro-cXXr)) (car (car (cdr (car x))))) (defun cl-caaddr (x) "Return the `car' of the `car' of the `cdr' of the `cdr' of X." + (declare (compiler-macro cl--compiler-macro-cXXr)) (car (car (cdr (cdr x))))) (defun cl-cadaar (x) "Return the `car' of the `cdr' of the `car' of the `car' of X." + (declare (compiler-macro cl--compiler-macro-cXXr)) (car (cdr (car (car x))))) (defun cl-cadadr (x) "Return the `car' of the `cdr' of the `car' of the `cdr' of X." + (declare (compiler-macro cl--compiler-macro-cXXr)) (car (cdr (car (cdr x))))) (defun cl-caddar (x) "Return the `car' of the `cdr' of the `cdr' of the `car' of X." + (declare (compiler-macro cl--compiler-macro-cXXr)) (car (cdr (cdr (car x))))) (defun cl-cadddr (x) "Return the `car' of the `cdr' of the `cdr' of the `cdr' of X." + (declare (compiler-macro cl--compiler-macro-cXXr)) (car (cdr (cdr (cdr x))))) (defun cl-cdaaar (x) "Return the `cdr' of the `car' of the `car' of the `car' of X." + (declare (compiler-macro cl--compiler-macro-cXXr)) (cdr (car (car (car x))))) (defun cl-cdaadr (x) "Return the `cdr' of the `car' of the `car' of the `cdr' of X." + (declare (compiler-macro cl--compiler-macro-cXXr)) (cdr (car (car (cdr x))))) (defun cl-cdadar (x) "Return the `cdr' of the `car' of the `cdr' of the `car' of X." + (declare (compiler-macro cl--compiler-macro-cXXr)) (cdr (car (cdr (car x))))) (defun cl-cdaddr (x) "Return the `cdr' of the `car' of the `cdr' of the `cdr' of X." + (declare (compiler-macro cl--compiler-macro-cXXr)) (cdr (car (cdr (cdr x))))) (defun cl-cddaar (x) "Return the `cdr' of the `cdr' of the `car' of the `car' of X." + (declare (compiler-macro cl--compiler-macro-cXXr)) (cdr (cdr (car (car x))))) (defun cl-cddadr (x) "Return the `cdr' of the `cdr' of the `car' of the `cdr' of X." + (declare (compiler-macro cl--compiler-macro-cXXr)) (cdr (cdr (car (cdr x))))) (defun cl-cdddar (x) "Return the `cdr' of the `cdr' of the `cdr' of the `car' of X." + (declare (compiler-macro cl--compiler-macro-cXXr)) (cdr (cdr (cdr (car x))))) (defun cl-cddddr (x) "Return the `cdr' of the `cdr' of the `cdr' of the `cdr' of X." + (declare (compiler-macro cl--compiler-macro-cXXr)) (cdr (cdr (cdr (cdr x))))) ;;(defun last* (x &optional n) @@ -548,7 +569,6 @@ Thus, `(cl-list* A B C D)' is equivalent to `(nconc (list A B C) D)', or to (last (nthcdr (- n 2) copy))) (setcdr last (car (cdr last))) (cons arg copy))))) -(autoload 'cl--compiler-macro-list* "cl-macs") (defun cl-ldiff (list sublist) "Return a copy of LIST with the tail SUBLIST removed." @@ -585,7 +605,6 @@ Otherwise, return LIST unmodified. ((or (equal cl-keys '(:test equal)) (null cl-keys)) (if (member cl-item cl-list) cl-list (cons cl-item cl-list))) (t (apply 'cl--adjoin cl-item cl-list cl-keys)))) -(autoload 'cl--compiler-macro-adjoin "cl-macs") (defun cl-subst (cl-new cl-old cl-tree &rest cl-keys) "Substitute NEW for OLD everywhere in TREE (non-destructively). |