pimutils / khal

:calendar: CLI calendar application
https://lostpackets.de/khal/
MIT License
2.6k stars 199 forks source link

Added autocomplete of mail addresses to attendees in event editor in interactive mode. #1324

Open dabrowskiw opened 9 months ago

dabrowskiw commented 9 months ago

Hello,

I have added autocompletion of attendees in the event editor. This works by exposing an additional configuration option "address_adapter" in the account section. The command specified there is run on startup using "bash -c" and the input is parsed as the contacts for that account. The parser (in CalendarCollection, in _contacts_update()) is written under the assumption that "address_adapter" will be "khal email | tail -n +2", however I am sure other contact managers can be forced to output in the same format, or the parser can be extended to be more intelligent.

The autocomplete (in attendeewidget.py) is using IndicativeListBox from additional_urwid_widgets (available via pip, pyproject.toml updated accordingly) to display autocomplete options and some ugly hackery to pretend that focus is still on the address line while it actually is in the list.

All tests run, and I suspect that the autogenerated configspec.rst should include the comment from khal.spec where I explained how address_adapter works - I am not sure though since I am not familiar with Sphinx and was not able to divine how the Makefile generated the configspec.rst file.

This code is not going to win any beauty contests, the best I can do is hope that only a few of those who look at it will need PTSD treatment. However, this is a development driven by need and not by too much spare time, so I am afraid that it's either "share it now" or "share it when it's cleaned up, which may well be never". If you think the usefulness of the feature outweighs the ugliness of the code, I am more than happy to contribute, but I will not be offended if you don't.

Anyways, thanks for the great tool that khal is, I very much enjoy working with it :)

geier commented 5 months ago

Thanks for your contribution, @dabrowskiw! This sounds like a very useful feature!

Some notes:

For me, the attendee widget doesn't have a leading 'Attendee' anymore and I believe that text field should be labeled.

image

I would liket to drop the ruff commit, it adds a lot of noise which makes reviewing the PR harder. (I rebased this PR on master and dropped the ruff commit, see https://github.com/pimutils/khal/tree/rebase_pr1324 )