EDIT better alternative
A better alternative, provided in Emacs since version 28,
is to use the read-extended-command-predicate
to (pre-)filter the candidates listed by M-x
:
(defun execute-my-extended-command (&optional prefixarg)
(interactive "P")
(let ((read-extended-command-predicate
(lambda (s _)
(string-match "protoc" (symbol-name s)))))
(execute-extended-command prefixarg)))
I'll keep the old answer below, as it is also informative.
END EDIT
I don't understand unread-command-events
very well, but from the answer here, I figured that you could use
(defun execute-my-extended-command (&rest args)
"Read a command name to call, favoring commands that begin with `*'.
Like `execute-extended-command', but when called interactively, preload a
leading `*' into the minibuffer."
(interactive)
(if (interactive-p)
(progn
(setq unread-command-events (listify-key-sequence "protoc"))
(call-interactively #'execute-extended-command))
(funcall #'execute-extended-command args)))
Now you could bind that command to H-x
(Wow, you have a hyper key!)