I have a list of objects and I want the user to pick one of them (with completion). But these objects are a priori not strings, so I can't use completing-read. What should I do ?
Example In the following example I want to write the interactive spec for killing a process, so I want the user to pick a process to kill.
(defun yf/kill-process (process)
(interactive (list (let ((list
(mapcar
(lambda (proc)
(cons (format "%s" proc) proc))
(process-list))))
(cdr
(assoc (ido-completing-read "Process: "
(mapcar #'car list))
list)))))
(when (yes-or-no-p (format "You are about to kill process \"%s\", continue? " process))
(delete-process process)))
This is something I have to do often, so I'm wondering if there's a standard way to achieve this functionality (or if I should write my own... which I have done already, but it's ugly).