2014-01-30 43 views
0

我试图在我的.emacs中创建一个函数,以在邪恶模式下绑定到kbd“*”,以便像在vim中一样突出显示光标下的单词。emacs在光标下突出显示单词

我修改从脚本: http://www.emacswiki.org/emacs/SearchAtPoint

这是我有:

(defun isearch-yank-regexp (regexp) 
    "Pull REGEXP into search regexp." 
    (let ((isearch-regexp nil)) ;; Dynamic binding of global. 
     (isearch-yank-string regexp)) 
    (if (not isearch-regexp) 
    (isearch-toggle-regexp)) 
    (isearch-search-and-update)) 

    (defun isearch-yank-symbol() 
    "Put symbol at current point into search string." 
    (interactive) 
    (let ((sym (highlight-regexp))) 
     (if (null sym) 
     (message "No symbol at point") 
    (isearch-yank-regexp 
    (concat "\\_<" (regexp-quote sym) "\\_>")) 'hi-yellow))) 

似乎有一些错误的位置:

let: Wrong number of arguments: #[(regexp &optional face) 

我是一个口齿不清的新手。

你能帮我解决这个问题吗?

+0

你已经用0个参数调用了'highlight-regexp',而它至少需要1.使用'f1 f'来读取'highlight-regexp'的函数doc –

+0

你能解释为什么默认*不适合你的需求?它已经突出显示单词下的单词并向前搜索。另外,你可以延长突出显示的时间(setq evil-flash-delay 10)。 – Ehvince

+0

我想这与[this]类似(http://stackoverflow.com/a/387877/4247851)。结帐:) –

回答

0

看来你已经从wiki复制了错误的lisp,我假设你正在谈论these函数。 Wiki上的代码在函数isearch-yank-symbol中使用find-tag-default,但在您的版本中,此函数已被highlight-regexp调用所取代。 highlight-regexp需要至少1个参数。实际功能是使用find-tag-default来得到符号的点,我不确定highlight-regexp可以用于此。

我想创建我的.emacs功能绑定在 邪模式骨节病“*”,突出,除了正常 搜索在VIM下光标字。

我很抱歉,如果我在这里的Emacs但isearch失去了一些东西确实凸显了当前搜索的术语,不是吗?