girzel / ebdb

An EIEIO port of BBDB, Emacs' contact-management package
67 stars 11 forks source link

Non-primary email used when completing name with edbd-complete-mail #87

Closed ecraven closed 4 years ago

ecraven commented 4 years ago

I've run into the following "bug": When completing a name with edbd-complete-mail (in ebdb-notmuch, but should not matter), the first mail is picked (it uses ebdb-record-mail [which does not put the primary first] and then uses the first, if matching by name). I'd much prefer and expect the primary email to be used in such cases. Could you possibly change this? Or would you accept a PR that changes ebdb-record-mail to always return the primary mail first?

girzel commented 4 years ago

Ugh, ebdb-complete-mail is the last big chunk of BBDB code that I've never gone in and cleaned up; that and ebdb-annotate-message. I've been bitten by this "bug" before, but haven't yet been annoyed enough to fix it.

There are too many functions that can be used to return an email address for a record. There's also ebdb-record-one-mail, which respects primary status, but I wouldn't want to use that in ebdb-complete-mail, because completion also adjusts which mail address it uses based on which exact string the user has entered. ebdb-record-one-mail should disappear and turn into extra arguments to ebdb-record-mail.

God ebdb-complete-mail does a lot of unnecessary work. Give me a bit here, and I will try to fix things properly, it might take a week or two to get to. In the meantime, if it really irritates you, you might try replacing ebdb-record-mail with ebdb-record-one-mail inside the completion function.

girzel commented 4 years ago

Well, don't do that because I'm likely to remove ebdb-record-one-mail altogether.

ecraven commented 4 years ago

God ebdb-complete-mail does a lot of unnecessary work. Give me a bit here, and I will try to fix things properly, it might take a week or two to get to. In the meantime, if it really irritates you, you might try replacing ebdb-record-mail with ebdb-record-one-mail inside the completion function.

What I tried was the following (which seems to work fine, but is probably not the optimal solution):

(let* ((ms (slot-value record 'mail)) (primary (object-assoc 'primary 'priority ms)) (mails (cons primary (remove primary ms)))) ...)

Thanks for looking into it!

girzel commented 4 years ago

Right, that's essentially what ebdb-record-one-mail does. If you want a temporary solution, just replace ebdb-record-mail with ebdb-record-one-mail. I'll let you know when a proper fix is in the works.

ecraven commented 4 years ago

Great, thank you!

girzel commented 4 years ago

Meh, even though more code needs to be fixed up, ebdb-record-mail should return mails in sorted order anyway, which should address your issue here. Please reopen if it doesn't.