Commit 9e31e67b authored by Richard M. Stallman's avatar Richard M. Stallman
Browse files

(byte-compile-not-obsolete-var): New var.

(byte-compile-variable-ref): Handle byte-compile-not-obsolete-var.
(byte-compile-defvar): Bind byte-compile-not-obsolete-var
to prevent warnings about defvar for an obsolete variable.

(byte-compile-log-warning):
warning-group-format renamed to warning-type-format.
parent f0491f76
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
;;; This version incorporates changes up to version 2.10 of the ;;; This version incorporates changes up to version 2.10 of the
;;; Zawinski-Furuseth compiler. ;;; Zawinski-Furuseth compiler.
(defconst byte-compile-version "$Revision: 2.134 $") (defconst byte-compile-version "$Revision: 2.135 $")
;; This file is part of GNU Emacs. ;; This file is part of GNU Emacs.
...@@ -351,6 +351,9 @@ Elements of the list may be be: ...@@ -351,6 +351,9 @@ Elements of the list may be be:
(const callargs) (const redefine) (const callargs) (const redefine)
(const obsolete) (const noruntime) (const cl-functions)))) (const obsolete) (const noruntime) (const cl-functions))))
(defvar byte-compile-not-obsolete-var nil
"If non-nil, this is a variable that shouldn't be reported as obsolete.")
(defcustom byte-compile-generate-call-tree nil (defcustom byte-compile-generate-call-tree nil
"*Non-nil means collect call-graph information when compiling. "*Non-nil means collect call-graph information when compiling.
This records functions were called and from where. This records functions were called and from where.
...@@ -982,7 +985,7 @@ Each function's symbol gets marked with the `byte-compile-noruntime' property." ...@@ -982,7 +985,7 @@ Each function's symbol gets marked with the `byte-compile-noruntime' property."
;; Also log the current function and file if not already done. ;; Also log the current function and file if not already done.
(defun byte-compile-log-warning (string &optional fill level) (defun byte-compile-log-warning (string &optional fill level)
(let ((warning-prefix-function 'byte-compile-warning-prefix) (let ((warning-prefix-function 'byte-compile-warning-prefix)
(warning-group-format "") (warning-type-format "")
(warning-fill-prefix (if fill " "))) (warning-fill-prefix (if fill " ")))
(display-warning 'bytecomp string level "*Compile-Log*"))) (display-warning 'bytecomp string level "*Compile-Log*")))
...@@ -2705,7 +2708,8 @@ If FORM is a lambda or a macro, byte-compile it as a function." ...@@ -2705,7 +2708,8 @@ If FORM is a lambda or a macro, byte-compile it as a function."
(if (symbolp var) "constant" "nonvariable") (if (symbolp var) "constant" "nonvariable")
(prin1-to-string var)) (prin1-to-string var))
(if (and (get var 'byte-obsolete-variable) (if (and (get var 'byte-obsolete-variable)
(memq 'obsolete byte-compile-warnings)) (memq 'obsolete byte-compile-warnings)
(not (eq var byte-compile-not-obsolete-var)))
(let* ((ob (get var 'byte-obsolete-variable)) (let* ((ob (get var 'byte-obsolete-variable))
(when (cdr ob))) (when (cdr ob)))
(byte-compile-warn "%s is an obsolete variable%s; %s" var (byte-compile-warn "%s is an obsolete variable%s; %s" var
...@@ -3608,13 +3612,14 @@ If FORM is a lambda or a macro, byte-compile it as a function." ...@@ -3608,13 +3612,14 @@ If FORM is a lambda or a macro, byte-compile it as a function."
fun var string)) fun var string))
`(put ',var 'variable-documentation ,string)) `(put ',var 'variable-documentation ,string))
(if (cddr form) ; `value' provided (if (cddr form) ; `value' provided
(if (eq fun 'defconst) (let ((byte-compile-not-obsolete-var var))
;; `defconst' sets `var' unconditionally. (if (eq fun 'defconst)
(let ((tmp (make-symbol "defconst-tmp-var"))) ;; `defconst' sets `var' unconditionally.
`(funcall '(lambda (,tmp) (defconst ,var ,tmp)) (let ((tmp (make-symbol "defconst-tmp-var")))
,value)) `(funcall '(lambda (,tmp) (defconst ,var ,tmp))
;; `defvar' sets `var' only when unbound. ,value))
`(if (not (default-boundp ',var)) (setq-default ,var ,value))) ;; `defvar' sets `var' only when unbound.
`(if (not (default-boundp ',var)) (setq-default ,var ,value))))
(when (eq fun 'defconst) (when (eq fun 'defconst)
;; This will signal an appropriate error at runtime. ;; This will signal an appropriate error at runtime.
`(eval ',form))) `(eval ',form)))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment