0

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 ?

Ehvince
  • 17,274
  • 7
  • 58
  • 79
  • You've called `highlight-regexp` with 0 args, while it requires at least 1. Use `f1 f` to read the function doc for `highlight-regexp` – abo-abo Jan 30 '14 at 20:21
  • 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 Jan 31 '14 at 10:07
  • I guess this is similar to [this](http://stackoverflow.com/a/387877/4247851). Checkout :) – Shanavas M Apr 30 '17 at 12:20
  • did you try this: https://github.com/gennad/auto-highlight-symbol – gdkrmr Oct 21 '17 at 16:38

1 Answers1

0

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?