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

Possible to call after-save-hook after writing database #306

Open
swflint opened this issue Aug 23, 2024 · 2 comments
Open

Possible to call after-save-hook after writing database #306

swflint opened this issue Aug 23, 2024 · 2 comments

Comments

@swflint
Copy link
Contributor

swflint commented Aug 23, 2024

Would it be possible to call after-save-hook in the context of the buffer visiting a given database file? Not doing so prevents git-auto-commit-mode from operating like I'd expect.

@joostkremers
Copy link
Owner

No, unfortunately not. The reason is that there is no buffer visiting the database file. What Ebib does is read the contents of a .bib file and store it in a hash table. Then when you save the database, it is written to a temp buffer, the content of which is then written (using write-region) to the original file.

I don't immediately see an alternative solution... Perhaps visiting the .bib file and enabling auto-revert-mode in that buffer could work. Ebib shouldn't touch that buffer (it uses temp buffers to read and write the file, it never visits it), and auto-revert-mode should ensure that when Ebib saves the database, the buffer is reverted. I don't know if that triggers after-save-hook, but if not you could probably use after-revert-hook to call gac-after-save-func.

A little cumbersome, of course... Perhaps it makes sense to add some hooks to Ebib to make this easier.

@swflint
Copy link
Contributor Author

swflint commented Aug 24, 2024

That's about what I had expected. I may try to make a PR if I can get something working.

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

No branches or pull requests

2 participants