emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master a0524584e9 1/2: Allow suppressing messages about the wrong number


From: Lars Ingebrigtsen
Subject: master a0524584e9 1/2: Allow suppressing messages about the wrong number of arguments
Date: Sun, 22 May 2022 14:07:28 -0400 (EDT)

branch: master
commit a0524584e93a66278dcf7bb998398f7484f9e8b5
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Allow suppressing messages about the wrong number of arguments
    
    * lisp/emacs-lisp/byte-run.el (with-suppressed-warnings): Add
    `wrong-args'.
    * lisp/emacs-lisp/bytecomp.el (byte-compile-emit-callargs-warn)
    (byte-compile-subr-wrong-args): Allow suppressing wrong number of
    arguments.
---
 lisp/emacs-lisp/byte-run.el |  2 +-
 lisp/emacs-lisp/bytecomp.el | 32 +++++++++++++++++---------------
 2 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/lisp/emacs-lisp/byte-run.el b/lisp/emacs-lisp/byte-run.el
index 0113051c8e..2d11f350f0 100644
--- a/lisp/emacs-lisp/byte-run.el
+++ b/lisp/emacs-lisp/byte-run.el
@@ -637,7 +637,7 @@ The warnings that can be suppressed are a subset of the 
warnings
 in `byte-compile-warning-types'; see the variable
 `byte-compile-warnings' for a fuller explanation of the warning
 types.  The types that can be suppressed with this macro are
-`free-vars', `callargs', `redefine', `obsolete',
+`free-vars', `callargs', `redefine', `obsolete', `wrong-args',
 `interactive-only', `lexical', `mapcar', `constants' and
 `suspicious'.
 
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index e72b96af4a..920cdbe5a6 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -1494,15 +1494,16 @@ when printing the error message."
                 byte-compile-unresolved-functions)))))
 
 (defun byte-compile-emit-callargs-warn (name actual-args min-args max-args)
-  (byte-compile-warn-x
-   name
-   "%s called with %d argument%s, but %s %s"
-   name actual-args
-   (if (= 1 actual-args) "" "s")
-   (if (< actual-args min-args)
-       "requires"
-     "accepts only")
-   (byte-compile-arglist-signature-string (cons min-args max-args))))
+  (when (byte-compile-warning-enabled-p 'wrong-args name)
+    (byte-compile-warn-x
+     name
+     "`%s' called with %d argument%s, but %s %s"
+     name actual-args
+     (if (= 1 actual-args) "" "s")
+     (if (< actual-args min-args)
+         "requires"
+       "accepts only")
+     (byte-compile-arglist-signature-string (cons min-args max-args)))))
 
 (defun byte-compile--check-arity-bytecode (form bytecode)
   "Check that the call in FORM matches that allowed by BYTECODE."
@@ -3838,12 +3839,13 @@ If it is nil, then the handler is 
\"byte-compile-SYMBOL.\""
 
 
 (defun byte-compile-subr-wrong-args (form n)
-  (byte-compile-warn-x (car form)
-                        "`%s' called with %d arg%s, but requires %s"
-                        (car form) (length (cdr form))
-                        (if (= 1 (length (cdr form))) "" "s") n)
-  ;; Get run-time wrong-number-of-args error.
-  (byte-compile-normal-call form))
+  (when (byte-compile-warning-enabled-p 'wrong-args (car form))
+    (byte-compile-warn-x (car form)
+                         "`%s' called with %d arg%s, but requires %s"
+                         (car form) (length (cdr form))
+                         (if (= 1 (length (cdr form))) "" "s") n)
+    ;; Get run-time wrong-number-of-args error.
+    (byte-compile-normal-call form)))
 
 (defun byte-compile-no-args (form)
   (if (not (= (length form) 1))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]