diff options
| author | Daniel Mendler <mail@daniel-mendler.de> | 2023-01-14 20:55:19 +0100 |
|---|---|---|
| committer | Daniel Mendler <mail@daniel-mendler.de> | 2023-02-07 16:51:17 +0100 |
| commit | 041624f7150fca931888c96be56ca39f36718a62 (patch) | |
| tree | c2bed1253c2d28bcffd551d780febbc7185135ab | |
| parent | b0dc9210a6ba6fdab58e5b0c1dc1960cbdacc132 (diff) | |
compat-27: Add with-suppressed-warnings
| -rw-r--r-- | NEWS.org | 1 | ||||
| -rw-r--r-- | compat-27.el | 7 | ||||
| -rw-r--r-- | compat-tests.el | 8 | ||||
| -rw-r--r-- | compat.texi | 17 |
4 files changed, 31 insertions, 2 deletions
@@ -2,6 +2,7 @@ * Development +- compat-27: Add ~with-suppressed-warnings~. - compat-29: Add ~cl-with-gensyms~ and ~cl-once-only~. * Release of "Compat" Version 29.1.3.2 diff --git a/compat-27.el b/compat-27.el index 2be27a6..151948f 100644 --- a/compat-27.el +++ b/compat-27.el @@ -393,6 +393,13 @@ the minibuffer was activated, and execute the forms." (with-selected-window window ,@body))) +;;;; Defined in byte-run.el + +(defmacro with-suppressed-warnings (_warnings &rest body) ;; <compat-tests:with-suppressed-warnings> + "Like `progn', but prevents compiler WARNINGS in BODY. +NOTE: The compatibility version behaves like `with-no-warnings'." + `(with-no-warnings ,@body)) + ;;;; Defined in image.el (compat-defun image--set-property (image property value) ;; <compat-tests:image-property> diff --git a/compat-tests.el b/compat-tests.el index 2b5f1bb..8154234 100644 --- a/compat-tests.el +++ b/compat-tests.el @@ -2568,6 +2568,14 @@ (should-equal '(if a (progn b)) (macroexpand-1 '(when a b))) (should-equal '(if a (progn (unless b c))) (macroexpand-1 '(when a (unless b c))))) +;; NOTE: `with-suppressed-warnings' does not work inside of `ert-deftest'?! +(defun compat-tests--with-suppressed-warnings () + (with-suppressed-warnings ((interactive-only goto-line) + (obsolete encode-time-value)) + (encode-time-value 1 2 3 4 0) + (goto-line 10))) +(ert-deftest with-suppressed-warnings () #'compat-tests--with-suppressed-warnings) + (ert-deftest time-equal-p () (should (time-equal-p nil nil)) diff --git a/compat.texi b/compat.texi index 91275ff..ce3c3cd 100644 --- a/compat.texi +++ b/compat.texi @@ -1163,6 +1163,21 @@ returns @code{t} if so, @code{nil} otherwise. Small integers can be compared with @code{eq}. @end defun +@c copied from lispref/compile.texi +@defspec with-suppressed-warnings warnings body@dots{} +In execution, this is equivalent to @code{(progn @var{body}...)}, but +the compiler does not issue warnings for the specified conditions in +@var{body}. @var{warnings} is an association list of warning symbols +and function/variable symbols they apply to. For instance, if you +wish to call an obsolete function called @code{foo}, but want to +suppress the compilation warning, say: + +@lisp +(with-suppressed-warnings ((obsolete foo)) + (foo ...)) +@end lisp +@end defspec + @c copied from lispref/lists.texi @defun proper-list-p object This function returns the length of @var{object} if it is a proper list, @@ -1627,8 +1642,6 @@ The function @code{time-convert}. @item The macro @code{benchmark-progn}. @item -The macro @code{with-suppressed-warnings}. -@item Support for @code{condition-case} to handle t. @item The function @code{file-system-info}. |
