diff options
| author | Lars Ingebrigtsen | 2019-06-12 15:59:19 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2019-06-12 15:59:19 +0200 |
| commit | f2071b6de417ea079ab55298e8ca8f7bb2ad8d14 (patch) | |
| tree | bbdc2892ff80632a5ffbfda98eb2ff7f20f8131e /doc | |
| parent | b8350e52ef6201103b12db5ad8b9268452feb8b6 (diff) | |
| download | emacs-f2071b6de417ea079ab55298e8ca8f7bb2ad8d14.tar.gz emacs-f2071b6de417ea079ab55298e8ca8f7bb2ad8d14.zip | |
Add the new macro with-suppressed-warnings
* lisp/emacs-lisp/byte-run.el (with-suppressed-warnings): New macro.
* doc/lispref/compile.texi (Compiler Errors): Document
with-suppressed-warnings and deemphasise with-no-warnings
slightly.
* lisp/emacs-lisp/bytecomp.el (byte-compile--suppressed-warnings):
New internal variable.
(byte-compile-warning-enabled-p): Heed
byte-compile--suppressed-warnings, bound via with-suppressed-warnings.
(byte-compile-initial-macro-environment): Provide a macro
expansion of with-suppressed-warnings.
(byte-compile-file-form-with-suppressed-warnings): New byte hunk
handler for the suppressed symbol machinery.
(byte-compile-suppressed-warnings): Ditto for the byteop.
(byte-compile-file-form-defmumble): Ditto.
(byte-compile-form, byte-compile-normal-call)
(byte-compile-normal-call, byte-compile-variable-ref)
(byte-compile-set-default, byte-compile-variable-set)
(byte-compile-function-form, byte-compile-set-default)
(byte-compile-warn-obsolete, byte-compile--declare-var): Pass the
symbol being warned in to byte-compile-warning-enabled-p.
* test/lisp/emacs-lisp/bytecomp-tests.el (test-suppression): New
function.
(bytecomp-test--with-suppressed-warnings): Tests.
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/lispref/compile.texi | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/doc/lispref/compile.texi b/doc/lispref/compile.texi index d9db55e22cd..4ff0e1c91e4 100644 --- a/doc/lispref/compile.texi +++ b/doc/lispref/compile.texi | |||
| @@ -505,8 +505,25 @@ current lexical scope, or file if at top-level.) @xref{Defining | |||
| 505 | Variables}. | 505 | Variables}. |
| 506 | @end itemize | 506 | @end itemize |
| 507 | 507 | ||
| 508 | You can also suppress any and all compiler warnings within a certain | 508 | You can also suppress compiler warnings within a certain expression |
| 509 | expression using the construct @code{with-no-warnings}: | 509 | using the @code{with-suppressed-warnings} macro: |
| 510 | |||
| 511 | @defspec with-suppressed-warnings warnings body@dots{} | ||
| 512 | In execution, this is equivalent to @code{(progn @var{body}...)}, but | ||
| 513 | the compiler does not issue warnings for the specified conditions in | ||
| 514 | @var{body}. @var{warnings} is an associative list of warning symbols | ||
| 515 | and function/variable symbols they apply to. For instance, if you | ||
| 516 | wish to call an obsolete function called @code{foo}, but want to | ||
| 517 | suppress the compilation warning, say: | ||
| 518 | |||
| 519 | @lisp | ||
| 520 | (with-suppressed-warnings ((obsolete foo)) | ||
| 521 | (foo ...)) | ||
| 522 | @end lisp | ||
| 523 | @end defspec | ||
| 524 | |||
| 525 | For more coarse-grained suppression of compiler warnings, you can use | ||
| 526 | the @code{with-no-warnings} construct: | ||
| 510 | 527 | ||
| 511 | @c This is implemented with a defun, but conceptually it is | 528 | @c This is implemented with a defun, but conceptually it is |
| 512 | @c a special form. | 529 | @c a special form. |
| @@ -516,8 +533,9 @@ In execution, this is equivalent to @code{(progn @var{body}...)}, | |||
| 516 | but the compiler does not issue warnings for anything that occurs | 533 | but the compiler does not issue warnings for anything that occurs |
| 517 | inside @var{body}. | 534 | inside @var{body}. |
| 518 | 535 | ||
| 519 | We recommend that you use this construct around the smallest | 536 | We recommend that you use @code{with-suppressed-warnings} instead, but |
| 520 | possible piece of code, to avoid missing possible warnings other than | 537 | if you do use this construct, that you use it around the smallest |
| 538 | possible piece of code to avoid missing possible warnings other than | ||
| 521 | one you intend to suppress. | 539 | one you intend to suppress. |
| 522 | @end defspec | 540 | @end defspec |
| 523 | 541 | ||