Interactively select multiple items

How can I let the user select multiple items from a list instead of one? As in the menu Cx b in the steering wheel.

Currently, I can only select one item instead of getting a complete list:

(defun test-main ()
  (interactive)
  (let ((choice (completing-read "Select: " '("item1 item2 item3"))))
    (message choice)))
+4
source share
2 answers

You can do this with completing-read-multiple:

(defun test-main ()
  (interactive)
  (let ((choice (completing-read-multiple "Select: " '("item1" "item2" "item3"))))
    (message "%S" choice)))

It returns the selected items as a list, so if you type item2,item3in the prompt, it will return ("item2" "item3").

+3
source

Because what vanilla does completing-read. It reads and returns one choice, providing completion to help you choose.

, , Icicles. completing-read, Icicle.

Icicles multi-commands, , : , , .

( ) , .

( . , .)

+2

Source: https://habr.com/ru/post/1615979/


All Articles