Open tpeacock19 opened 1 year ago
Sorry for the late response.
I'm not sure if people will actually use +puni-wrap-pair
often, based on my own habit:
(
/)
or backticks.electric-pair-mode
to insert delimiters around the selection, so I'm used to mark the region to be wrapped first. "Wrapping the next N sexps" is not intuitive for me. If you are also used to mark things first, you could rewrite +puni-wrap-pair
to be not based on Puni.But if you are sure some users will found it useful, please go ahead.
(defun puni-wrap (char)
"Wrap the region with the given CHAR."
(cond ((or (eq char ?\)) (eq char ?\()) (puni-wrap-round))
((or (eq char ?\]) (eq char ?\[)) (puni-wrap-square))
((or (eq char ?\}) (eq char ?\{)) (puni-wrap-curly))
(t (save-excursion
(goto-char (region-end))
(insert char)
(goto-char (region-beginning))
(insert char)))))
(defun meow-wrap-with-pair ()
"Prompt user to enter a character to wrap the active region, and use `puni-wrap`."
(interactive)
(if (use-region-p)
(let ((char (read-char "Enter the character to wrap with: ")))
(puni-wrap char))
(message "No active region")))
I'm using this myself. Just sharing for others to steal
I currently use the below configuration to emulate
insert-pair
fromlisp.el
withpuni-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 forpuni-wrap-{round,square,curly,angle}
.Note: I currently use
insert-pair-alist
, but perhaps adding an alist specific topuni
would be better.