[已解决]smartparens 如何设置使得删除左括号时自动删除右括号

类似 autopair 这个插件的效果。

默认是可以的,与 hungry delete 冲突了,去掉就可以了,或者参考 Always remove brackets by pairs - fix hungry-delete-mode and smartparens-strict-mode conflict issue 见 Better integration with hungry-delete

我也碰到了这个问题,但是我讲 hungry delete 去掉后,仍然无法成对删除括号。

我是在用 Auctex 时碰到这个问题,我的 minor mode 是 Auto-Composition Auto-Compression Auto-Encryption Blink-Cursor Company Electric-Indent File-Name-Shadow Font-Lock Global-Company Global-Eldoc Global-Font-Lock Global-Hl-Line Global-Linum Ivy Latex-Math Line-Number Linum Menu-Bar Mouse-Wheel Recentf Reftex Shell-Dirtrack Show-Paren Tex-Pdf Tooltip Transient-Mark Visual-Line

请问是否是因为这些 minor mode 有冲突?

没用过 Auctex 不是特别清楚,别的 major mode 去掉 hungry mode 是否正常? 另外后来我想用 hungry mode 是这样解决的

;; fix hungry-delete & smartparents conflict
(defadvice hungry-delete-backward (before sp-delete-pair-advice activate) (save-match-data (sp-delete-pair (ad-get-arg 0))))

抱歉,我刚发现 (add-hook 'LaTex-mode-hook #'smartparens-mode) 无法自动加载 smartparens。在用 M-x smartparens-mode 加载后就正常了。

请问下,我上一句 (add-hook 'LaTex-mode-hook #'smartparens-mode) 有问题吗?

应该是 (add-hook 'LaTeX-mode-hook 'smartparens-mode) ? https://github.com/anmonteiro/dotfiles/blob/master/.emacs.d/customizations/setup-latex.el#L8

非常感谢,我把 (add-hook 'latex-mode-hook 'smartparens-mode) (add-hook 'LaTeX-mode-hook 'smartparens-mode) (add-hook 'tex-mode-hook 'smartparens-mode) (add-hook 'TeX-mode-hook 'smartparens-mode) (add-hook 'bibtex-mode-hook 'smartparens-mode) 添加进 init.el 后,就可以自动加载了。 可能是我之前选择的major mode (LaTex-mode)不对,应该是 Tex-mode。