Advice that calls transpose-chars instead of evil-shift-right-line (C-t)

Christoph LANGE langec at web.de
Wed Feb 20 13:09:27 CET 2013


Hi all,

on the one hand I welcome the new commands evil-shift-right-line (C-t)
and evil-shift-left-line (C-d) in insert mode, as this has been one of
the features I had always missed in evil.

And it is good that evil-shift-right-line is bound to C-t instead of C-i
as in vim, as C-i does other useful things in Emacs.

However, one of my most frequently used Emacs functions in insert mode
has so far been transpose-chars, which is what Emacs binds to C-t.
(Transposing two characters in vim is a PITA; you'd have to do "_xp in
command mode.)

So I came up with the following for my .emacs:

(defadvice evil-shift-right-line (around evil activate)
  "call transpose-chars if universal argument given"
  (if (equal current-prefix-arg '(4))
      (transpose-chars 1)
    ad-do-it))

This gives me transpose-chars with C-u C-t, and evil-shift-right-line
with C-t.

The only drawback is that it unconditionally calls transpose-chars with
an argument of 1, but so far I have never used it with different
arguments anyway.

Suggestions for improving this are welcome.

Cheers,

Christoph

-- 
Christoph Lange, http://www.facebook.com/ch.lange, Skype duke4701



More information about the implementations-list mailing list