evil-mode evil-lookup-func question
Hi everyone, I'm quite new to hacking elisp (and this mailing list), so please bear with me! For the past week, I've been customizing evil-mode to fit my needs. Recently, I've been having trouble setting the evil-lookup-func variable. I want to add mode-hooks so that when I hit "K" (upper-case) on a token in a buffer, the lookup functions that is called is appropriate to the file type. For example, I'm trying to add a hook to python-mode so that the evil-lookup-func variable is set locally to py-documentation, but it's not working. Here is my current mode-hook: (defun my-python-mode-hook() (setq evil-lookup-func #'py-documentation)) (add-hook 'python-mode-hook 'my-python-mode-hook) When I hit "K" on a token in a python-mode buffer, I get the following error: funcall: Wrong number of arguments: (lambda (w) "Launch PyDOC on the Word at Point" (interactive (list (let* ((word (thing-at-point (quote word))) (input (read-string (format "pydoc entry%s: " (if (not word) "" (format " (default %s)" word)))))) (if (string= input "") (if (not word) (error "No pydoc args given") word) input)))) (shell-command (concat py-shell-name " -c \"from pydoc import help;help('" w "')\"") "*PYDOCS*") (view-buffer-other-window "*PYDOCS*" t (quote kill-buffer-and-window))), 0 There are two main things that I need help with: 1. Why am I getting this error, even when there is a word under the point? How can I resolve this bug? 2. How do I make this hook only apply to python-mode buffers? When I hit "K" in any buffer, it calls this function. I'm sure there's a simple solution, but like I said, I'm very new to elisp. Thanks! D
On Sun, Jan 06 2013 (01:25), Daniel Friedman <[email protected]> wrote:
Hi everyone,
I'm quite new to hacking elisp (and this mailing list), so please bear with me!
[23 lines snipped]
There are two main things that I need help with: 1. Why am I getting this error, even when there is a word under the point? How can I resolve this bug?
Here: (evil-define-motion evil-lookup () "Look up the keyword at point. Calls `evil-lookup-func'." (funcall evil-lookup-func)) Evil calls `evil-lookup-func' without any argument. Try (defun evil-py-lookup () (py-documentation (word-at-point))) (setq evil-lookup-func evil-lookup-func)
2. How do I make this hook only apply to python-mode buffers? When I hit "K" in any buffer, it calls this function. I'm sure there's a simple solution, but like I said, I'm very new to elisp.
That's because `evil-lookup-func' is not buffer-local but global. Put a (make-variable-buffer-local 'evil-lookup-func) into your evil setup code. Maybe that would be a good idea to do it by default, I like your idea! Michael
participants (2)
-
Daniel Friedman -
Michael Markert