smartparens
smartparens copied to clipboard
A few questions about configuring smartparens package.
On Ubuntu 20.10, I use the latest git master version of Emacs and installed the lastest smartparens from melpa with the following settings in my ~/.emacs.d/init.el:
(use-package smartparens-config
:ensure smartparens
:config (progn (show-smartparens-global-mode t)))
(add-hook 'prog-mode-hook #'smartparens-strict-mode)
(setq sp-navigate-close-if-unbalanced t)
The above setting seems to be working smoothly. But I still can't understand a few questions as described below:
- Based on my tries, all the following forms are equivalent:
(add-hook 'prog-mode-hook 'turn-on-smartparens-strict-mode)
(add-hook 'prog-mode-hook 'smartparens-strict-mode)
(add-hook 'prog-mode-hook #'smartparens-strict-mode)
Why?
-
As you can see, the above settings only activate the smartparens-strict-mode conditionally for prog-mode. If I want to always activate this mode in any case globally. What setting should I use?
-
Are the following two instructions equivalent:
(require 'smartparens-config)
and
(use-package smartparens-config
Regards, HY
turn-on-smartparens-strict-modestarts the mode except in modes on the ignore listsp-ignore-modes-listor special buffers. This is described in the documentation.- use
smartparens-global-strict-modewhich usesturn-on-smartparens-strict-modeto enable the mode in any new buffer. - this is a question for
use-packagepackage: https://github.com/jwiegley/use-package, but in short no, it's not the same.use-packagehas a lot more features which are too much to describe here. Check their readme.
- use smartparens-global-strict-mode which uses turn-on-smartparens-strict-mode to enable the mode in any new buffer.
Do you mean something like this: :config (progn (smartparens-global-strict-mode t))?
The global mode is generated by Emacs and this is the documentation:
(smartparens-global-strict-mode &optional ARG)
Toggle Smartparens-Strict mode in all buffers. With prefix ARG, enable Smartparens-Global-Strict mode if ARG is positive; otherwise, disable it. If called from Lisp, enable the mode if ARG is omitted or nil.
So drop the t argument.
So drop the
targument.
But based on my tries, the following usage in .emacs.d/init.el is still vaild:
(use-package smartparens
:demand t
:config
(setq sp-navigate-close-if-unbalanced t)
(progn
(require 'smartparens-latex)
(smartparens-global-strict-mode t)
(smartparens-mode +1)))