Closed akater closed 6 years ago
Note: this would also cause ebdb-insert-field to abort on entering empty label
Hmm, do you think it would be better to simply enter an empty label, or to abort field creation altogether?
I certainly wouldn't use "" labels (empty strings) anywhere. Actually, I've been avoiding empty label just so that I wouldn't have to deal with possible hassle of unmanageable label (at worst) or possible awkward rendering of completion buffer with such label in it (at best), even though I don't care much for labels in my particular db at all!
Support for unlabeled entities would be nice though, with persistent db entry looking like this
(ebdb-field-phone nil ;; i'm not actually familiar with ebdb objects yet
:object-name nil ;; so this could be totally unreasonable
:country-code 0
:area-code 0
:number "000")
and empty input creating such unlabeled field. In that case though, we have to ask for the phone number (or address, or whatever is label-able) first and for label second. This looks most reasonable to me but I'm not ready to provide the necessary patch myself.
It wouldn't have to ask for the label second -- we could still prompt for the label first, but simply interpret "" as nil. I need to look at the code more closely, but can't see why that wouldn't work.
Interpreting an empty string as "abort" is fine when you're inputting core field values, but labels aren't core field values.
It wouldn't have to ask for the label second -- we could still prompt for the label first, but simply interpret "" as nil.
Suppose there's a facility for adding multiple phone numbers or addresses. (As far as I can remember, bbdb had it.) When label is requested first, user has to needlessly specify a label before he or she is able to say “no more phone numbers please”.
Label is a datum secondary to the number itself. Sooner or later this reversed entry order is going to be exposed as a source of some issue.
Interpreting an empty string as "abort" is fine when you're inputting core field values, but labels aren't core field values.
Agree.
Suppose there's a facility for adding multiple phone numbers or addresses. (As far as I can remember, bbdb had it.) When label is requested first, user has to needlessly specify a label before he or she is able to say “no more phone numbers please”.
That's a good point, and that's exactly what happens when creating a new record: it loops on numbers and addresses.
Okay, I'll swap the order so the label comes after other field data; that won't be hard to do.
Also, nil values for field-instance labels are fine, all code will fall back on the :human-readable option of the class itself.
EBDB manual, node 4.1 says
However, entering blank string and pressing C-g when adding labels causes different feedback from EBDB which looks like an inconsistency.
Steps to reproduce:
Try creating new record interactively, e.g.
M-x ebdb-create-record
When prompted for label (say, phone label), enter empty string.
Emacs then reacts with “ is not a known label, define it?” — apparently, it attempts to define an empty label which doesn't make much sense and feels contradictory to what manual says
C-g would skip adding label (and the field). Entering blank string on Mail address would have had the same effect as C-g on entering Mail address.
Looks like empty string check in
cl-defmethod ebdb-read :around ((class (subclass ebdb-field-labeled)) &optional slots obj)
would cause the behaviour to be the same for blank string and C-g:Note: this would also cause
ebdb-insert-field
to abort on entering empty label.