On Sat, Jun 02 2012 (21:20), Simon Carter <[email protected]> wrote: 

> I was wondering if there was a canonical method for allowing camelcase
> and underscore word movement in evil-mode.

Not to my knowledge.

> I've looked at the suggestion in
> http://slashusr.wordpress.com/2011/09/15/heretical-confessions-of-an-emacs-addict-joy-of-the-vim-text-editor/,
> but that solution was somewhat limited (no backward movement, and it
> only worked with other operators, rather than as an actual method of
> movement).

Ok this is the solution posted:

    (evil-define-motion evil-little-word (count)
      :type exclusive
      (let ((case-fold-search nil))
        (forward-char)
        (search-forward-regexp "[_A-Z]\\|\\W" nil t)
        (backward-char)))

it only works with other operators, because it was defined in
`evil-operator-state-map' define in in `evil-motion-state-map' and it
will work on its own (but you maybe want to chose another key sequence
to not shadow `l').

Here is code for the backword movement:

    (evil-define-motion evil-little-word-backward (count)
      :type inclusive
      (let ((case-fold-search nil))
        (backward-char)
        (search-backward-regexp "[_A-Z]\\|\\W" nil t)))

You have to define it as well as keys, of course.

Another change you want to make is the inclusion of `count':

    (evil-define-motion evil-little-word (count)
      :type exclusive
      (let ((case-fold-search nil))
        (forward-char)
        (search-forward-regexp "[_A-Z]\\|\\W" nil t count)
        (backward-char)))
        
respective

    (evil-define-motion evil-little-word-backward (count)
      :type inclusive
      (let ((case-fold-search nil))
        (backward-char)
        (search-backward-regexp "[_A-Z]\\|\\W" nil t count)))
        
As there's `subword-mode' for vanilla Emacs maybe it would be nice to
change the word movements (b, e, w and their ilk) to subword movements
if subword-move is active for a tighter emacs integration?

Michael

Attachment: pgpNxft6ljCei.pgp
Description: PGP signature

_______________________________________________
implementations-list mailing list
[email protected]
https://lists.ourproject.org/cgi-bin/mailman/listinfo/implementations-list

Reply via email to