aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2000-06-01 04:58:08 +0000
committerStefan Monnier2000-06-01 04:58:08 +0000
commit20482b7061ced4500c005f1bd2c4e59d831e35c9 (patch)
tree28f1d0241ecc51f7198696dd62b980b56d3994f2
parent6684834d92267991a6eb918ba18ba4b2d40932d8 (diff)
downloademacs-20482b7061ced4500c005f1bd2c4e59d831e35c9.tar.gz
emacs-20482b7061ced4500c005f1bd2c4e59d831e35c9.zip
* byte-run.el (make-obsolete, make-obsolete-variable):
Add an optional WHEN argument and change the format of the symbol-property information. * emacs-lisp/bytecomp.el (byte-compile-log): Don't quote lambda. (byte-compile-obsolete, byte-compile-variable-ref): Understand the new obsolete-symbol-property format and print WHEN if it is provided. (make-obsolete): Update the calls to use the third argument.
-rw-r--r--lisp/byte-run.el20
-rw-r--r--lisp/emacs-lisp/bytecomp.el80
2 files changed, 57 insertions, 43 deletions
diff --git a/lisp/byte-run.el b/lisp/byte-run.el
index af34a459419..09c59818b22 100644
--- a/lisp/byte-run.el
+++ b/lisp/byte-run.el
@@ -76,29 +76,33 @@
76 (list 'put (list 'quote name) 76 (list 'put (list 'quote name)
77 ''byte-optimizer ''byte-compile-inline-expand)))) 77 ''byte-optimizer ''byte-compile-inline-expand))))
78 78
79(defun make-obsolete (fn new) 79(defun make-obsolete (fn new &optional when)
80 "Make the byte-compiler warn that FUNCTION is obsolete. 80 "Make the byte-compiler warn that FUNCTION is obsolete.
81The warning will say that NEW should be used instead. 81The warning will say that NEW should be used instead.
82If NEW is a string, that is the `use instead' message." 82If NEW is a string, that is the `use instead' message.
83If provided, WHEN should be a string indicating when the function
84was first made obsolete, for example a date or a release number."
83 (interactive "aMake function obsolete: \nxObsoletion replacement: ") 85 (interactive "aMake function obsolete: \nxObsoletion replacement: ")
84 (let ((handler (get fn 'byte-compile))) 86 (let ((handler (get fn 'byte-compile)))
85 (if (eq 'byte-compile-obsolete handler) 87 (if (eq 'byte-compile-obsolete handler)
86 (setcar (get fn 'byte-obsolete-info) new) 88 (setq handler (nth 1 (get fn 'byte-obsolete-info)))
87 (put fn 'byte-obsolete-info (cons new handler)) 89 (put fn 'byte-compile 'byte-compile-obsolete))
88 (put fn 'byte-compile 'byte-compile-obsolete))) 90 (put fn 'byte-obsolete-info (list new handler when)))
89 fn) 91 fn)
90 92
91(defun make-obsolete-variable (var new) 93(defun make-obsolete-variable (var new &optional when)
92 "Make the byte-compiler warn that VARIABLE is obsolete, 94 "Make the byte-compiler warn that VARIABLE is obsolete,
93and NEW should be used instead. If NEW is a string, then that is the 95and NEW should be used instead. If NEW is a string, then that is the
94`use instead' message." 96`use instead' message.
97If provided, WHEN should be a string indicating when the variable
98was first made obsolete, for example a date or a release number."
95 (interactive 99 (interactive
96 (list 100 (list
97 (let ((str (completing-read "Make variable obsolete: " obarray 'boundp t))) 101 (let ((str (completing-read "Make variable obsolete: " obarray 'boundp t)))
98 (if (equal str "") (error "")) 102 (if (equal str "") (error ""))
99 (intern str)) 103 (intern str))
100 (car (read-from-string (read-string "Obsoletion replacement: "))))) 104 (car (read-from-string (read-string "Obsoletion replacement: ")))))
101 (put var 'byte-obsolete-variable new) 105 (put var 'byte-obsolete-variable (cons new when))
102 var) 106 var)
103 107
104(put 'dont-compile 'lisp-indent-hook 0) 108(put 'dont-compile 'lisp-indent-hook 0)
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index c16e2d80568..0d183fa9ec0 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -10,7 +10,7 @@
10 10
11;;; This version incorporates changes up to version 2.10 of the 11;;; This version incorporates changes up to version 2.10 of the
12;;; Zawinski-Furuseth compiler. 12;;; Zawinski-Furuseth compiler.
13(defconst byte-compile-version "$Revision: 2.69 $") 13(defconst byte-compile-version "$Revision: 2.70 $")
14 14
15;; This file is part of GNU Emacs. 15;; This file is part of GNU Emacs.
16 16
@@ -806,8 +806,8 @@ Each function's symbol gets marked with the `byte-compile-noruntime' property."
806 (cons 'format 806 (cons 'format
807 (cons format-string 807 (cons format-string
808 (mapcar 808 (mapcar
809 '(lambda (x) 809 (lambda (x)
810 (if (symbolp x) (list 'prin1-to-string x) x)) 810 (if (symbolp x) (list 'prin1-to-string x) x))
811 args))))))) 811 args)))))))
812 812
813(defconst byte-compile-last-warned-form nil) 813(defconst byte-compile-last-warned-form nil)
@@ -895,13 +895,16 @@ Each function's symbol gets marked with the `byte-compile-noruntime' property."
895 895
896;;; Used by make-obsolete. 896;;; Used by make-obsolete.
897(defun byte-compile-obsolete (form) 897(defun byte-compile-obsolete (form)
898 (let ((new (get (car form) 'byte-obsolete-info))) 898 (let* ((new (get (car form) 'byte-obsolete-info))
899 (handler (nth 1 new))
900 (when (nth 2 new)))
899 (if (memq 'obsolete byte-compile-warnings) 901 (if (memq 'obsolete byte-compile-warnings)
900 (byte-compile-warn "%s is an obsolete function; %s" (car form) 902 (byte-compile-warn "%s is an obsolete function%s; %s" (car form)
903 (if when (concat " since " when) "")
901 (if (stringp (car new)) 904 (if (stringp (car new))
902 (car new) 905 (car new)
903 (format "use %s instead." (car new))))) 906 (format "use %s instead." (car new)))))
904 (funcall (or (cdr new) 'byte-compile-normal-call) form))) 907 (funcall (or handler 'byte-compile-normal-call) form)))
905 908
906;; Compiler options 909;; Compiler options
907 910
@@ -2383,11 +2386,13 @@ If FORM is a lambda or a macro, byte-compile it as a function."
2383 (prin1-to-string var)) 2386 (prin1-to-string var))
2384 (if (and (get var 'byte-obsolete-variable) 2387 (if (and (get var 'byte-obsolete-variable)
2385 (memq 'obsolete byte-compile-warnings)) 2388 (memq 'obsolete byte-compile-warnings))
2386 (let ((ob (get var 'byte-obsolete-variable))) 2389 (let* ((ob (get var 'byte-obsolete-variable))
2387 (byte-compile-warn "%s is an obsolete variable; %s" var 2390 (when (cdr ob)))
2388 (if (stringp ob) 2391 (byte-compile-warn "%s is an obsolete variable%s; %s" var
2389 ob 2392 (if when (concat " since " when) "")
2390 (format "use %s instead." ob))))) 2393 (if (stringp (car ob))
2394 (car ob)
2395 (format "use %s instead." (car ob))))))
2391 (if (memq 'free-vars byte-compile-warnings) 2396 (if (memq 'free-vars byte-compile-warnings)
2392 (if (eq base-op 'byte-varbind) 2397 (if (eq base-op 'byte-varbind)
2393 (setq byte-compile-bound-variables 2398 (setq byte-compile-bound-variables
@@ -3551,37 +3556,42 @@ For example, invoke `emacs -batch -f batch-byte-recompile-directory .'."
3551 (kill-emacs 0)) 3556 (kill-emacs 0))
3552 3557
3553 3558
3554(make-obsolete 'dot 'point) 3559(make-obsolete 'dot 'point "before 19.15")
3555(make-obsolete 'dot-max 'point-max) 3560(make-obsolete 'dot-max 'point-max "before 19.15")
3556(make-obsolete 'dot-min 'point-min) 3561(make-obsolete 'dot-min 'point-min "before 19.15")
3557(make-obsolete 'dot-marker 'point-marker) 3562(make-obsolete 'dot-marker 'point-marker "before 19.15")
3558 3563
3559(make-obsolete 'buffer-flush-undo 'buffer-disable-undo) 3564(make-obsolete 'buffer-flush-undo 'buffer-disable-undo "before 19.15")
3560(make-obsolete 'baud-rate "use the baud-rate variable instead") 3565(make-obsolete 'baud-rate "use the baud-rate variable instead" "before 19.15")
3561(make-obsolete 'compiled-function-p 'byte-code-function-p) 3566(make-obsolete 'compiled-function-p 'byte-code-function-p "before 19.15")
3562(make-obsolete 'define-function 'defalias) 3567(make-obsolete 'define-function 'defalias "20.1")
3563(make-obsolete-variable 'auto-fill-hook 'auto-fill-function) 3568(make-obsolete-variable 'auto-fill-hook 'auto-fill-function "before 19.15")
3564(make-obsolete-variable 'blink-paren-hook 'blink-paren-function) 3569(make-obsolete-variable 'blink-paren-hook 'blink-paren-function "before 19.15")
3565(make-obsolete-variable 'lisp-indent-hook 'lisp-indent-function) 3570(make-obsolete-variable 'lisp-indent-hook 'lisp-indent-function "before 19.15")
3566(make-obsolete-variable 'inhibit-local-variables 3571(make-obsolete-variable 'inhibit-local-variables
3567 "use enable-local-variables (with the reversed sense).") 3572 "use enable-local-variables (with the reversed sense)."
3573 "before 19.15")
3568(make-obsolete-variable 'unread-command-char 3574(make-obsolete-variable 'unread-command-char
3569 "use unread-command-events instead. That variable is a list of events to reread, so it now uses nil to mean `no event', instead of -1.") 3575 "use unread-command-events instead. That variable is a list of events to reread, so it now uses nil to mean `no event', instead of -1."
3576 "before 19.15")
3570(make-obsolete-variable 'unread-command-event 3577(make-obsolete-variable 'unread-command-event
3571 "use unread-command-events; which is a list of events rather than a single event.") 3578 "use unread-command-events; which is a list of events rather than a single event."
3572(make-obsolete-variable 'suspend-hooks 'suspend-hook) 3579 "before 19.15")
3573(make-obsolete-variable 'comment-indent-hook 'comment-indent-function) 3580(make-obsolete-variable 'suspend-hooks 'suspend-hook "before 19.15")
3574(make-obsolete-variable 'meta-flag "Use the set-input-mode function instead.") 3581(make-obsolete-variable 'comment-indent-hook 'comment-indent-function "before 19.15")
3575(make-obsolete-variable 'executing-macro 'executing-kbd-macro) 3582(make-obsolete-variable 'meta-flag "Use the set-input-mode function instead." "before 19.34")
3583(make-obsolete-variable 'executing-macro 'executing-kbd-macro "before 19.34")
3576(make-obsolete-variable 'before-change-function 3584(make-obsolete-variable 'before-change-function
3577 "use before-change-functions; which is a list of functions rather than a single function.") 3585 "use before-change-functions; which is a list of functions rather than a single function."
3586 "before 19.34")
3578(make-obsolete-variable 'after-change-function 3587(make-obsolete-variable 'after-change-function
3579 "use after-change-functions; which is a list of functions rather than a single function.") 3588 "use after-change-functions; which is a list of functions rather than a single function."
3580(make-obsolete-variable 'font-lock-doc-string-face 'font-lock-string-face) 3589 "before 19.34")
3590(make-obsolete-variable 'font-lock-doc-string-face 'font-lock-string-face "before 19.34")
3581(make-obsolete-variable 'post-command-idle-hook 3591(make-obsolete-variable 'post-command-idle-hook
3582 "use timers instead, with `run-with-idle-timer'.") 3592 "use timers instead, with `run-with-idle-timer'." "before 19.34")
3583(make-obsolete-variable 'post-command-idle-delay 3593(make-obsolete-variable 'post-command-idle-delay
3584 "use timers instead, with `run-with-idle-timer'.") 3594 "use timers instead, with `run-with-idle-timer'." "before 19.34")
3585 3595
3586(provide 'byte-compile) 3596(provide 'byte-compile)
3587(provide 'bytecomp) 3597(provide 'bytecomp)