2014-01-30 69 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失去了一些東西確實凸顯了當前搜索的術語,不是嗎?