-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Description
I currently use the below configuration to emulate insert-pair from lisp.el with puni-wrap-next-sexps. I figured it may be useful to add to puni itself. I'm happy to open a PR, but wanted to get your opinion first. This allows for the delimiter to be defined after calling the function, so there would be less need for puni-wrap-{round,square,curly,angle}.
Note: I currently use insert-pair-alist, but perhaps adding an alist specific to puni would be better.
(setf insert-pair-alist '((?\( ?\)) (?\[ ?\]) (?\{ ?\}) (?\< ?\>)
(?\" ?\") (?\' ?\') (?\` ?\') (?r "(" ")")
(?R "( " " )") (?c "{" "}") (?C "{ " " }")
(?b "[" "]") (?B "[ " " ]") (?o "<" ">")
(?O "< " " >") (?s "\"" "\"") (?t "\'" "\'")
(?v "`" "`")))
(defun +puni-wrap-pair (&optional n open close)
(interactive "P")
(let ((pair (or (assq last-command-event insert-pair-alist)
(assq (event-basic-type last-command-event)
insert-pair-alist))))
(if pair
(if (nth 2 pair)
(setq open (nth 1 pair) close (nth 2 pair))
(setq open (nth 0 pair) close (nth 1 pair)))))
(puni-wrap-next-sexps
(puni--parse-interactive-argument-for-wrap n)
open close))
(defvar-keymap insert-pair-map
:prefix 'insert-pair-map
"<t>" #'+puni-wrap-pair)
(keymap-global-set "C-S-w" insert-pair-map)suconakh and EGmux
Metadata
Metadata
Assignees
Labels
No labels