unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Advice function needs argument not used in function, how to avoid compiler warning?
@ 2022-10-05 21:20 Jean Louis
  2022-10-05 22:30 ` Michael Heerdegen
  2022-10-05 23:46 ` Emanuel Berg
  0 siblings, 2 replies; 3+ messages in thread
From: Jean Louis @ 2022-10-05 21:20 UTC (permalink / raw)
  To: Help GNU Emacs

I realize that advice function need argument such as &rest args, but I
am not using it in the function. And I do not understand what is that
argument receiving. Anybody may explain it?

I have to do (ignore args) to avoid compiler warning. What does args receive?

(defun hyperscope-after-sort (&rest args)
  (ignore args)
  (hyperscope-highlight))

(advice-add 'tabulated-list-col-sort :after 'hyperscope-after-sort)
(advice-add 'tabulated-list-sort :after 'hyperscope-after-sort)


--
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Advice function needs argument not used in function, how to avoid compiler warning?
  2022-10-05 21:20 Advice function needs argument not used in function, how to avoid compiler warning? Jean Louis
@ 2022-10-05 22:30 ` Michael Heerdegen
  2022-10-05 23:46 ` Emanuel Berg
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Heerdegen @ 2022-10-05 22:30 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis <bugs@gnu.support> writes:

> I realize that advice function need argument such as &rest args, but I
> am not using it in the function. And I do not understand what is that
> argument receiving. Anybody may explain it?
>
> I have to do (ignore args) to avoid compiler warning. What does args
> receive?

The arguments of the current call of the advised function, in the case
of an :after advice.  In the general case that depends on the kind of
advice (see docstring of `advice-add', the HOW arg).

> (defun hyperscope-after-sort (&rest args)
>   (ignore args)
>   (hyperscope-highlight))

You can just use `_args` to label the argument as unused by the function
body - it's the same as for all functions.

Michael.




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Advice function needs argument not used in function, how to avoid compiler warning?
  2022-10-05 21:20 Advice function needs argument not used in function, how to avoid compiler warning? Jean Louis
  2022-10-05 22:30 ` Michael Heerdegen
@ 2022-10-05 23:46 ` Emanuel Berg
  1 sibling, 0 replies; 3+ messages in thread
From: Emanuel Berg @ 2022-10-05 23:46 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis wrote:

> I have to do (ignore args) to avoid compiler warning.
> What does args receive?
>
> (defun hyperscope-after-sort (&rest args)
>   (ignore args)
>   (hyperscope-highlight))
>
> (advice-add 'tabulated-list-col-sort :after 'hyperscope-after-sort)
> (advice-add 'tabulated-list-sort :after
> 'hyperscope-after-sort)

(defun hyperscope-after-sort (&rest _) ... )

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-10-05 23:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-05 21:20 Advice function needs argument not used in function, how to avoid compiler warning? Jean Louis
2022-10-05 22:30 ` Michael Heerdegen
2022-10-05 23:46 ` Emanuel Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).