summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2021-10-01 15:38:29 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2021-10-01 15:38:35 +0200
commitdecabae2df4669da6279b0fceefb8bddffdda079 (patch)
treef9a88381d0980780dd87b0840011b701083a08dc /lisp
parentd62beccbbf5fb3dc77374e545792ae991b60aa91 (diff)
downloademacs-decabae2df4669da6279b0fceefb8bddffdda079.tar.gz
emacs-decabae2df4669da6279b0fceefb8bddffdda079.tar.bz2
emacs-decabae2df4669da6279b0fceefb8bddffdda079.zip
Fix one-clause movement in erts-mode--goto-start-of-test
* lisp/progmodes/erts-mode.el (erts-mode--goto-start-of-test): Fix so this works in one-clause tests.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/progmodes/erts-mode.el17
1 files changed, 13 insertions, 4 deletions
diff --git a/lisp/progmodes/erts-mode.el b/lisp/progmodes/erts-mode.el
index 46b6a3a711b..9d51c1f8f08 100644
--- a/lisp/progmodes/erts-mode.el
+++ b/lisp/progmodes/erts-mode.el
@@ -173,7 +173,8 @@ will be prompted for one."
(erts-mode--goto-start-of-test)
(condition-case arg
(ert-test--erts-test
- (list (cons 'dummy t) (cons 'code test-function))
+ (list (cons 'dummy t)
+ (cons 'code (car (read-from-string test-function))))
(buffer-file-name))
(:success (message "Test successful"))
(ert-test-failed (message "Test failure; result: \n%s"
@@ -183,9 +184,17 @@ will be prompted for one."
(if (not (erts-mode--in-test-p (point)))
(re-search-forward "^=-=\n" nil t)
(re-search-backward "^=-=\n" nil t)
- (when (save-match-data (erts-mode--in-test-p (point)))
- (re-search-backward "^=-=\n" nil t))
- (goto-char (match-end 0))))
+ (let ((potential-start (match-end 0)))
+ ;; See if we're in a two-clause ("before" and "after") test or not.
+ (if-let ((start (and (save-excursion (re-search-backward "^=-=\n" nil t))
+ (match-end 0))))
+ (let ((end (save-excursion (re-search-backward "^=-=-=\n" nil t))))
+ (if (or (not end)
+ (> start end))
+ ;; We are, so go to the real start.
+ (goto-char start)
+ (goto-char potential-start)))
+ (goto-char potential-start)))))
(provide 'erts-mode)