I want to implement a custom M-x (execute-extended-command). This time real skeleton-coding (crying)

(defun gbq-extended-command (inst) 
  (interactive "sgbq-X ")
  (cond ((equal inst "eob") (end-of-buffer)))
  ;; BODY of function

in this function, I want completion instruction. for example, if call the function, like M-x, when I type eo, Completion from eo to eob. but I have no idea how.

  • Are you aware of the key sequences C-<end> and C-<begin>? If you want to have shortcuts for existing commands consider also defalias.
    – Tobias
    Mar 26 '19 at 11:26
  • @Tobias Thanks for your Comment!! but, i want own 'M-x'. So wondering that implementation. but i dnt want reinventing the wheel T.T, Hmm, another way you know that rename from 'M-x' to 'gbq-X' as Text when call the M-x! Mar 26 '19 at 11:45

Have you looked at the definition of execute-extended-command for inspiration (in simple.el, reachable via the link in C-h o execute-extended-command)?

In any case, to prompt the user in the minibuffer with completion, you want to use the completing-read function (about which you can read in the Elisp manual).

  • yaya!! in completing-read , i get try-completion! Thanks for your answer. my knowledge level up , 🍺 this is for you! Mar 26 '19 at 13:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.