completing-read set to show me a plist.
I want to do something without RETURNING (completing the function).
(defun fancy-mode-call-buffer () "List buffers to switch." (interactive) (let* ((visible-buffers-plist (working-function-returning-desired-plist)) (key (completing-read "Buffer: " visible-buffers-plist nil nil "^")) (val (alist-get key visible-buffers-plist nil nil #'string=))) (message "Called buffer: %s" val) (switch-to-buffer val)))
This function will list the visible-buffers using
completing-read, and if I press RET it will "log" the called buffer with
message and then
switch-to-buffer to the desired buffer.
What I need now, is to do actions before switching buffer (completing the function), like if I want to press
C-x k to kill the highlighted/selected buffer just like in
ivy-switch-buffer. How can I recover the "highlighted" cons?
Of course I need to create a key-map and define a custom
C-x k to do the job, I think it's easy once I have the "current selected" item. But I don't know if this is possible in vanilla
completing-read. I've been reading the documentation and searching without success, maybe I missed it?