bastibe / annotate.el

Annotate.el
Other
384 stars 20 forks source link

Failed to kill indirect buffers #134

Closed JuanManuelM closed 1 year ago

JuanManuelM commented 2 years ago

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 2 years ago

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

Hi!

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

Thanks to you for your kind words. I am always happy to know that this package is useful to someone, to be useful is one of the reason why i am working on it (another reason is that is fun! :-)).

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:

Today i learnt about indirect buffer, thanks! :)

(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))
                 "")))

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?

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? And if yes, may I ask how annotating indirect buffer fits in your workflow?

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.

Of course feel free to ignore my questions if you do not want or can not answer!

Thanks a lot, your report was very interesting! C.

JuanManuelM commented 2 years ago

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 2 years ago

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.

JuanManuelM commented 2 years ago

Works like a charm! :-)

Thank you very much for the excellent work.

cage2 commented 2 years ago

On Wed, Aug 10, 2022 at 08:20:49AM -0700, you wrote:

Hi!

Works like a charm! :-)

Good! Thanks for review!

Thank you very much for the excellent work.

Thanks to for the interesting discussion!

Bye! C.

cage2 commented 1 year ago

On Wed, Aug 10, 2022 at 07:15:11AM -0700, you wrote:

Hi!

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.

This is a good idea! I think i am going to use `org-tree-to-indirect-buffer' starting from today too! :)

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.

That's perfectly fine, i am going to prepare a PR; this should not take a lot of time as the changes are minimal.

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.

No problem, i was just surprised about this behaviour and my surprise was derived from my ignorance about indirect buffers, and i am sure i have a lot to learn about Emacs in general. :D

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.

This makes totally sense to me.

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 :-)

I think the same! :) But i need start thinking how this could be accomplished given the ephemeral nature of the indirect buffer. Very likely this changes is going to require changes in the format of the annotations database. Anyway i think this feature could be useful to add!

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.

Thanks for your appreciation, we (all the contributors and the maintainer) poured a lot of efforts in this package and is very satisfying to know that annotate is helping people!

Bye! C.