aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2008-04-26 02:32:51 +0000
committerGlenn Morris2008-04-26 02:32:51 +0000
commit5791bedf991b09f52d31add9cd5945d65bb59bcf (patch)
tree85bbff970e7ca954376c2fd101606b82816fee3e
parent497a66ae0a5bce75b6acd87549852fe8151c4c6a (diff)
downloademacs-5791bedf991b09f52d31add9cd5945d65bb59bcf.tar.gz
emacs-5791bedf991b09f52d31add9cd5945d65bb59bcf.zip
(byte-compile-warn-obsolete): New function.
(byte-compile-obsolete, byte-compile-variable-ref): Use it.
-rw-r--r--lisp/emacs-lisp/bytecomp.el46
1 files changed, 23 insertions, 23 deletions
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 1ba4de2f354..e54d1edf4d5 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -1106,6 +1106,22 @@ Each function's symbol gets added to `byte-compile-noruntime-functions'."
1106 (error "%s" format) ; byte-compile-file catches and logs it 1106 (error "%s" format) ; byte-compile-file catches and logs it
1107 (byte-compile-log-warning format t :warning))) 1107 (byte-compile-log-warning format t :warning)))
1108 1108
1109(defun byte-compile-warn-obsolete (symbol)
1110 "Warn that SYMBOL (a variable or function) is obsolete."
1111 (when (byte-compile-warning-enabled-p 'obsolete)
1112 (let* ((funcp (get symbol 'byte-obsolete-info))
1113 (obsolete (or funcp (get symbol 'byte-obsolete-variable)))
1114 (instead (car obsolete))
1115 (asof (if funcp (nth 2 obsolete) (cdr obsolete))))
1116 (byte-compile-warn "`%s' is an obsolete %s%s%s" symbol
1117 (if funcp "function" "variable")
1118 (if asof (concat " (as of Emacs " asof ")") "")
1119 (cond ((stringp instead)
1120 (concat "; " instead))
1121 (instead
1122 (format "; use `%s' instead." instead))
1123 (t "."))))))
1124
1109(defun byte-compile-report-error (error-info) 1125(defun byte-compile-report-error (error-info)
1110 "Report Lisp error in compilation. ERROR-INFO is the error data." 1126 "Report Lisp error in compilation. ERROR-INFO is the error data."
1111 (setq byte-compiler-error-flag t) 1127 (setq byte-compiler-error-flag t)
@@ -1115,19 +1131,10 @@ Each function's symbol gets added to `byte-compile-noruntime-functions'."
1115 1131
1116;;; Used by make-obsolete. 1132;;; Used by make-obsolete.
1117(defun byte-compile-obsolete (form) 1133(defun byte-compile-obsolete (form)
1118 (let* ((new (get (car form) 'byte-obsolete-info)) 1134 (byte-compile-set-symbol-position (car form))
1119 (use (car new)) 1135 (byte-compile-warn-obsolete (car form))
1120 (handler (nth 1 new)) 1136 (funcall (or (cadr (get (car form) 'byte-obsolete-info)) ; handler
1121 (when (nth 2 new))) 1137 'byte-compile-normal-call) form))
1122 (byte-compile-set-symbol-position (car form))
1123 (if (byte-compile-warning-enabled-p 'obsolete)
1124 (byte-compile-warn "`%s' is an obsolete function%s%s" (car form)
1125 (if when (concat " (as of Emacs " when ")") "")
1126 (cond ((stringp use)
1127 (concat "; " use))
1128 (use (format "; use `%s' instead." use))
1129 (t "."))))
1130 (funcall (or handler 'byte-compile-normal-call) form)))
1131 1138
1132;; Compiler options 1139;; Compiler options
1133 1140
@@ -2930,16 +2937,9 @@ That command is designed for interactive use only" fn))
2930 (t "variable reference to %s `%s'")) 2937 (t "variable reference to %s `%s'"))
2931 (if (symbolp var) "constant" "nonvariable") 2938 (if (symbolp var) "constant" "nonvariable")
2932 (prin1-to-string var)) 2939 (prin1-to-string var))
2933 (if (and (get var 'byte-obsolete-variable) 2940 (and (get var 'byte-obsolete-variable)
2934 (byte-compile-warning-enabled-p 'obsolete) 2941 (not (eq var byte-compile-not-obsolete-var))
2935 (not (eq var byte-compile-not-obsolete-var))) 2942 (byte-compile-warn-obsolete var))
2936 (let* ((ob (get var 'byte-obsolete-variable))
2937 (when (cdr ob)))
2938 (byte-compile-warn "`%s' is an obsolete variable%s; %s" var
2939 (if when (concat " (as of Emacs " when ")") "")
2940 (if (stringp (car ob))
2941 (car ob)
2942 (format "use `%s' instead." (car ob))))))
2943 (if (byte-compile-warning-enabled-p 'free-vars) 2943 (if (byte-compile-warning-enabled-p 'free-vars)
2944 (if (eq base-op 'byte-varbind) 2944 (if (eq base-op 'byte-varbind)
2945 (push var byte-compile-bound-variables) 2945 (push var byte-compile-bound-variables)