debugging - 在 elisp 中设置键绑定时出现“参数类型错误:commandp,my/function”
问题描述
这可能看起来像重复,但我已经尝试了所有其他解决方案但没有成功。
我的 init 文件中有一个函数,如下所示:
(defun my/function ()
"Comment or uncomment the current line or text selection."
(interactive)
(let (p1 p2)
(if (use-region-p)
当我设置键绑定时:
(global-set-key (kbd "C-x C-.") 'my/function)
我收到以下错误:
wrong type of argument: commandp, my/function
当我转身时debug-on-error
,这就是我得到的:
call-interactively(my/function nil nil)
command-execute(my/function)
我究竟做错了什么?
解决方案
你绑定的函数必须是一个命令,即:它必须(interactive)
在里面。跑步(commandp 'my/function)
应该告诉你它是否如此。
(在您的问题中,您确实有(interactive)
in 定义,但一定出了问题,也许重新评估函数的定义会解决它)
推荐阅读
- regex - RegExp:如何为列表构建正则表达式
- java - JProfiler 很慢 重新转换 17586 类文件
- caffe - 为什么 Adam 求解器的损失值在 10 万次迭代后逐渐增加?
- http - PiTunnel.com Ubuntu 的 HTTPS 隧道
- java - 如何在 Linux 上为 Eclipse 产品运行 consoleLog?
- python-2.7 - 如何设置 setuptools 存档文件名?
- ruby-on-rails - 如何使用 Active Storage 将 SVG 显示为图像
- html - Sharepoint (office 365) 在线:HTML 脚本错误
- machine-learning - 子采样层和卷积层的区别(卷积神经网络)
- python - PowerShell 上的彩色文本输出