Search code examples
emacselisp

I'm trying to shadow find-file in Emacs, why is this function yelling at me about arguments?


I'm a recent convert to Evil-mode from Vim and I'm trying to make the environment more familiar. One of the things I miss is the find command in Vim. I'm trying to set up something similar in Emacs by wrapping the find-file command in a function. So far I have this:

(defun find nil
  "Shadow vim find command, with helm."
  (interactive)
  (find-file))

When I run the command it yells at me, Wrong number of arguments {doc string} 0 I've tried adding arguments and had no success. The really confusing bit is that I shadowed a helm function the same way and it worked, like this:

(defun buflist nil
  "List buffers in helm."
  (interactive)
  (helm-buffers-list))

What's different? How do I fix this?


Solution

  • find-file needs arguments, you can't call it just like

    (find-file)
    

    The debugger shows what arguments are needed:

    (filename &optional wildcards)
    

    You can also invoke help to see them: C-hf.

    Another option is to use call-interactively:

    (call-interactively 'find-file)