Evil experiences

Michael Markert markert.michael at googlemail.com
Tue Sep 13 22:32:44 CEST 2011


Finally I found the time to answer here.

On  8 Sep 2011, Tom Short wrote:
> I really like evil. (That's hard to write with a straight face.)

I can follow you here. The name's just great :)

> (setq evil-emacs-state-cursor '("red" box))

I use this for `evil-default-cursor':

#+begin_src emacs_lisp
(defun cofi/evil-cursor ()
  "Change cursor color according to evil-state."
  (let ((default "OliveDrab4")
        (cursor-colors '((insert . "dark orange")
                         (emacs  . "sienna")
                         (visual . "white"))))
    (setq cursor-type (if (eq evil-state 'visual)
                          'hollow
                        'bar))
    (set-cursor-color (def-assoc evil-state cursor-colors default))))
#+end_src

> (require 'key-chord) ; for mapping simultaneous key presses
> ;; http://www.emacswiki.org/emacs/key-chord.el
> (key-chord-mode 1)
> (key-chord-define-global "jk"  'evil-normal-state) ; super ESC
> (key-chord-define-global "JK"  'evil-emacs-state)
> (key-chord-define-global "df"  'evil-window-map)
> (key-chord-define evil-window-map "df" 'evil-window-prev) ; df twice
> (DOESN'T WORK)

Is that a "doesn't work" for "key-chord doesn't like evil" or just for
the double df? Anyway I use this for "jk" as `ESC' (with help from Frank):

#+begin_src emacs_lisp
(evil-define-command cofi/evil-maybe-exit ()
  :repeat change
  (interactive)
  (let ((modified (buffer-modified-p))
        (entry-key ?j)
        (exit-key ?k))
    (insert entry-key)
    (let ((evt (read-event (format "Insert %c to exit insert state" exit-key) nil 0.5)))
      (cond
       ((null evt) (message ""))
       ((and (integerp evt) (char-equal evt exit-key))
          (delete-char -1)
          (set-buffer-modified-p modified)
          (push 'escape unread-command-events))
       (t (push evt unread-command-events))))))
#+end_src

Maybe this could be generalized for vim-like mapping support (one that
doesn't eternally wait keys if a binding is not reached)?

To contribute a tweak myself:

#+begin_src emacs_lisp
(defadvice evil-goto-definition (around evil-goto-lisp-def activate)
  "Make use of emacs' and slime's possibilities for finding definitions."
  (case major-mode
    (lisp-mode (if slime-mode
                   (or (slime-find-definitions (symbol-name (symbol-at-point)))
                       ad-do-it)
                 ad-do-it))
    (emacs-lisp-mode (condition-case nil
                         (find-function (symbol-at-point))
                       (error (condition-case nil
                                  (find-variable (symbol-at-point))
                                (error ad-do-it)))))
    (otherwise ad-do-it)))
#+end_src

My complete evil config is on github[1].

Michael

Footnotes:

[1] https://github.com/cofi/dotfiles/blob/master/emacs.d/cofi-evil.el
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
Url : https://lists.ourproject.org/pipermail/implementations-list/attachments/20110913/56d5f28c/attachment.pgp 


More information about the implementations-list mailing list