76 |
(eval-and-compile |
(eval-and-compile |
77 |
(put ',name 'byte-optimizer 'byte-compile-inline-expand)))) |
(put ',name 'byte-optimizer 'byte-compile-inline-expand)))) |
78 |
|
|
79 |
(defun make-obsolete (fn new &optional when) |
(defun make-obsolete (function new &optional when) |
80 |
"Make the byte-compiler warn that FUNCTION is obsolete. |
"Make the byte-compiler warn that FUNCTION is obsolete. |
81 |
The warning will say that NEW should be used instead. |
The warning will say that NEW should be used instead. |
82 |
If NEW is a string, that is the `use instead' message. |
If NEW is a string, that is the `use instead' message. |
83 |
If provided, WHEN should be a string indicating when the function |
If provided, WHEN should be a string indicating when the function |
84 |
was first made obsolete, for example a date or a release number." |
was first made obsolete, for example a date or a release number." |
85 |
(interactive "aMake function obsolete: \nxObsoletion replacement: ") |
(interactive "aMake function obsolete: \nxObsoletion replacement: ") |
86 |
(let ((handler (get fn 'byte-compile))) |
(let ((handler (get function 'byte-compile))) |
87 |
(if (eq 'byte-compile-obsolete handler) |
(if (eq 'byte-compile-obsolete handler) |
88 |
(setq handler (nth 1 (get fn 'byte-obsolete-info))) |
(setq handler (nth 1 (get function 'byte-obsolete-info))) |
89 |
(put fn 'byte-compile 'byte-compile-obsolete)) |
(put function 'byte-compile 'byte-compile-obsolete)) |
90 |
(put fn 'byte-obsolete-info (list new handler when))) |
(put function 'byte-obsolete-info (list new handler when))) |
91 |
fn) |
function) |
92 |
|
|
93 |
(defun make-obsolete-variable (var new &optional when) |
(defun make-obsolete-variable (variable new &optional when) |
94 |
"Make the byte-compiler warn that VARIABLE is obsolete. |
"Make the byte-compiler warn that VARIABLE is obsolete. |
95 |
The warning will say that NEW should be used instead. |
The warning will say that NEW should be used instead. |
96 |
If NEW is a string, that is the `use instead' message. |
If NEW is a string, that is the `use instead' message. |
102 |
(if (equal str "") (error "")) |
(if (equal str "") (error "")) |
103 |
(intern str)) |
(intern str)) |
104 |
(car (read-from-string (read-string "Obsoletion replacement: "))))) |
(car (read-from-string (read-string "Obsoletion replacement: "))))) |
105 |
(put var 'byte-obsolete-variable (cons new when)) |
(put variable 'byte-obsolete-variable (cons new when)) |
106 |
var) |
variable) |
107 |
|
|
108 |
(put 'dont-compile 'lisp-indent-hook 0) |
(put 'dont-compile 'lisp-indent-hook 0) |
109 |
(defmacro dont-compile (&rest body) |
(defmacro dont-compile (&rest body) |
134 |
;; Remember, it's magic. |
;; Remember, it's magic. |
135 |
(cons 'progn body)) |
(cons 'progn body)) |
136 |
|
|
137 |
(defun with-no-warnings (&optional first &rest body) |
(defun with-no-warnings (&rest body) |
138 |
"Like `progn', but prevents compiler warnings in the body." |
"Like `progn', but prevents compiler warnings in the body." |
139 |
;; The implementation for the interpreter is basically trivial. |
;; The implementation for the interpreter is basically trivial. |
140 |
(if body (car (last body)) |
(car (last body))) |
|
first)) |
|
141 |
|
|
142 |
|
|
143 |
;;; I nuked this because it's not a good idea for users to think of using it. |
;;; I nuked this because it's not a good idea for users to think of using it. |