Swap parentheses and square brackets in Emacs Paredit
问题 How can I define a command in paredit mode that swaps parentheses and square brackets? 回答1: The following code does what you request. You can bind swap-parens to whatever key binding you want. (defvar swap-paren-pairs '("()" "[]")) (defun swap-parens-at-points (b e) (let ((open-char (buffer-substring b (+ b 1))) (paren-pair-list (append swap-paren-pairs swap-paren-pairs))) (while paren-pair-list (if (eq (aref open-char 0) (aref (car paren-pair-list) 0)) (save-excursion (setq to-replace (cadr