summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/cl-macs.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2012-06-08 22:26:47 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2012-06-08 22:26:47 -0400
commitd9857e534be786674818645a1c51410b4ca68cf8 (patch)
treea9ef3afbf43c114e4d913c3afc01b98ad9b184b8 /lisp/emacs-lisp/cl-macs.el
parent7cb70fd73eccd2725b8e436bff3295506816f935 (diff)
downloademacs-d9857e534be786674818645a1c51410b4ca68cf8.tar.gz
Don't autoload functions too eagerly during macroexpansion.
* lisp/emacs-lisp/macroexp.el (macroexp--expand-all): Only autoload a function if there's a clear indication that it has a compiler-macro. * lisp/emacs-lisp/byte-run.el (defun-declarations-alist, defmacro, defun) (macro-declarations-alist): Add arglist to declaration functions. (defun-declarations-alist): Add `obsolete' and `compiler-macro'. * lisp/emacs-lisp/cl-seq.el (cl-member, cl-assoc): * lisp/emacs-lisp/cl-lib.el (cl-list*, cl-adjoin): * lisp/emacs-lisp/cl-extra.el (cl-get): Use the new `declare' statement. Also add autoload to find the compiler macro. * lisp/emacs-lisp/cl-macs.el (eql) [compiler-macro]: Remove. (cl--compiler-macro-member, cl--compiler-macro-assoc) (cl--compiler-macro-adjoin, cl--compiler-macro-list*) (cl--compiler-macro-get): New functions, replacing calls to cl-define-compiler-macro. (cl-typep) [compiler-macro]: Use macroexp-let².
Diffstat (limited to 'lisp/emacs-lisp/cl-macs.el')
-rw-r--r--lisp/emacs-lisp/cl-macs.el42
1 files changed, 8 insertions, 34 deletions
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index 22ef55e3a52..60f1189718b 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -1,4 +1,4 @@
-;;; cl-macs.el --- Common Lisp macros --*- lexical-binding: t -*-
+;;; cl-macs.el --- Common Lisp macros -*- lexical-binding: t; coding: utf-8 -*-
;; Copyright (C) 1993, 2001-2012 Free Software Foundation, Inc.
@@ -2993,30 +2993,7 @@ surrounded by (cl-block NAME ...).
;; Note that cl.el arranges to force cl-macs to be loaded at compile-time,
;; mainly to make sure these macros will be present.
-(put 'eql 'byte-compile nil)
-(cl-define-compiler-macro eql (&whole form a b)
- (cond ((macroexp-const-p a)
- (let ((val (cl--const-expr-val a)))
- (if (and (numberp val) (not (integerp val)))
- `(equal ,a ,b)
- `(eq ,a ,b))))
- ((macroexp-const-p b)
- (let ((val (cl--const-expr-val b)))
- (if (and (numberp val) (not (integerp val)))
- `(equal ,a ,b)
- `(eq ,a ,b))))
- ((cl--simple-expr-p a 5)
- `(if (numberp ,a)
- (equal ,a ,b)
- (eq ,a ,b)))
- ((and (cl--safe-expr-p a)
- (cl--simple-expr-p b 5))
- `(if (numberp ,b)
- (equal ,a ,b)
- (eq ,a ,b)))
- (t form)))
-
-(cl-define-compiler-macro cl-member (&whole form a list &rest keys)
+(defun cl--compiler-macro-member (form a list &rest keys)
(let ((test (and (= (length keys) 2) (eq (car keys) :test)
(cl--const-expr-val (nth 1 keys)))))
(cond ((eq test 'eq) `(memq ,a ,list))
@@ -3024,7 +3001,7 @@ surrounded by (cl-block NAME ...).
((or (null keys) (eq test 'eql)) `(memql ,a ,list))
(t form))))
-(cl-define-compiler-macro cl-assoc (&whole form a list &rest keys)
+(defun cl--compiler-macro-assoc (form a list &rest keys)
(let ((test (and (= (length keys) 2) (eq (car keys) :test)
(cl--const-expr-val (nth 1 keys)))))
(cond ((eq test 'eq) `(assq ,a ,list))
@@ -3034,31 +3011,28 @@ surrounded by (cl-block NAME ...).
`(assoc ,a ,list) `(assq ,a ,list)))
(t form))))
-(cl-define-compiler-macro cl-adjoin (&whole form a list &rest keys)
+(defun cl--compiler-macro-adjoin (form a list &rest keys)
(if (and (cl--simple-expr-p a) (cl--simple-expr-p list)
(not (memq :key keys)))
`(if (cl-member ,a ,list ,@keys) ,list (cons ,a ,list))
form))
-(cl-define-compiler-macro cl-list* (arg &rest others)
+(defun cl--compiler-macro-list* (_form arg &rest others)
(let* ((args (reverse (cons arg others)))
(form (car args)))
(while (setq args (cdr args))
(setq form `(cons ,(car args) ,form)))
form))
-(cl-define-compiler-macro cl-get (sym prop &optional def)
+(defun cl--compiler-macro-get (_form sym prop &optional def)
(if def
`(cl-getf (symbol-plist ,sym) ,prop ,def)
`(get ,sym ,prop)))
(cl-define-compiler-macro cl-typep (&whole form val type)
(if (macroexp-const-p type)
- (let ((res (cl--make-type-test val (cl--const-expr-val type))))
- (if (or (memq (cl--expr-contains res val) '(nil 1))
- (cl--simple-expr-p val)) res
- (let ((temp (make-symbol "--cl-var--")))
- `(let ((,temp ,val)) ,(cl-subst temp val res)))))
+ (macroexp-let² macroexp-copyable-p temp val
+ (cl--make-type-test temp (cl--const-expr-val type)))
form))