Wrapping paredit-forward

Nikolai Weibull now at disu.se
Thu May 29 21:28:44 CEST 2014


On Thu, May 29, 2014 at 6:06 PM, Óscar Fuentes <ofv at wanadoo.es> wrote:
> Nikolai Weibull <now at disu.se> writes:
>
>>>> How should I go about wrapping paredit-forward so that it will work in
>>>> normal mode?
>>>>
>>>> The problem currently is that once you hit a ‘)’ at the end of a line
>>>> you can’t go forward any more, as point will be /at/ the ‘)’, due to
>>>> the way Evil works, not /after/ the ‘)’, as paredit expects it to be.
>>>
>>> For me C-M-f (paredit-forward) puts the point after the closing paren,
>>> so successive C-M-f works as expected.
>>
>> In /insert/ mode, yes.  My question mentioned that I’m interested in
>> using paredit-forward in /normal/ mode.

> Sorry for not explicitly stating the fact on my previous message, but I
> was talking of normal mode all along. So there is something different on
> our setups that affects how paredit-forward works on normal mode...

(Phew!  I thought you were being a bit daft…I guess I’m a bit too used
to work e-mail.)

> While looking again at my .emacs I found this:
>
> (setq evil-move-cursor-back nil)
> (setq evil-highlight-closing-paren-at-point-states nil)
>
> specifically evil-move-cursor-back is, most likely, what you want.

Yes.  Even though I prefer the Vi way of doing this (not because it
makes a lot of sense, but because it’s what I’m used to), having
access to this command alone is reason enough to make the switch.
Perhaps I might finally do so.

Here’s a possible solution that seems to work, but probably doesn’t
take some edge case into account:

(evil-define-motion evil-paredit-forward (count)
  "TBD."
  :type inclusive
  (if (and evil-move-cursor-back
        (eq last-command 'evil-paredit-forward)
        (= count 1)
        (not (eolp)) (save-excursion (forward-char) (eolp)))
      (forward-char))
    (dotimes (i (or count 1))
      (paredit-forward)))

Comments?

Thanks!



More information about the implementations-list mailing list