Fix and tidy the text and code in the Structural Editing section

This commit is contained in:
Gerard Vermeulen 2023-12-31 11:43:48 +01:00
parent 3a75ac2a46
commit b3455d3412

View File

@ -6437,16 +6437,18 @@ following links show how to put the documentation to practical use:
3. [[https://lists.gnu.org/archive/html/help-gnu-emacs/2014-07/msg00135.html][How to enable smartparens in the minibuffer after eval-expression]] explains 3. [[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= how the machinery after the first and after later usages of =eval-expression=
differ and discusses options how to handle those differences. differ and discusses options how to handle those differences.
Listing [[lst:configure-smartparens]] aims to configure [[https://github.com/Fuco1/smartparens][smartparens]] for Elisp, Listing [[lst:configure-smartparens]] aims to configure [[https://github.com/Fuco1/smartparens][smartparens]] for Go, LaTeX,
LaTeX, Org, and Python. Lisp dialects, Org, and Python. Execute src_emacs-lisp{(sp-cheat-sheet)} for
short documentation taking into account the overridden key bindings in listing
[[lst:configure-smartparens]].
Despite the provocative post [[https://andreyorst.gitlab.io/posts/2022-02-20-what-if-structural-editing-was-a-mistake/]["What if structural editing was a mistake?"]], Despite the provocative post [[https://andreyorst.gitlab.io/posts/2022-02-20-what-if-structural-editing-was-a-mistake/]["What if structural editing was a mistake?"]],
[[https://github.com/Fuco1/smartparens][smartparens]] is one of my favorite packages. In particular, [[https://github.com/Fuco1/smartparens][smartparens]] handles [[https://github.com/Fuco1/smartparens][smartparens]] is one of my favorite packages. In particular, [[https://github.com/Fuco1/smartparens][smartparens]] handles
matching pairs in Org-mode files with export and source blocks for multiple matching pairs in Org-mode files with export and source blocks for multiple
formats and languages almost (exceptions are due to ~elisp~ functions like ~<~ formats and languages almost (exceptions are due to ~Search failed~ errors
and ~<=~) correctly. Therefore, [[https://smartparens.readthedocs.io/en/latest/index.html?highlight=show-smartparens-mode#getting-started][show-smartparens-mode]] highlights matching pairs inside source blocks) correctly. Therefore, [[https://smartparens.readthedocs.io/en/latest/index.html?highlight=show-smartparens-mode#getting-started][show-smartparens-mode]] highlights
immediately in front or after point in such files correctly, contrary to for matching pairs immediately in front or after point in such files correctly,
instance [[https://github.com/Fanael/rainbow-delimiters#readme][rainbow-delimiters]]. contrary to for instance [[https://github.com/Fanael/rainbow-delimiters#readme][rainbow-delimiters]].
#+caption[Configure =smartparens=]: #+caption[Configure =smartparens=]:
#+caption: Configure =smartparens=. #+caption: Configure =smartparens=.
@ -6457,17 +6459,17 @@ instance [[https://github.com/Fanael/rainbow-delimiters#readme][rainbow-delimite
;; disable pairing of the quote character for lisp modes. ;; disable pairing of the quote character for lisp modes.
(require 'smartparens-config nil 'noerror)) (require 'smartparens-config nil 'noerror))
(setopt sp-base-key-bindings 'sp (setopt sp-base-key-bindings 'sp
sp-override-key-bindings '(("C-(" . sp-backward-barf-sexp) sp-override-key-bindings '(("C-(" . sp-backward-slurp-sexp)
("C-)" . sp-forward-slurp-sexp) ("C-)" . sp-forward-slurp-sexp)
("C-M-(" . sp-backward-barf-sexp) ("C-M-(" . sp-backward-barf-sexp)
("C-M-)" . sp-backward-slurp-sexp))) ("C-M-)" . sp-forward-barf-sexp)))
(dolist (hook '(conf-toml-mode-hook prog-mode-hook text-mode-hook)) (dolist (hook '(conf-toml-mode-hook prog-mode-hook text-mode-hook))
(add-hook hook #'smartparens-mode)) (add-hook hook #'smartparens-mode))
(dolist (hook '(emacs-lisp-mode-hook (dolist (hook '(emacs-lisp-mode-hook
geiser-repl-startup-hook geiser-repl-startup-hook
;; go-mode-ts-hook is not operational in Emacs-29! go-ts-mode-hook
ielm-mode-hook ielm-mode-hook
lisp-data-mode-hook lisp-data-mode-hook
lisp-mode-hook lisp-mode-hook
@ -6502,28 +6504,6 @@ instance [[https://github.com/Fanael/rainbow-delimiters#readme][rainbow-delimite
(show-smartparens-global-mode +1)) (show-smartparens-global-mode +1))
#+end_src #+end_src
#+caption[Emacs Lisp commit message helper]:
#+caption: Emacs Lisp commit message helper.
#+name: lst:org-commit-message-helper
#+begin_src emacs-lisp -n
(with-eval-after-load 'smartparens-config
(defun defun-name-to-elisp-commit ()
"Wrap the defun name for elisp commit messages to put it on the kill-ring.
BUG: `beginning-of-defun' may find any (for instance `with-eval-after-load')
toplevel sexp."
(interactive)
(save-excursion
(beginning-of-defun)
(sp-forward-symbol)
(sp-copy-sexp))
(with-temp-buffer
(insert "(")
(yank)
(insert "):")
(kill-region 1 (point)))))
#+end_src
** [[https://github.com/davidshepherd7/electric-operator#readme][Electric operators]] ** [[https://github.com/davidshepherd7/electric-operator#readme][Electric operators]]
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: sec:electric-operators :CUSTOM_ID: sec:electric-operators