diff options
| author | Stefan Monnier | 2009-11-27 22:03:04 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2009-11-27 22:03:04 +0000 |
| commit | 62a258a71d61b623ca071cd8113c01882e469ad7 (patch) | |
| tree | 027177beada5fab90103278cd45a79281dc9e5ac | |
| parent | c5269f1cd5bb589342127015860890e03e8bdf96 (diff) | |
| download | emacs-62a258a71d61b623ca071cd8113c01882e469ad7.tar.gz emacs-62a258a71d61b623ca071cd8113c01882e469ad7.zip | |
(byte-compile-warning-types): New type `suspicious'.
(byte-compile-warnings): Use byte-compile-warning-types.
(byte-compile-save-excursion): Warn about use of set-buffer right
after save-excursion.
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/emacs-lisp/bytecomp.el | 13 |
2 files changed, 13 insertions, 6 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 579ae1e7af1..15710daaf2c 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,11 @@ | |||
| 1 | 2009-11-27 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2009-11-27 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * emacs-lisp/bytecomp.el (byte-compile-warning-types): New type | ||
| 4 | `suspicious'. | ||
| 5 | (byte-compile-warnings): Use byte-compile-warning-types. | ||
| 6 | (byte-compile-save-excursion): Warn about use of set-buffer right | ||
| 7 | after save-excursion. | ||
| 8 | |||
| 3 | * progmodes/gud.el (gud-basic-call): Don't only save the buffer but | 9 | * progmodes/gud.el (gud-basic-call): Don't only save the buffer but |
| 4 | the excursion as well. | 10 | the excursion as well. |
| 5 | 11 | ||
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 2f0c7db4c34..bf7c2c113f0 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el | |||
| @@ -263,7 +263,7 @@ If it is 'byte, then only byte-level optimizations will be logged." | |||
| 263 | (defconst byte-compile-warning-types | 263 | (defconst byte-compile-warning-types |
| 264 | '(redefine callargs free-vars unresolved | 264 | '(redefine callargs free-vars unresolved |
| 265 | obsolete noruntime cl-functions interactive-only | 265 | obsolete noruntime cl-functions interactive-only |
| 266 | make-local mapcar constants) | 266 | make-local mapcar constants suspicious) |
| 267 | "The list of warning types used when `byte-compile-warnings' is t.") | 267 | "The list of warning types used when `byte-compile-warnings' is t.") |
| 268 | (defcustom byte-compile-warnings t | 268 | (defcustom byte-compile-warnings t |
| 269 | "List of warnings that the byte-compiler should issue (t for all). | 269 | "List of warnings that the byte-compiler should issue (t for all). |
| @@ -285,17 +285,15 @@ Elements of the list may be: | |||
| 285 | make-local calls to make-variable-buffer-local that may be incorrect. | 285 | make-local calls to make-variable-buffer-local that may be incorrect. |
| 286 | mapcar mapcar called for effect. | 286 | mapcar mapcar called for effect. |
| 287 | constants let-binding of, or assignment to, constants/nonvariables. | 287 | constants let-binding of, or assignment to, constants/nonvariables. |
| 288 | suspicious constructs that usually don't do what the coder wanted. | ||
| 288 | 289 | ||
| 289 | If the list begins with `not', then the remaining elements specify warnings to | 290 | If the list begins with `not', then the remaining elements specify warnings to |
| 290 | suppress. For example, (not mapcar) will suppress warnings about mapcar." | 291 | suppress. For example, (not mapcar) will suppress warnings about mapcar." |
| 291 | :group 'bytecomp | 292 | :group 'bytecomp |
| 292 | :type `(choice (const :tag "All" t) | 293 | :type `(choice (const :tag "All" t) |
| 293 | (set :menu-tag "Some" | 294 | (set :menu-tag "Some" |
| 294 | (const free-vars) (const unresolved) | 295 | ,@(mapcar (lambda (x) `(const ,x)) |
| 295 | (const callargs) (const redefine) | 296 | byte-compile-warning-types)))) |
| 296 | (const obsolete) (const noruntime) | ||
| 297 | (const cl-functions) (const interactive-only) | ||
| 298 | (const make-local) (const mapcar) (const constants)))) | ||
| 299 | ;;;###autoload(put 'byte-compile-warnings 'safe-local-variable 'byte-compile-warnings-safe-p) | 297 | ;;;###autoload(put 'byte-compile-warnings 'safe-local-variable 'byte-compile-warnings-safe-p) |
| 300 | 298 | ||
| 301 | ;;;###autoload | 299 | ;;;###autoload |
| @@ -3714,6 +3712,9 @@ that suppresses all warnings during execution of BODY." | |||
| 3714 | 3712 | ||
| 3715 | 3713 | ||
| 3716 | (defun byte-compile-save-excursion (form) | 3714 | (defun byte-compile-save-excursion (form) |
| 3715 | (if (and (eq 'set-buffer (car-safe (car-safe (cdr form)))) | ||
| 3716 | (byte-compile-warning-enabled-p 'suspicious)) | ||
| 3717 | (byte-compile-warn "`save-excursion' defeated by `set-buffer'.")) | ||
| 3717 | (byte-compile-out 'byte-save-excursion 0) | 3718 | (byte-compile-out 'byte-save-excursion 0) |
| 3718 | (byte-compile-body-do-effect (cdr form)) | 3719 | (byte-compile-body-do-effect (cdr form)) |
| 3719 | (byte-compile-out 'byte-unbind 1)) | 3720 | (byte-compile-out 'byte-unbind 1)) |