-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: advising + defadvice implementation #72
Labels
Comments
jaidetree
changed the title
Idea: defadvice implementation
Feature request: advising + defadvice implementation
Sep 29, 2020
I really like the idea. I can't think of a good use case for it at this point, but having it at our disposal perhaps would generate many good use-cases. |
This was referenced Mar 27, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
One aspect of Spacehammer that could stand to be improved is the ability to customize the implementation behavior of current or new features. For instance in an issue like #66 is going to require enhancing some core modal functions to change how bindings are created.
One option would be to design and architect some kind of hook or event system but then extra work will need to be done to update the system to use it, and it's a whole new API.
Another option would be to support more functions in the config.fnl. However, like the previous system we'll need to write checks for it in the relevant parts, additionally it muddles the purpose of config.fnl as it's now responsible for defining your configuration of spacehammer and the implementation.
My proposal would be to create a library similar to emacs-lisp advising functions, especially the doom emacs defadvice! macro.
An example from my dotconfig at https://github.com/eccentric-j/dotfiles/blob/c457fcba768f91a9fe2b7464221c97ba4dc3ad46/client/doom.d/config.el#L200-L206:
Here I'm defining a function that fires after the js--multi-line-declaration-indentation function. Depending on the keyword used to represent how we're advising the function, I'll receive the original args sent to the function or the original function as the first argument.
Benefits
(fn ...)
with the name of the macro that registers the function with the advising state so(fn)
becomes either(advisable-fn ...)
or(defn ...)
to add this to existing functionality.Tradeoffs
time
macro to make sure it's not too slow. Based on previous performance tests, I doubt it will have a noticable impact beyond a fraction of a ms.API
add-advice!
function to advise a functionremove-advice!
function to remove an advising functiondefadvice!
macro to define a function and calladd-advice!
.advisable-fn
ordefn
macro to register functions as advisable and create a handler to dispatch to advising functions.The text was updated successfully, but these errors were encountered: