Skip to content

Modify database save routine to save while in a file-visiting buffer #307

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

swflint
Copy link
Contributor

@swflint swflint commented Aug 24, 2024

This should work for #306, hopefully without causing too many issues.
Let me know if I should also hack it to work for ebib-write-database.

@joostkremers
Copy link
Owner

Well, this is a tough one... I use temp buffers to read and write a .bib file mainly to avoid the risk of the database and the buffer getting out of sync (which would happen as soon as the user edits one or the other). The disadvantage of that is that Ebib has to keep track of mod times and backups itself.

One idea I had, thinking about this, was to visit the .bib file in a buffer in read-only-mode. That way, the user would get a warning when they try to edit the buffer.

Visiting the file could be done when Ebib opens it. That would have the small disadvantage that the data lives is memory twice: once in a hash table and once in a buffer. But given that .bib files are just text files, that may not be such a big issue.

The advantage would be that everything a user expects Emacs to do when saving a file (checking mod time, creating backups) is handled automatically. Though I can't foresee if the user experience will be smooth in every situation, so I'd have to check that first. I'd also have to check what happens when the user reloads a database from its file.

Let me know if I should also hack it to work for ebib-write-database.

Yes, it should also work for ebib-write-database. In that case, the buffer should also start visiting the new file, of course.

@swflint
Copy link
Contributor Author

swflint commented Sep 2, 2024

Well, this is a tough one... I use temp buffers to read and write a .bib file mainly to avoid the risk of the database and the buffer getting out of sync (which would happen as soon as the user edits one or the other). The disadvantage of that is that Ebib has to keep track of mod times and backups itself.

One idea I had, thinking about this, was to visit the .bib file in a buffer in read-only-mode. That way, the user would get a warning when they try to edit the buffer.

The reasoning for not keeping the buffer around makes sense. However, I think the solution of opening it as read-only would be a decent solution.

Visiting the file could be done when Ebib opens it. That would have the small disadvantage that the data lives is memory twice: once in a hash table and once in a buffer. But given that .bib files are just text files, that may not be such a big issue.

The advantage would be that everything a user expects Emacs to do when saving a file (checking mod time, creating backups) is handled automatically. Though I can't foresee if the user experience will be smooth in every situation, so I'd have to check that first. I'd also have to check what happens when the user reloads a database from its file.

I think that would be the way to go. I don't think having a bib file open would be all that likely to be an issue. It could also be an option, ebib-use-read-only-buffer or something like that.

Let me know if I should also hack it to work for ebib-write-database.

Yes, it should also work for ebib-write-database. In that case, the buffer should also start visiting the new file, of course.

I figured as much. That said, I may close this to try and improve the logic.

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