0

Consider this:

(defun kill-arg-words (arg)
  "kill `arg' words ahead of you"
  (interactive)
  (kill-region (point)
               (progn (forward-word arg) (point)
                      )))

I want to call it as M-x kill-arg-words <RET> 5 <RET>, but instead, it does not provide me the option to type in arguments after the first <RET>. How can I enable this?

Drew
  • 75,699
  • 9
  • 109
  • 225
  • https://emacs.stackexchange.com/tags/elisp/info – Drew May 29 '23 at 00:41
  • 1
    Does this answer your question? [What is the difference between a function and a command?](https://emacs.stackexchange.com/questions/3555/what-is-the-difference-between-a-function-and-a-command) – Drew May 29 '23 at 00:46
  • There are also other duplicates, e.g. emacs.stackexchange.com/q/54602/ – Drew May 29 '23 at 00:47

1 Answers1

1

In addition to specifying the arglist of the function, you have to declare where the args come from when it is called interactively.

(interactive) alone declares that an interactive call should supply no arguments. Use (interactive "n") to instead specify that when called interactively, it should first prompt for a number in the minibuffer and then supply it as the first argument.

You really should read the help message for it. Use C-h f to pull it up; it goes into some detail.

db48x
  • 15,741
  • 1
  • 19
  • 23