0
votes

I am trying to create a function in my .emacs to bind to kbd "*" in evil mode to highlight the word under cursor in addition to normal search as in vim.

I modified the script from: http://www.emacswiki.org/emacs/SearchAtPoint

This is what I have:

(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)))

There seems to be some error here:

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

I am a lisp newbie.

Could you please help to fix this ?

1
You've called highlight-regexp with 0 args, while it requires at least 1. Use f1 f to read the function doc for highlight-regexpabo-abo
Can you explain why the default * in evil doesn't suit your needs ? It already highlights word under point and searches forward for it. In addition, you can extend the time it is highlighted with (setq evil-flash-delay 10).Ehvince
I guess this is similar to this. Checkout :)Shanavas M

1 Answers

0
votes

It seems you have copied the wrong lisp from the wiki, I am assuming you are talking about these functions. The code on the wiki uses find-tag-default in the function isearch-yank-symbol however in your version this has been replaced with a call to highlight-regexp. highlight-regexp requires atleast 1 argument. The actual function is using find-tag-default to get the symbol at point, I am not sure highlight-regexp can be used for this.

I am trying to create a function in my .emacs to bind to kbd "*" in evil mode to highlight the word under cursor in addition to normal search as in vim.

I am sorry if I am missing something here but isearch in emacs does highlight the currently searched term, doesn't it?