Explain structure editing (smartparens)
This commit is contained in:
parent
d68d265da0
commit
d18cd7cd40
39
README.org
39
README.org
@ -1123,12 +1123,38 @@ widened buffer states.
|
||||
(add-hook 'text-mode-hook #'ws-butler-mode)))
|
||||
#+end_src
|
||||
|
||||
** Smart character-pair handling
|
||||
** Structure editing
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: sec:structure-editing
|
||||
:END:
|
||||
|
||||
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://lists.gnu.org/archive/html/help-gnu-emacs/2014-07/msg00135.html][How to enable smartparens in the minibuffer after eval-expression]]
|
||||
Structure editing keeps character pairs (for instance parentheses, curly and
|
||||
square brackets as well as single and double quotes) balanced to leave code (for
|
||||
instance Lisp and Python) and text (for instance LaTeX and Org) structure
|
||||
intact. I use [[https://github.com/Fuco1/smartparens][smartparens]] which offers a normal mode (=smartparens-mode=) and a
|
||||
a strict mode (=smartparens-strict-mode=). Although both modes insert character
|
||||
pairs, the normal mode allows to easily delete one of the paired characters
|
||||
while the strict mode does not. Therefore, the strict mode is more for code
|
||||
editing since it never breaks programming language rules and the normal mode is
|
||||
more for text editing where structure is a matter of convention instead of
|
||||
programming language rules.
|
||||
|
||||
For instance, the strict mode in Python allows to delete entire lists, tuples,
|
||||
or the arguments after the cursor (what Emacs calls =point=) in a function call
|
||||
without breaking the character pair balance. In order to repair a broken
|
||||
character pair balance, insert a single character by prefixing it with "C-q"
|
||||
bound to =quoted-insert=.
|
||||
|
||||
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"]] is the first place to look for
|
||||
how to tweak [[https://github.com/Fuco1/smartparens][smartparens]]. However, the gist may be partially obsolete, since
|
||||
it is not part of his current [[https://github.com/oantolin/emacs-config][Emacs configuration]].
|
||||
2. [[https://lists.gnu.org/archive/html/help-gnu-emacs/2014-07/msg00135.html][How to enable smartparens in the minibuffer after eval-expression]] explains
|
||||
how the machinery after the first and after later usages of =eval-expression=
|
||||
differ and discusses options how to handle those differences.
|
||||
|
||||
The next block aims to configure [[https://github.com/Fuco1/smartparens][smartparens]] for Elisp, LaTeX, Org, and Python.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(unless noninteractive
|
||||
@ -1153,7 +1179,8 @@ links show how to put the documentation to practical use:
|
||||
python-mode-hook))
|
||||
(add-hook hook #'smartparens-strict-mode))
|
||||
|
||||
;; Makes only sense after `eval-expression-minibuffer-setup-hook'.
|
||||
;; Tweak for the call to `smartparens-strict-mode' hooked on
|
||||
;; `eval-expression-minibuffer-setup-hook'.
|
||||
(sp-with-modes '(fundamental-mode ; first usage.
|
||||
minibuffer-inactive-mode) ; later usage.
|
||||
(sp-local-pair "'" nil :actions nil))
|
||||
|
Loading…
Reference in New Issue
Block a user