From 0787500ad6a37693310f9b9289f10edc0d837423 Mon Sep 17 00:00:00 2001 From: Dominik Schrempf Date: Thu, 16 Mar 2023 20:58:32 +0100 Subject: [PATCH 1/4] latex: remove unused `sp-local-tag`s --- smartparens-latex.el | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/smartparens-latex.el b/smartparens-latex.el index 61d9a00c..27163566 100644 --- a/smartparens-latex.el +++ b/smartparens-latex.el @@ -179,13 +179,7 @@ ID, ACTION, CONTEXT." (sp-local-pair "\\lvert" "\\rvert" :when '(sp-in-math-p) :trigger "\\lvert" - :post-handlers '(sp-latex-insert-spaces-inside-pair)) - - ;; some common wrappings - (sp-local-tag "\"" "``" "''" :actions '(wrap)) - (sp-local-tag "\\b" "\\begin{_}" "\\end{_}") - (sp-local-tag "bi" "\\begin{itemize}" "\\end{itemize}") - (sp-local-tag "be" "\\begin{enumerate}" "\\end{enumerate}")) + :post-handlers '(sp-latex-insert-spaces-inside-pair))) (provide 'smartparens-latex) From c1fc35d0520edfc7eed208eb72d92f24a10d791f Mon Sep 17 00:00:00 2001 From: Dominik Schrempf Date: Thu, 16 Mar 2023 20:58:52 +0100 Subject: [PATCH 2/4] latex: format nit --- smartparens-latex.el | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/smartparens-latex.el b/smartparens-latex.el index 27163566..a91b0c41 100644 --- a/smartparens-latex.el +++ b/smartparens-latex.el @@ -88,12 +88,7 @@ ID, ACTION, CONTEXT." (add-to-list 'sp-navigate-skip-match '((tex-mode plain-tex-mode latex-mode) . sp--backslash-skip-match)) -(sp-with-modes '( - tex-mode - plain-tex-mode - latex-mode - LaTeX-mode - ) +(sp-with-modes '(tex-mode plain-tex-mode latex-mode LaTeX-mode) (sp-local-pair "`" "'" :actions '(:rem autoskip) :skip-match 'sp-latex-skip-match-apostrophe From 073fba73a7a84e427b18739c68836940ba024a9f Mon Sep 17 00:00:00 2001 From: Dominik Schrempf Date: Thu, 16 Mar 2023 21:23:05 +0100 Subject: [PATCH 3/4] latex: disable pairs that interfere with AucTeX --- smartparens-latex.el | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/smartparens-latex.el b/smartparens-latex.el index a91b0c41..60acafde 100644 --- a/smartparens-latex.el +++ b/smartparens-latex.el @@ -62,21 +62,6 @@ (goto-char (sp-get sp-last-wrapped-region :beg-in)) (insert " ")))) -(defun sp-latex-skip-match-apostrophe (ms _mb me) - "MS, MB, ME." - (when (equal ms "'") - (save-excursion - (goto-char me) - (looking-at-p "\\sw")))) - -(defun sp-latex-skip-double-quote (_id action _context) - "ID, ACTION, CONTEXT." - (when (eq action 'insert) - (when (looking-at-p "''''") - (delete-char -2) - (delete-char 2) - (forward-char 2)))) - (defun sp-latex-point-after-backslash (id action _context) "Return t if point follows a backslash, nil otherwise. This predicate is only tested on \"insert\" action. @@ -89,11 +74,9 @@ ID, ACTION, CONTEXT." '((tex-mode plain-tex-mode latex-mode) . sp--backslash-skip-match)) (sp-with-modes '(tex-mode plain-tex-mode latex-mode LaTeX-mode) - (sp-local-pair "`" "'" - :actions '(:rem autoskip) - :skip-match 'sp-latex-skip-match-apostrophe - :unless '(sp-latex-point-after-backslash sp-in-math-p)) - ;; math modes, yay. The :actions are provided automatically if + ;; Disable pairs that interfere with AucTeX. + (sp-local-pair "`" nil :actions nil) + (sp-local-pair "\"" nil :actions nil) ;; these pairs do not have global definitions. (sp-local-pair "$" "$") (sp-local-pair "\\[" "\\]" @@ -104,13 +87,6 @@ ID, ACTION, CONTEXT." (sp-local-pair "'" nil :actions nil) (sp-local-pair "\\\"" nil :actions nil) - ;; quote should insert ``'' instead of double quotes. If we ever - ;; need to insert ", C-q is our friend. - (sp-local-pair "``" "''" - :trigger "\"" - :unless '(sp-latex-point-after-backslash sp-in-math-p) - :post-handlers '(sp-latex-skip-double-quote)) - ;; add the prefix function sticking to {} pair (sp-local-pair "{" nil :prefix "\\\\\\(\\sw\\|\\s_\\)*") From f72ec8e247ae66b21778f462c4255cd22f873294 Mon Sep 17 00:00:00 2001 From: Dominik Schrempf Date: Thu, 16 Mar 2023 21:23:28 +0100 Subject: [PATCH 4/4] latex: nits --- smartparens-latex.el | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/smartparens-latex.el b/smartparens-latex.el index 60acafde..7b501fa9 100644 --- a/smartparens-latex.el +++ b/smartparens-latex.el @@ -77,25 +77,27 @@ ID, ACTION, CONTEXT." ;; Disable pairs that interfere with AucTeX. (sp-local-pair "`" nil :actions nil) (sp-local-pair "\"" nil :actions nil) + + ;; Math modes, yay. The :actions are provided automatically if ;; these pairs do not have global definitions. (sp-local-pair "$" "$") (sp-local-pair "\\[" "\\]" :unless '(sp-latex-point-after-backslash)) - ;; disable useless pairs. + ;; Disable useless pairs. (sp-local-pair "\\\\(" nil :actions nil) (sp-local-pair "'" nil :actions nil) (sp-local-pair "\\\"" nil :actions nil) - ;; add the prefix function sticking to {} pair + ;; Add the prefix function sticking to {} pair. (sp-local-pair "{" nil :prefix "\\\\\\(\\sw\\|\\s_\\)*") - ;; do not add more space when slurping + ;; Do not add more space when slurping. (sp-local-pair "{" "}") (sp-local-pair "(" ")") (sp-local-pair "[" "]") - ;; pairs for big brackets. Needs more research on what pairs are + ;; Pairs for big brackets. Needs more research on what pairs are ;; useful to add here. Post suggestions if you know some. (sp-local-pair "\\left(" "\\right)" :trigger "\\l("