Jumping to non-existent fields
Hugo-Heagren opened this issue · 2 comments
I noticed that the ebib-jump-to-field
code just presents a list of all fields for the current entry type, including fields not used in the current entry. It uses re-search-forward
to find the field, so if the field doesn't exist, point doesn't move but there's no feedback about this. This can be a bit confusing, I think it would be better to check if the field exists and have some appropriate feedback if not...
...like adding the field. For me, it makes most sense to just add (or offer to add, with a yes/no prompt?) any field the user tries to jump which doesn't yet exist. This behaviour could be configured in a custom var, so users who don't like it can switch it off.
[Rambling side note: I switched from ivy to a vertico/embark/marginalia stack recently, so I might looking into adding embark support to ebib soon. If so, I could add things like switching between similar commands like add/jump-to-field
In fact, having come to the end of writing this issue of the back of opening #228, I wonder if it might not be simpler to just combine ebib-add-field
with ebib-jump-to-field
? If the selection exists in the current entry, jump to it. If not, add it and jump to it (and edit it, to provide an initial value). Maybe this could allow for users who prefer the current behaviour by providing leaving the current commands as they are and adding a new, combined ebib-add-or-jump
?]
This could make sense, indeed. In a way, the current ebib-add-field
already does this, but only for fields that do not have a value yet.
The main question would be the UI: would this be an enhancement of ebib-jump-to-field
, of ebib-add-field
or a new command?
The main question would be the UI: would this be an enhancement of ebib-jump-to-field, of ebib-add-field or a new command?
Well, I suppose this issue ended up having two parts, the first of which is a fix for behaviour (which I think is problematic) in ebib-jump-to-field
, so part of if would be to fix that.
The second part I think should also go in ebib-jump-to-field
. I was thinking of something like the mechanics of switch-buffer
(and similar commands, because this pattern is used a lot in emacs and will be familiar for users): start typing, if the thing you want exists, go to it, if not create it and go to it (and in ebib's case, provide a value for it).