Function: helpful--disambiguate

helpful--disambiguate is a byte-compiled function defined in helpful.el.

Signature

(helpful--disambiguate SYM CHOICES)

Documentation

Prompt the user to disambiguate SYM via a read-char-choice selection.

CHOICES is a list of tuples of the form (FN DESC CHAR), where

  CHAR is the input character associated with the choice
  DESC is a short description of the choice to display in the prompt.
  FN is the function being chosen, which takes SYM as an argument.

For instance, the choice (#'helpful-variable "[v]ariable" ?v) calls (helpful-variable SYM) when the key v is pressed in the prompt.

Source Code

;; Defined in ~/.emacs.d/elpa/helpful-20250408.334/helpful.el
(defun helpful--disambiguate (sym choices)
  "Prompt the user to disambiguate SYM via a `read-char-choice' selection.

CHOICES is a list of tuples of the form (FN DESC CHAR), where

  CHAR is the input character associated with the choice
  DESC is a short description of the choice to display in the prompt.
  FN is the function being chosen, which takes SYM as an argument.

For instance, the choice (#'helpful-variable \"[v]ariable\" ?v)
calls (helpful-variable SYM) when the key `v' is pressed in the prompt."
  (let* ((prompt (format "%s is ambiguous: describe %s ?"
                         (propertize (symbol-name sym) 'face font-lock-keyword-face)
                         (mapconcat (-lambda ((_ desc _)) desc)
                                    choices " / ")))
         (chars (mapcar (-lambda ((_ _ char)) char)
                        choices))
         (lookup (mapcar (-lambda ((fn _ char)) (cons char fn))
                         choices))
         (input (read-char-choice prompt chars)))
    (funcall (alist-get input lookup) sym)))