Document and improve the smartparens configuration
This commit is contained in:
parent
f4ea67a889
commit
4119cc202a
22
README.org
22
README.org
@ -1125,25 +1125,39 @@ widened buffer states.
|
|||||||
|
|
||||||
** Smart character-pair handling
|
** Smart character-pair handling
|
||||||
|
|
||||||
|
The [[https://smartparens.readthedocs.io/en/latest/index.html][smartparens documentation]] targets experienced Emacs users. The following
|
||||||
|
links show how to put the documentation to practical use:
|
||||||
|
1. [[https://gist.github.com/oantolin][Omar Antolin's gist: my-smartparens-config.el]]
|
||||||
|
2. [[https://xenodium.com/emacs-smartparens-auto-indent/index.html][How to enable smartparens in the minibuffer after eval-expression]]
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(unless noninteractive
|
(unless noninteractive
|
||||||
|
;; To disables pairing of the quote character for lisp modes,
|
||||||
|
;; require smartparens-config instead of smartparens.
|
||||||
(when (require 'smartparens-config nil 'noerror)
|
(when (require 'smartparens-config nil 'noerror)
|
||||||
;; Requiring smartparens-config disables pairing of the quote
|
|
||||||
;; character for lisp modes, contrary to requiring smartparens.
|
|
||||||
(custom-set-variables
|
(custom-set-variables
|
||||||
'(sp-base-key-bindings 'sp)
|
'(sp-base-key-bindings 'sp)
|
||||||
'(sp-override-key-bindings '(("C-(" . sp-backward-barf-sexp)
|
'(sp-override-key-bindings '(("C-(" . sp-backward-barf-sexp)
|
||||||
("C-)" . sp-forward-slurp-sexp))))
|
("C-)" . sp-forward-slurp-sexp))))
|
||||||
|
|
||||||
(add-hook 'prog-mode-hook #'smartparens-mode)
|
(dolist (hook '(prog-mode-hook
|
||||||
(add-hook 'text-mode-hook #'smartparens-mode)
|
text-mode-hook))
|
||||||
|
(add-hook hook #'smartparens-mode))
|
||||||
|
|
||||||
|
;; Hook on the specific `eval-expression-minibuffer-setup-hook'
|
||||||
|
;; and not on the general `minibuffer-setup-hook'.
|
||||||
(dolist (hook '(emacs-lisp-mode-hook
|
(dolist (hook '(emacs-lisp-mode-hook
|
||||||
eval-expression-minibuffer-setup-hook
|
eval-expression-minibuffer-setup-hook
|
||||||
ielm-mode-hook
|
ielm-mode-hook
|
||||||
|
inferior-emacs-lisp-mode-hook
|
||||||
python-mode-hook))
|
python-mode-hook))
|
||||||
(add-hook hook #'smartparens-strict-mode))
|
(add-hook hook #'smartparens-strict-mode))
|
||||||
|
|
||||||
|
;; Makes only sense after `eval-expression-minibuffer-setup-hook'.
|
||||||
|
(sp-with-modes '(fundamental-mode ; first usage.
|
||||||
|
minibuffer-inactive-mode) ; later usage.
|
||||||
|
(sp-local-pair "'" nil :actions nil))
|
||||||
|
|
||||||
;; https://xenodium.com/emacs-smartparens-auto-indent/index.html
|
;; https://xenodium.com/emacs-smartparens-auto-indent/index.html
|
||||||
(defun indent-between-pair (&rest _ignored)
|
(defun indent-between-pair (&rest _ignored)
|
||||||
(newline)
|
(newline)
|
||||||
|
Loading…
Reference in New Issue
Block a user