anki-editor/anki-editor

Add transient interface

orgtre opened this issue · 8 comments

I'm working on a transient user interface to anki-editor and am opening this issue to collect feedback and suggestions. It would resolve issues like louietan/anki-editor#79 and beyond. An alternative would be a hydra, but I am already familiar with transient and think it is more flexible.

Okay, the first version of the transient is out. Feel free to give it a try and come with suggestions for how the anki-editor workflow can be made more smooth. @cmirdesouza @doolio

The transient is in a separate module. In my setup with straight.el I load it like this:

(use-package anki-editor-ui
  :defer t
  :after anki-editor
  :straight (:host github :repo "louietan/anki-editor" :fork "orgtre")
  :bind (:map anki-editor-mode-map
	 ("C-c e" . anki-editor-ui)))

I really liked the idea, i was thinking on how the org-agenda works and i didn't think about magit, but it seems like a wonderful feature for better user experience.
Another possible feature could be a special buffer like magit (it opens a buffer with all commits, stage, etc) with a sparse tree of all anki notes on that buffer.
Im going to give it a test.
After doing some tests on Doom Emacs it seems to not been a popup or a window. The problem seems to be that any keyboard input goes to the anki-editor-ui when I focus on them, this makes it impossible to write on the mini buffer after selecting an option.
Per example when creating a new note and asked about Note Heading or when asked about the type of note.
Anyone has the same problem?

@cmirdesouza Thanks for testing! Indeed I see the same issue appearing randomly also without Doom, but very rarely and I fail to find a way to reliably reproduce it. The problem seems to be that when a command called by the transient user interface immediately calls a completing-read prompt (or some other function requesting user input?), sometimes the transient keybindings are still in effect (which they shouldn't be), and when you then type one of them, the transient interface pops up again. When this happens the transient interface eats all the keypresses and it is impossible to input anything into the mini buffer prompt or to get it to disappear. Does this description fit with what you're experiencing?

We could work around this by passing all the user input using the transient user interface (or maybe by introducing a delay?), but this would be awkward in this setting and we shouldn't have to. As the anki-editor-ui code is very basic and I don't see anything that might be wrong, I'd guess this is an issue with transient.el or something deeper down in Emacs. If we'd find a reliable way to reproduce this problem we could open an issue further down somewhere.

This is a great addition, thank you. Curious why you kept in separate from the main file?

One thing I've noticed when using this UI is that the :ANKI_FAILURE_REASON: property remains when successfully pushing a previously failed card. It is removed when pushing such a note not via this UI.

(I'm starting to use this more now so I'll report any other issues I encounter as and when they arise.)

Thanks for testing this and reporting issues!

I'll try to resolve the issue with :ANKI_FAILURE_REASON:. If there are issues with transient which we can't resolve we might considering testing a hydra instead.

I kept it separate to not force transient as a dependency for anki-editor. The transient package is quite big (4000+ lines) so one wouldn't want to load it unless necessary. Also, this seems to be almost standard practice for Emacs packages.

I kept it separate to not force transient as a dependency for anki-editor. The transient package is quite big (4000+ lines) so one wouldn't want to load it unless necessary. Also, this seems to be almost standard practice for Emacs packages.

That's fair. Though isn't transient a part of Emacs now or maybe just GNU ELPA.

The UI allows one to delete a note but does so only in Anki. Perhaps, an option to delete in Anki and the Org file should be included?

Yes, this option is already there actually: With a universal prefix argument (C-u) anki-editor-delete-note-at-point will also delete the note from the Org file. This is in the commands docstring but not indicated in the transient interface. I think having at least some indicator in the transient of which commands take interactive arguments, for example like I did here, would be nice.