radian-software / selectrum

🔔 Better solution for incremental narrowing in Emacs.
MIT License
737 stars 33 forks source link

completing-read-multi can't select all, resets after each selection #395

Open WorldsEndless opened 3 years ago

WorldsEndless commented 3 years ago

I used to use helm, and then ivy, to select addresses for emails I'm composing. I've now written it up using completing-read-multiple and at first it appears to work fine; indeed, there's no problem if I select only one. But I have problems with other major work flows:

  1. Search for all addresses that are part of my "newsletter" group (works fine; I see all those addresses)

2a. Fails: Try to select all of them at once (I can't find a "select all" key in standard completing-read-multiple; does it exist?)

2b. Press "TAB" to add one individually

  1. After adding that one option, I'm back to step 1: I need search again, re-enter "newsletter" etc.

How can I select all? Similarly, it seems like an undesirable workflow that hitting TAB always resets your Selectrum results.

clemera commented 3 years ago

A select all funcitonality doesn't exist, I think adding it to our adapted version in Selectrum is a great idea.

Similarly, it seems like an undesirable workflow that hitting TAB always resets your Selectrum results

Hitting TAB adds another candidate to your results and you can proceed searching for more. Do you think we could do better? What behaviour are you looking for? Maybe the prompt should be selected after TAB so one can immediately exit with RET or proceed searching by typing.

WorldsEndless commented 3 years ago

Hitting TAB adds another candidate to your results and you can proceed searching for more. Do you think we could do better? What behaviour are you looking for? Maybe the prompt should be selected after TAB so one can immediately exit with RET or proceed searching by typing.

My work flow is this:

  1. Start my completing-read-multiple
  2. type "newsletter", which reduces it appropriately
  3. Since there's no "select all", I choose one and press "tab"
  4. My prompt now includes the one I chose, followed by crm-separator
  5. I have to re-specify "newsletter" to find out who to add next

My snippet:

      (let ((crm-separator "|"))
    (insert (string-join
         (mapcar 'tsa/format-insert-email
             (completing-read-multiple "Select:" (tsa/get-address-names (bbdb-records))))
         ", "))) 
clemera commented 3 years ago

Thanks, as far as I understand we would only need to provide a select all functionality to make this use case more convenient. The reset is intentional and for the usual case it makes sense to keep it that way unless I am missing something. Keeping the prompt selected as I mentioned earlier might still be nice.

clemera commented 3 years ago

After trying I also see now that if you want to select multiple candidates which share a common substring the reset is inconvenient. Maybe we could have a key to add a candidate but also keep the current search string this would also solve the use case when you don't want all but multiple ones with a same substring.

clemera commented 3 years ago

For reference the following improvements for crm could be nice:

WorldsEndless commented 3 years ago

These are good. An addition that would be nice is a face to highlight elements that have already been selected, so it's easily visible.

clemera commented 3 years ago

You probably did not notice that we already omit candidates which are selected.

WorldsEndless commented 3 years ago

Ah! Perfect! Amidst the other changes to my selection list, you're right: I didn't notice that.

clemera commented 3 years ago

Regarding the prompt selection I think it is better to stay consistent with how we handle it elsewhere (for example file completions). To finish your input you should press "RET" on the last candidate. If you "wrongly" typed "TAB" you can remove the last "," or select the prompt to submit.