我试图在 Emacs 中隐藏查找文件,为什么这个函数对我大喊大叫?
I'm trying to shadow find-file in Emacs, why is this function yelling at me about arguments?
我最近从 Vim 转为邪恶模式,我正在尝试让环境更加熟悉。我想念的一件事是 Vim 中的 find
命令。我试图通过将 find-file
命令包装在函数中来在 Emacs 中设置类似的东西。到目前为止我有这个:
(defun find nil
"Shadow vim find command, with helm."
(interactive)
(find-file))
当我 运行 命令时它对我大喊大叫,Wrong number of arguments {doc string} 0
我尝试添加参数但没有成功。真正令人困惑的一点是,我以相同的方式隐藏了一个 helm 函数并且它起作用了,就像这样:
(defun buflist nil
"List buffers in helm."
(interactive)
(helm-buffers-list))
有什么不同?我该如何解决这个问题?
find-file
需要参数,不能像
那样调用
(find-file)
调试器显示需要哪些参数:
(filename &optional wildcards)
您也可以调用帮助来查看它们:C-hf.
另一种选择是使用 call-interactively
:
(call-interactively 'find-file)
find-file
以文件名作为参数,您需要熟悉 C-h f
来查找函数文档。
interactive
可以带参数,例如,
(defun find (filename)
(interactive "F")
(find-file filename))
我最近从 Vim 转为邪恶模式,我正在尝试让环境更加熟悉。我想念的一件事是 Vim 中的 find
命令。我试图通过将 find-file
命令包装在函数中来在 Emacs 中设置类似的东西。到目前为止我有这个:
(defun find nil
"Shadow vim find command, with helm."
(interactive)
(find-file))
当我 运行 命令时它对我大喊大叫,Wrong number of arguments {doc string} 0
我尝试添加参数但没有成功。真正令人困惑的一点是,我以相同的方式隐藏了一个 helm 函数并且它起作用了,就像这样:
(defun buflist nil
"List buffers in helm."
(interactive)
(helm-buffers-list))
有什么不同?我该如何解决这个问题?
find-file
需要参数,不能像
(find-file)
调试器显示需要哪些参数:
(filename &optional wildcards)
您也可以调用帮助来查看它们:C-hf.
另一种选择是使用 call-interactively
:
(call-interactively 'find-file)
find-file
以文件名作为参数,您需要熟悉 C-h f
来查找函数文档。
interactive
可以带参数,例如,
(defun find (filename)
(interactive "F")
(find-file filename))