bastibe/annotate.el

Failed to kill indirect buffers

Closed this issue · 6 comments

First of all, thank you for this excellent and useful package.

I have noticed in the latest version that if for some reason I need to open an indirect buffer (and I have annotate-mode active), for example with org-tree-to-indirect-buffer, then I get an error when I want to kill that buffer. I think the culprit is the line:

(add-hook 'kill-buffer-hook #'annotate-save-annotations t t)

I have found a temporary workaround by overriding the annotate-actual-file-name function, so that annotate can get the actual file name when there is an indirect buffer:

(defun annotate-actual-file-name ()
  "Get the actual file name of the current buffer."
  (substring-no-properties (or (annotate-info-actual-filename)
                 (buffer-file-name)
                 (buffer-file-name (buffer-base-buffer))
                 "")))
cage2 commented

On Wed, Aug 10, 2022 at 04:48:17AM -0700, you wrote:

Today i learnt about indirect buffer, thanks! :)

I mainly use them in Org Mode :-) They are very handy to isolate a
certain subtree and work on it in another dedicated buffer.

I think your is more than a workaround but a proper solution instead
:), do you want to file a PR or can i add it in a PR made by myself?
In the latter case can i mention you in the commit message as
JuanManuelM?

I'm afraid I don't have much experience doing PR (I don't use GitHub but
GitLab :-)). But if the addition that I proposed seems appropriate to
you, of course I have no problem if you add it yourself.

Moreover I would like to make a question to you: i noted that you can
annotate an indirect buffer, but the annotations will not be saved in
the annotations database and they will vanish if the indirect buffer
is killed. Is this the behaviour you expected?

That's correct, and I forgot to mention it in my previous post, sorry.
Certainly annotations are not permanent in indirect buffers. I always
add the annotations into the main buffer. The workaround above was just
to avoid the error when I want to kill my indirect buffers.

And if yes, may I ask how annotating indirect buffer fits in your
workflow?

I have to say that in my current workflow I almost never need to
annotate an indirect buffer, so I think I can live with that. But I
think the possibility of annotating indirect buffers could be an
interesting new feature :-)

Mine is just a genuine question, i am always curious to know how other
people use this package, especially if they use it in such unexpected
(for me!) ways.

I certainly find your package extremely useful in many tasks, and have
already recommended it to quite a few colleagues. As I dedicate myself
to literary translation, I find it very practical, among other things,
to introduce tiny notes in some passages or words of the text that I
translate.

cage2 commented

Hi @JuanManuelM !

My last comment (sent via email) seems had disappeared. :(

Anyway, i filed a PR (#135) that should fix this issue.

May I ask to take a look at it?

Note also that I have mentioned you here:

https://github.com/bastibe/annotate.el/pull/135/files#diff-396998658cacfe92eacb308e76ce79112a7cddc31df2a5c6c41dc288b985c774R4

If you feel not comfortable with this mention just write me and i will remove it form the PR immediately.

Thanks again for your report!
C.

Works like a charm! :-)

Thank you very much for the excellent work.

cage2 commented
cage2 commented