Skip to content

Commit ba33463

Browse files
committed
add LaTeX tests with delete-selection on
the tests fail on the current version of auctex, but pass on the most recent one following https://git.savannah.gnu.org/cgit/auctex.git/commit/?id=45ee2f.
1 parent f7cf316 commit ba33463

3 files changed

Lines changed: 81 additions & 12 deletions

File tree

smartparens.el

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2102,9 +2102,7 @@ BODY, do nothing."
21022102
;; Please contribute these if you come across some!
21032103
(defvar sp--self-insert-commands
21042104
'(self-insert-command
2105-
org-self-insert-command
2106-
LaTeX-insert-left-brace
2107-
latex-insert-left-brace)
2105+
org-self-insert-command)
21082106
"List of commands that are some sort of `self-insert-command'.
21092107

21102108
Many modes rebind \"self-inserting\" keys to \"smart\" versions
@@ -2116,14 +2114,8 @@ of pairs and wraps.")
21162114
;; Please contribute these if you come across some!
21172115
(defvar sp--special-self-insert-commands
21182116
'(
2119-
TeX-insert-dollar
2120-
TeX-insert-quote
2121-
;; At some point the TeX and LaTeX functions were renamed to
2122-
;; lower-case names. This broke some code dealing with these
2123-
;; modes, so we just add both versions for now.
2124-
tex-insert-dollar
21252117
tex-insert-quote
2126-
latex-insert-quote
2118+
TeX-insert-quote
21272119
quack-insert-opening-paren
21282120
quack-insert-closing-paren
21292121
quack-insert-opening-bracket

test/smartparens-auctex-latex-test.el

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,48 @@ thesmeves and would not break unrelated pair)"
9494
(sp-buffer-equals "$foo ``| baz$")))
9595

9696
;; #834
97-
(ert-deftest sp-test-LaTeX-wrap-with-trigger ()
97+
(ert-deftest sp-test-LaTeX-wrap-with-trigger-quote ()
9898
"A region should be wrapped with a pair if trigger key is pressed."
9999
(sp-test-with-temp-buffer "foo Mbar baz| bam"
100100
(LaTeX-mode)
101101
(execute-kbd-macro "\"")
102102
(sp-buffer-equals "foo ``bar baz''| bam")))
103+
104+
;; FIXME
105+
;; (ert-deftest sp-test-LaTeX-wrap-with-trigger-quote-delsel ()
106+
;; "A region should be wrapped with a pair if trigger key is pressed."
107+
;; (sp-test-with-delete-selection-mode
108+
;; (sp-test-with-temp-buffer "foo Mbar baz| bam"
109+
;; (LaTeX-mode)
110+
;; (execute-kbd-macro "\"")
111+
;; (sp-buffer-equals "foo ``bar baz''| bam"))))
112+
113+
(ert-deftest sp-test-LaTeX-wrap-with-trigger-backslash-paren ()
114+
"A region should be wrapped with a pair if trigger key is pressed."
115+
(sp-test-with-temp-buffer "foo |bar bazM bam"
116+
(LaTeX-mode)
117+
(execute-kbd-macro "\\(")
118+
(sp-buffer-equals "foo \\(|bar baz\\) bam")))
119+
120+
(ert-deftest sp-test-LaTeX-wrap-with-trigger-backslash-paren-delsel ()
121+
"A region should be wrapped with a pair if trigger key is pressed."
122+
(sp-test-with-delete-selection-mode
123+
(sp-test-with-temp-buffer "foo |bar bazM bam"
124+
(LaTeX-mode)
125+
(execute-kbd-macro "\\(")
126+
(sp-buffer-equals "foo \\(|bar baz\\) bam"))))
127+
128+
(ert-deftest sp-test-LaTeX-wrap-with-trigger-dollar ()
129+
"A region should be wrapped with a pair if trigger key is pressed."
130+
(sp-test-with-temp-buffer "foo |bar bazM bam"
131+
(LaTeX-mode)
132+
(execute-kbd-macro "$")
133+
(sp-buffer-equals "foo $|bar baz$ bam")))
134+
135+
(ert-deftest sp-test-LaTeX-wrap-with-trigger-dollar-delsel ()
136+
"A region should be wrapped with a pair if trigger key is pressed."
137+
(sp-test-with-delete-selection-mode
138+
(sp-test-with-temp-buffer "foo |bar bazM bam"
139+
(LaTeX-mode)
140+
(execute-kbd-macro "$")
141+
(sp-buffer-equals "foo $|bar baz$ bam"))))

test/smartparens-tex-mode-latex-test.el

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,47 @@ thesmeves and would not break unrelated pair)"
9494
(sp-buffer-equals "$foo ``| baz$")))
9595

9696
;; #834
97-
(ert-deftest sp-test-latex-wrap-with-trigger ()
97+
(ert-deftest sp-test-latex-wrap-with-trigger-quote ()
9898
"A region should be wrapped with a pair if trigger key is pressed."
9999
(sp-test-with-temp-buffer "foo Mbar baz| bam"
100100
(latex-mode)
101101
(execute-kbd-macro "\"")
102102
(sp-buffer-equals "foo ``bar baz''| bam")))
103+
104+
(ert-deftest sp-test-latex-wrap-with-trigger-quote-delsel ()
105+
"A region should be wrapped with a pair if trigger key is pressed."
106+
(sp-test-with-delete-selection-mode
107+
(sp-test-with-temp-buffer "foo Mbar baz| bam"
108+
(latex-mode)
109+
(execute-kbd-macro "\"")
110+
(sp-buffer-equals "foo ``bar baz''| bam"))))
111+
112+
(ert-deftest sp-test-latex-wrap-with-trigger-backslash-paren ()
113+
"A region should be wrapped with a pair if trigger key is pressed."
114+
(sp-test-with-temp-buffer "foo |bar bazM bam"
115+
(latex-mode)
116+
(execute-kbd-macro "\\(")
117+
(sp-buffer-equals "foo \\(|bar baz\\) bam")))
118+
119+
(ert-deftest sp-test-latex-wrap-with-trigger-backslash-paren-delsel ()
120+
"A region should be wrapped with a pair if trigger key is pressed."
121+
(sp-test-with-delete-selection-mode
122+
(sp-test-with-temp-buffer "foo |bar bazM bam"
123+
(latex-mode)
124+
(execute-kbd-macro "\\(")
125+
(sp-buffer-equals "foo \\(|bar baz\\) bam"))))
126+
127+
(ert-deftest sp-test-latex-wrap-with-trigger-dollar ()
128+
"A region should be wrapped with a pair if trigger key is pressed."
129+
(sp-test-with-temp-buffer "foo |bar bazM bam"
130+
(latex-mode)
131+
(execute-kbd-macro "$")
132+
(sp-buffer-equals "foo $|bar baz$ bam")))
133+
134+
(ert-deftest sp-test-latex-wrap-with-trigger-dollar-delsel ()
135+
"A region should be wrapped with a pair if trigger key is pressed."
136+
(sp-test-with-delete-selection-mode
137+
(sp-test-with-temp-buffer "foo |bar bazM bam"
138+
(latex-mode)
139+
(execute-kbd-macro "$")
140+
(sp-buffer-equals "foo $|bar baz$ bam"))))

0 commit comments

Comments
 (0)