"错型参数"在我写的Emacs函数上 [英] "wrong-type-argument" on an Emacs function I've written
本文介绍了"错型参数"在我写的Emacs函数上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望我的标签键执行以下操作:
I'd like my tab key to do the following:
- 如果我在minibuffer中,使用单词完成。 / li>
- 否则,如果选择了某个区域,请缩进。
- 否则,将该行缩进(使用tab-to-tab-stop)
这是代码,其中一些是基于互联网上其他地方找到的片段:
Here's the code, some of which is based on fragments I've found elsewhere on the Internet:
(defun my-tab ()
"If region is selected, indent it and keep it selected, else indent current line."
(interactive)
(if (use-region-p)
(increase-left-margin (region-beginning) (region-end) nil)
(tab-to-tab-stop))
(setq deactivate-mark nil))
(defun my-untab ()
"If region is selected, unindent it and keep it selected, else unindent current line."
(interactive)
(if (use-region-p)
(decrease-left-margin (region-beginning) (region-end) nil)
(indent-rigidly (line-beginning-position) (line-end-position) (- tab-width)))
(setq deactivate-mark nil))
;; AJF: wrote this one myself
(defun ajf-tab-fun ()
(if (minibufferp)
(minibuffer-complete)
(my-tab)))
(global-set-key (kbd "TAB") 'ajf-tab-fun)
问题是当我按Tab键时,我收到一个错误:
The problem is that when I press the tab key, I get an error:
Wrong type argument: commandp, ajf-tab-fun
我将错误设置为t,所以我可以调试。这是输出:
I set debug-on-error to t so I could debug. Here's the output:
Debugger entered--Lisp error: (wrong-type-argument commandp ajf-tab-fun)
call-interactively(ajf-tab-fun nil nil)
我该怎么做?
推荐答案
(defun ajf-tab-fun ()
(interactive) ; add interactive to let emacs know to call it interactively
(if (minibufferp)
(minibuffer-complete)
(my-tab)))
你刚刚忘了(交互式)
这篇关于"错型参数"在我写的Emacs函数上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文