Closed swflint closed 6 months ago
I'd probably need a bit more context to say anything specific, but I suspect the issue is caused by the fact that you don't set the database's current entry before calling ebib--update-index-buffer
.
In principle, the "current entry" is simply defined by the position of point in the index buffer. When necessary, however, the current entry is saved to the database, so that it can be restored later. ebib--update-index-buffer
uses this stored value to set the current entry after it has filled the index buffer. So probably what you need to do is to set the database's current entry before calling ebib--update-index-buffer
.
Note, BTW, that functions with two dashes are internal functions and aren't meant to be used in hooks directly. Obviously, you're free to do so if you like :slightly_smiling_face: , but keep in mind that you may run into unexpected issues when doing so.
In your case, it may be sufficient to define a function that first sets the database's current entry (see ebib-db-set-current-entry-key
) and then calls ebib--update-index-buffer
. Though like I said, without more context I can't really say for sure.
Is there a good way to get this sort of behavior (I add/remove to reading list, add a note, etc., then the index is refreshed to show that status change)?
Is there a good way to get this sort of behavior (I add/remove to reading list, add a note, etc., then the index is refreshed to show that status change)?
Ideally, Ebib should do that itself, of course, but in principle, the hook method isn't wrong. You just need to set the database's current entry first. Using the following function in the hook should work:
(defun my-ebib-reading-list-after-remove-item-function ()
"Update the index buffer after removing an item from the reading list."
(ebib-db-set-current-entry-key (ebib--get-key-at-point) ebib--cur-db)
(ebib--update-entry-buffer))
This is untested, though, so let me know if it doesn't work.
Changing ebib--update-entry-buffer
to ebib--update-index-buffer
worked. Thanks.
When running
ebib--update-index-buffer
(for instance inebib-reading-list-remove-hook
), the "current entry" in the index is not set to the actual current entry, but is set to the first entry in the index buffer.