* emacs-lisp/byte-run.el (advertised-signature-table): New var.
(set-advertised-calling-convention): New function. (make-obsolete, define-obsolete-function-alias) (make-obsolete-variable, define-obsolete-variable-alias): Make the optional-ness of `when' obsolete. (define-obsolete-face-alias): Make `when' non-optional. * help-fns.el (help-function-arglist): * emacs-lisp/bytecomp.el (byte-compile-fdefinition): Use advertised-signature-table.
This commit is contained in:
parent
d308026462
commit
ced10a4c9f
5 changed files with 68 additions and 29 deletions
|
@ -106,6 +106,15 @@ The return value of this function is not used."
|
|||
(eval-and-compile
|
||||
(put ',name 'byte-optimizer 'byte-compile-inline-expand))))
|
||||
|
||||
(defvar advertised-signature-table (make-hash-table :test 'eq :weakness 'key))
|
||||
|
||||
(defun set-advertised-calling-convention (function signature)
|
||||
"Set the advertised SIGNATURE of FUNCTION.
|
||||
This will allow the byte-compiler to warn the programmer when she uses
|
||||
an obsolete calling convention."
|
||||
(puthash (indirect-function function) signature
|
||||
advertised-signature-table))
|
||||
|
||||
(defun make-obsolete (obsolete-name current-name &optional when)
|
||||
"Make the byte-compiler warn that OBSOLETE-NAME is obsolete.
|
||||
The warning will say that CURRENT-NAME should be used instead.
|
||||
|
@ -120,6 +129,9 @@ was first made obsolete, for example a date or a release number."
|
|||
(put obsolete-name 'byte-compile 'byte-compile-obsolete))
|
||||
(put obsolete-name 'byte-obsolete-info (list current-name handler when)))
|
||||
obsolete-name)
|
||||
(set-advertised-calling-convention
|
||||
;; New code should always provide the `when' argument.
|
||||
'make-obsolete '(obsolete-name current-name when))
|
||||
|
||||
(defmacro define-obsolete-function-alias (obsolete-name current-name
|
||||
&optional when docstring)
|
||||
|
@ -137,6 +149,10 @@ See the docstrings of `defalias' and `make-obsolete' for more details."
|
|||
`(progn
|
||||
(defalias ,obsolete-name ,current-name ,docstring)
|
||||
(make-obsolete ,obsolete-name ,current-name ,when)))
|
||||
(set-advertised-calling-convention
|
||||
;; New code should always provide the `when' argument.
|
||||
'define-obsolete-function-alias
|
||||
'(obsolete-name current-name when &optional docstring))
|
||||
|
||||
(defun make-obsolete-variable (obsolete-name current-name &optional when)
|
||||
"Make the byte-compiler warn that OBSOLETE-NAME is obsolete.
|
||||
|
@ -152,6 +168,9 @@ was first made obsolete, for example a date or a release number."
|
|||
(car (read-from-string (read-string "Obsoletion replacement: ")))))
|
||||
(put obsolete-name 'byte-obsolete-variable (cons current-name when))
|
||||
obsolete-name)
|
||||
(set-advertised-calling-convention
|
||||
;; New code should always provide the `when' argument.
|
||||
'make-obsolete-variable '(obsolete-name current-name when))
|
||||
|
||||
(defmacro define-obsolete-variable-alias (obsolete-name current-name
|
||||
&optional when docstring)
|
||||
|
@ -179,14 +198,17 @@ Info node `(elisp)Variable Aliases' for more details."
|
|||
`(progn
|
||||
(defvaralias ,obsolete-name ,current-name ,docstring)
|
||||
(make-obsolete-variable ,obsolete-name ,current-name ,when)))
|
||||
(set-advertised-calling-convention
|
||||
;; New code should always provide the `when' argument.
|
||||
'define-obsolete-variable-alias
|
||||
'(obsolete-name current-name when &optional docstring))
|
||||
|
||||
;; FIXME This is only defined in this file because the variable- and
|
||||
;; function- versions are too. Unlike those two, this one is not used
|
||||
;; by the byte-compiler (would be nice if it could warn about obsolete
|
||||
;; faces, but it doesn't really do anything special with faces).
|
||||
;; It only really affects M-x describe-face output.
|
||||
(defmacro define-obsolete-face-alias (obsolete-face current-face
|
||||
&optional when)
|
||||
(defmacro define-obsolete-face-alias (obsolete-face current-face when)
|
||||
"Make OBSOLETE-FACE a face alias for CURRENT-FACE and mark it obsolete.
|
||||
The optional string WHEN gives the Emacs version where OBSOLETE-FACE
|
||||
became obsolete."
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue