X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/3fdfb09c1c320351dcf3fc3d93cbf08181e714b6..3fe269229781c0530ed48272c39f0a10fa3ee06b:/lisp/emacs-lisp/byte-run.el diff --git a/lisp/emacs-lisp/byte-run.el b/lisp/emacs-lisp/byte-run.el index ef426494b6..3728eea8bf 100644 --- a/lisp/emacs-lisp/byte-run.el +++ b/lisp/emacs-lisp/byte-run.el @@ -31,12 +31,36 @@ ;;; Code: +;; We define macro-declaration-function here because it is needed to +;; handle declarations in macro definitions and this is the first file +;; loaded by loadup.el that uses declarations in macros. + +(defun macro-declaration-function (macro decl) + "Process a declaration found in a macro definition. +This is set as the value of the variable `macro-declaration-function'. +MACRO is the name of the macro being defined. +DECL is a list `(declare ...)' containing the declarations. +The return value of this function is not used." + ;; We can't use `dolist' or `cadr' yet for bootstrapping reasons. + (let (d) + ;; Ignore the first element of `decl' (it's always `declare'). + (while (setq decl (cdr decl)) + (setq d (car decl)) + (cond ((and (consp d) (eq (car d) 'indent)) + (put macro 'lisp-indent-function (car (cdr d)))) + ((and (consp d) (eq (car d) 'debug)) + (put macro 'edebug-form-spec (car (cdr d)))) + (t + (message "Unknown declaration %s" d)))))) + +(setq macro-declaration-function 'macro-declaration-function) + + ;; Redefined in byte-optimize.el. ;; This is not documented--it's not clear that we should promote it. (fset 'inline 'progn) (put 'inline 'lisp-indent-function 0) - ;;; Interface to inline functions. ;; (defmacro proclaim-inline (&rest fns) @@ -90,6 +114,18 @@ was first made obsolete, for example a date or a release number." (put function 'byte-obsolete-info (list new handler when))) function) +(defmacro define-obsolete-function-alias (function new + &optional when docstring) + "Set FUNCTION's function definition to NEW and warn that FUNCTION is obsolete. +If provided, WHEN should be a string indicating when FUNCTION was +first made obsolete, for example a date or a release number. The +optional argument DOCSTRING specifies the documentation string +for FUNCTION; if DOCSTRING is omitted or nil, FUNCTION uses the +documentation string of NEW unless it already has one." + `(progn + (defalias ,function ,new ,docstring) + (make-obsolete ,function ,new ,when))) + (defun make-obsolete-variable (variable new &optional when) "Make the byte-compiler warn that VARIABLE is obsolete. The warning will say that NEW should be used instead. @@ -105,11 +141,22 @@ was first made obsolete, for example a date or a release number." (put variable 'byte-obsolete-variable (cons new when)) variable) -(put 'dont-compile 'lisp-indent-function 0) +(defmacro define-obsolete-variable-alias (variable new + &optional when docstring) + "Make VARIABLE a variable alias for NEW and warn that VARIABLE is obsolete. +If provided, WHEN should be a string indicating when VARIABLE was +first made obsolete, for example a date or a release number. The +optional argument DOCSTRING specifies the documentation string +for VARIABLE; if DOCSTRING is omitted or nil, VARIABLE uses the +documentation string of NEW unless it already has one." + `(progn + (defvaralias ,variable ,new ,docstring) + (make-obsolete-variable ,variable ,new ,when))) + (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)) + (declare (debug t) (indent 0)) (list 'eval (list 'quote (if (cdr body) (cons 'progn body) (car body))))) @@ -118,19 +165,17 @@ If you think you need this, you're probably making a mistake somewhere." ;;; definition in the file overrides the magic definitions on the ;;; byte-compile-macro-environment. -(put 'eval-when-compile 'lisp-indent-function 0) (defmacro eval-when-compile (&rest body) "Like `progn', but evaluates the body at compile time. The result of the body appears to the compiler as a quoted constant." - (declare (debug t)) + (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)) -(put 'eval-and-compile 'lisp-indent-function 0) (defmacro eval-and-compile (&rest body) "Like `progn', but evaluates the body at compile time and at load time." - (declare (debug t)) + (declare (debug t) (indent 0)) ;; Remember, it's magic. (cons 'progn body))