Skip to content

Conversation

@milanglacier
Copy link
Contributor

I believe it is generally considered good practice to use named functions rather than anonymous lambdas for hook-like things, like when adding functions to hook variables or defining advice. Named functions make debugging simpler, as one can readily identify their origin and location.

With this patch applied, for example, inspecting a function such as example-func using C-h f immediately shows that it is advised by a timeout-* function. The user can then further examine the advice function itself, improving traceability and clarity.

Screenshot 2025-09-08 at 13 59 22 Screenshot 2025-09-08 at 14 00 40

* lisp/timeout.el (timeout-debounce, timeout-throttle): Assign
explicit names to advice functions instead of using anonymous lambdas.
This makes it easier to debug the advice stack.  The advice functions
are given names like 'timeout-debounce-on-...' and
'timeout-throttle-on-...'.
@karthink
Copy link
Owner

karthink commented Sep 9, 2025

I believe it is generally considered good practice to use named functions rather than anonymous lambdas for hook-like things, like when adding functions to hook variables or defining advice.

The advice is already named via the PROPS argument of advice-add, which serves as the handle.

The function itself is intentionally anonymous. I think the recommendation to use named functions applies only to hooks, not advice, because there is no other way to refer to them in remove-hook. Advice functions can be removed using the advice name in PROPS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants