[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Advice functions: required args that byte-compiler warns are unused
From: |
Stefan Monnier |
Subject: |
Re: Advice functions: required args that byte-compiler warns are unused |
Date: |
Wed, 03 Nov 2021 15:04:34 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
> (defun my-foo-after-advice (&rest args)
> "..."
> (ignore args) ; Quiet the byte-compiler.
> (do-stuff-that-doesnt-refer-to-ARGS))
Use
(defun my-foo-after-advice (&rest _args)
or just
(defun my-foo-after-advice (&rest _)
> Suppose function `foo' requires 3 arguments:
>
> (defun foo (a b c) ...)
Here you can use
(defun foo (_a _b _c) ...)
tho you can also use
(defun foo (&rest _) ...)
since you advice doesn't have to only accept exactly the same args as
the function it advises: it is free to accept *more* use-cases (and it's
often a good idea to do so, in case the advised function grows some
&optional arguments in the future).
Stefan