1

I would like to insert the number 1, and then increase the number with calling the function evil-numbers/inc-at-pt from the package evil-numbers.

So I went looking into the source code of the function evil-numbers/inc-at-pt:

(defun evil-numbers/inc-at-pt (amount &optional no-region)
"Increment the number at point or after point before end-of-line by `amount'.
When region is selected, increment all numbers in the region by `amount'

NO-REGION is internal flag that allows
`evil-numbers/inc-at-point' to be called recursively when
applying the regional features of `evil-numbers/inc-at-point'.

"
(interactive "p*")
[...]

This function don't need any region by the way. You can place your cursor after the number, without any region. It will increase the number if there is no region, then it will look for any number and increase it.

So I created a function around this

(defun eshell-go-to-number-down ()
    (interactive "p*")
    (evil-insert)
    (insert "0")
    (evil-numbers/inc-at-pt 1))

So when I call that function, it will insert the number and increase it. I plan to modify it, when there is already a number then don't insert any number. But that's a later concern. I'm trying to figure out how I call evil-numbers/inc-at-pt properly.

As it seems from the source code, the function evil-numbers/inc-at-pt expects a number, which I provide with 1 But I get the error message:

funcall-interactively: Wrong number of arguments: (lambda nil (interactive "p*") (evil-insert) (insert "1") (evil-numbers/inc-at-pt 1)), 1 

So where went I wrong? Please don't verdict me, I'm trying to learn Lisp.

2

You've misunderstood the error. Emacs is complaining about the call to your function eshell-go-to-number-down; not the call to evil-numbers/inc-at-pt.

Your problem is that you have defined a function with an empty arglist (), and then given it an interactive spec of "p*" -- which supplies an argument when the function is called interactively.

See C-h f interactive if you're uncertain of what that spec means. Also C-h i g (elisp) Prefix Command Arguments. Note that the "numeric value" of a nil prefix argument is 1, which may have further confused you.

To resolve the conflict you either need to change the interactive spec, or else introduce an argument to your function.

  • I have already thought of that. I added the word "amount" as argument to my function eshell-go-to-number-down which didn't help, same result for the 2 parameters (amount &optional no-region) for eshell-go-to-number-down. Both ways gives me only errors. But based on tips, I will study C-h f interactive further. – ReneFroger Nov 23 '15 at 20:53
  • It wouldn't give the same error (unless you didn't re-evaluate the function after modifying it). I don't use evil so I can't tell you offhand if you're misusing that. – phils Nov 23 '15 at 21:19

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.