Skip to content
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

Add section on using hooks #26

Open
justinbarclay opened this issue Apr 2, 2024 · 1 comment
Open

Add section on using hooks #26

justinbarclay opened this issue Apr 2, 2024 · 1 comment

Comments

@justinbarclay
Copy link

justinbarclay commented Apr 2, 2024

As a package dev, I'd like to have a reference section of hooks that are commonly used in packages and how to use them.

In particular, for my use case, I've been looking for a good reference implementation of using the after-change-hooks for building up a set of changes a user has made to the buffer.

IE:
If a user replaces a region of text

abcd => efgh

would look something like:

(:before-change "abcd"
 :after-change "efgh")

or if a user deletes a char:

hello world => helloworld

would look like

(:before-change " "
 :after-change "")

I've tried implementing this myself using the after-change-hook, but I keep running edges in my knowledge causing weird bugs.

@alphapapa
Copy link
Owner

Hi Justin,

That would certainly be helpful. Generally I'd suggest that, if someone were to take the time to write something like that up, it ought to be added to the Elisp manual (or, at least, offered to it first). I'm guessing that the maintainers would welcome improvements to that part of the manual.

Beyond that, I haven't worked with the after/before-change hooks myself, so my role would be that of welcoming contributions in that regard.

FYI, there's a discussion on a bug about an easier API for this sort of thing; you might like to chime in there: https://yhetil.org/emacs-bugs/jwvh6gnvncn.fsf-monnier+emacs@gnu.org/T/#me028b279c2813b1bd6c1cf7ebca00efb60cf60b3

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

No branches or pull requests

2 participants