diff options
Diffstat (limited to 'lisp/emacs-lisp/byte-run.el')
-rw-r--r-- | lisp/emacs-lisp/byte-run.el | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/lisp/emacs-lisp/byte-run.el b/lisp/emacs-lisp/byte-run.el index 7322c0fbe6f..8f0999b2f80 100644 --- a/lisp/emacs-lisp/byte-run.el +++ b/lisp/emacs-lisp/byte-run.el @@ -79,12 +79,17 @@ The return value of this function is not used." (list 'quote f) (list 'quote arglist) (list 'quote when)))) (list 'obsolete #'(lambda (f _args new-name when) - `(make-obsolete ',f ',new-name ,when))) + (list 'make-obsolete + (list 'quote f) (list 'quote new-name) (list 'quote when)))) (list 'compiler-macro - #'(lambda (f _args compiler-function) - (if (not (symbolp compiler-function)) - (error "Only symbols are supported in `compiler-macro'") - `(put ',f 'compiler-macro #',compiler-function)))) + #'(lambda (f args compiler-function) + ;; FIXME: Make it possible to just reuse `args'. + `(eval-and-compile + (put ',f 'compiler-macro + ,(if (eq (car-safe compiler-function) 'lambda) + `(lambda ,(append (cadr compiler-function) args) + ,@(cddr compiler-function)) + `#',compiler-function))))) (list 'doc-string #'(lambda (f _args pos) (list 'put (list 'quote f) ''doc-string-elt (list 'quote pos)))) @@ -374,7 +379,7 @@ obsolete." (defmacro dont-compile (&rest body) "Like `progn', but the body always runs interpreted (not compiled). If you think you need this, you're probably making a mistake somewhere." - (declare (debug t) (indent 0)) + (declare (debug t) (indent 0) (obsolete nil "24.4")) (list 'eval (list 'quote (if (cdr body) (cons 'progn body) (car body))))) @@ -388,19 +393,19 @@ If you think you need this, you're probably making a mistake somewhere." Thus, the result of the body appears to the compiler as a quoted constant. In interpreted code, this is entirely equivalent to `progn'." (declare (debug t) (indent 0)) - ;; Not necessary because we have it in b-c-initial-macro-environment - ;; (list 'quote (eval (cons 'progn body))) - (cons 'progn body)) + (list 'quote (eval (cons 'progn body) lexical-binding))) (defmacro eval-and-compile (&rest body) "Like `progn', but evaluates the body at compile time and at load time." (declare (debug t) (indent 0)) - ;; Remember, it's magic. - (cons 'progn body)) + ;; When the byte-compiler expands code, this macro is not used, so we're + ;; either about to run `body' (plain interpretation) or we're doing eager + ;; macroexpansion. + (list 'quote (eval (cons 'progn body) lexical-binding))) -(put 'with-no-warnings 'lisp-indent-function 0) (defun with-no-warnings (&rest body) "Like `progn', but prevents compiler warnings in the body." + (declare (indent 0)) ;; The implementation for the interpreter is basically trivial. (car (last body))) |