<div dir="ltr"><div>I do this:<br><br>(define-key evil-normal-state-map "o" nil)<br>(define-key evil-visual-state-map "o" nil)<br>(defmacro my-define-insert-pair-key-binding (open-char close-char)<br> "Define key binding for inserting a pair."<br> `(define-key evil-normal-state-map ,(format "o%c" open-char)<br> (lambda (&optional parg)<br> (interactive "*P")<br> (insert-pair parg ,open-char ,close-char))))<br>(my-define-insert-pair-key-binding ?\" ?\")<br>(my-define-insert-pair-key-binding ?\' ?\')<br>(my-define-insert-pair-key-binding ?\( ?\))<br>(my-define-insert-pair-key-binding ?\[ ?\])<br>(my-define-insert-pair-key-binding ?\{ ?\})<br>(my-define-insert-pair-key-binding ?\< ?\>)<br><br></div>No reason you need to use "o", but this means if region is active and I type o[ then the region is enclosed in []. Same for quotes and other brackets.<br><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 28, 2016 at 6:33 AM, Frank Fischer <span dir="ltr"><<a href="mailto:frank-fischer@shadow-soft.de" target="_blank">frank-fischer@shadow-soft.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 27.11.2016 14:27, ivan wrote:<br>
> But in evil-visual-state, "(" is bound to evil-backward-sentence-begin.<br>
> The binding originates in evil-motion-state-map, which both normal and<br>
> visual states inherit from. I've tried a few ways to rebind "(" to<br>
> self-insert-command in order to let smartparens do its thing, but so far<br>
> nothing I've tried has worked:<br>
><br>
> (define-key evil-visual-state-map (kbd "(") 'self-insert-command)<br>
> (define-key evil-motion-state-map (kbd "(") 'self-insert-command)<br>
> (define-key evil-motion-state-map (kbd "(") nil)<br>
> (evil-define-key 'visual evil-visual-state-map (kbd "(")<br>
> 'self-insert-command)<br>
><br>
> How can I properly configure this?<br>
<br>
</span>You probably need to write your own command that inserts both characters<br>
at the beginning and the end of the region. Something like this might work:<br>
<br>
(defconst my-pairs-alist '((?( . ?))<br>
(?{ . ?})<br>
(?[ . ?])))<br>
<br>
(evil-define-operator my-wrap (beg end type)<br>
(interactive "<R>")<br>
(let* ((ch last-command-event)<br>
(pair (or (assoc ch my-pairs-alist)<br>
(rassoc ch my-pairs-alist))))<br>
;; Other characters a paired literally, e.g. "<br>
(unless pair<br>
(unless (characterp ch)<br>
(user-error "Cannot pair key %s" ch))<br>
(setq pair (cons ch ch)))<br>
(save-excursion<br>
(goto-char end)<br>
(insert-char (cdr pair))<br>
(goto-char beg)<br>
(insert-char (car pair)))))<br>
<br>
(define-key evil-visual-state-map "(" 'my-wrap)<br>
(define-key evil-visual-state-map ")" 'my-wrap)<br>
(define-key evil-visual-state-map "[" 'my-wrap)<br>
(define-key evil-visual-state-map "]" 'my-wrap)<br>
(define-key evil-visual-state-map "{" 'my-wrap)<br>
(define-key evil-visual-state-map "}" 'my-wrap)<br>
(define-key evil-visual-state-map "\"" 'my-wrap)<br>
(define-key evil-visual-state-map "'" 'my-wrap)<br>
<br>
Bind `my-wrap` to whatever key should be paired. Maybe " or ' are not so<br>
good because this would shadow register and mark access.<br>
<br>
Frank<br>
<br>
______________________________<wbr>_________________<br>
implementations-list mailing list<br>
<a href="mailto:implementations-list@lists.ourproject.org">implementations-list@lists.<wbr>ourproject.org</a><br>
<a href="https://lists.ourproject.org/cgi-bin/mailman/listinfo/implementations-list" rel="noreferrer" target="_blank">https://lists.ourproject.org/<wbr>cgi-bin/mailman/listinfo/<wbr>implementations-list</a><br>
</blockquote></div><br></div>