ahyatt / ekg

The emacs knowledge graph, app for notes and structured data.
GNU General Public License v3.0
230 stars 19 forks source link

Add ekg-capture/edit-abort function #122

Closed qingshuizheng closed 10 months ago

qingshuizheng commented 10 months ago

Why this commit:

I personally want to have an abort function, so that I could decide where the note should go. Even the note has been auto-saved as draft by ekg-auto-save-mode (my personal branch), with ekg-capture-abort, the note still could go to trash. Or when I edit a note but later I decide not to save it at all, ekg-edit-abort could abort all the edits.

Changes in this commit:

  1. In ekg-edit-mode: abort edit -> restore note to its original state. (Except for modification time: ekg-save-note recalculates it finally. Q: Any function to compare the new note vs the note in db: if value are the same, don't update the modification time?)

  2. In ekg-capture-mode: abort capture -> trashing the note.

  3. Clean up some whitespaces and bad indentations around the edits.

This commit also address https://github.com/ahyatt/ekg/pull/19 :

Do we want C-c C-k to abort the capture process?

ahyatt commented 10 months ago

Interesting, thank you for contributing! Having a way to clean up after saving a draft is nice. One thing I'm wondering is whether aborted notes should go to the trash or simply be deleted. To me, a trashed note is a note that was once good, but is no longer needed. An aborted note doesn't seem to rise to that level. What do you think?

qingshuizheng commented 10 months ago

An aborted note doesn't seem to rise to that level.

I think you are right, I would change the code to adapt to this idea.

Also, I add a new local variable ekg-kill-buffer-query-function, which adapted from builtin kill-buffer-query-function, for user to decide whether to save the note on buffer kill.

edit: reword.

qingshuizheng commented 10 months ago

I'll need to make some adjustment to kill-buffer-query-function to adapt it to ekg-capture-abort, convert this pr to drafts for the moment.

Update: adjustments done.

Update 2: let me know if you see this pr is okay for ekg, and you'd like me to squash them into one.

Update 3: forced-push a fix for wrongly usage of "delq"; kill-emacs-query-functions -> kill-buffer-query-functions

qingshuizheng commented 10 months ago

Pushed two new commits:

  1. fix a wrongly placed "t" in ekg-buffer-kill-query-function, which leads to buffer not killed after save.
  2. improve docstring for user option ekg-save-action-on-buffer-kill.
ahyatt commented 10 months ago

Thank you for all the changes so far. We're close! Maybe all the way there, but I want to continue to think about making things even clearer. I'm not sure, though, so please be patient as I continue to think through this.

qingshuizheng commented 10 months ago

Ahh no worry at all.

I planned to place this on discussion section. But since I have these changes in my personal branch, I think I could make a PR here, so that you could play with it, then decide whether you like it or not.

ahyatt commented 10 months ago

Thanks for bearing with me - this looks good. I want to make a few changes and test this out, but this will be nice to have for the next release. Thanks again for your effort in putting this together.

qingshuizheng commented 10 months ago

Thanks for the review and merge. Feel free to make any changes to fit the repo.