[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master f7c08c8: Make `C-c C-c' in erts-mode work with Point-Char elems
From: |
Lars Ingebrigtsen |
Subject: |
master f7c08c8: Make `C-c C-c' in erts-mode work with Point-Char elems |
Date: |
Wed, 10 Nov 2021 02:52:38 -0500 (EST) |
branch: master
commit f7c08c8b4199974825d1769faf501746a5124799
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Make `C-c C-c' in erts-mode work with Point-Char elems
* lisp/progmodes/erts-mode.el (erts-mode--preceding-spec):
Factor out into own function (bug#51680).
(erts-run-test): Respect Point-Char settings.
---
lisp/progmodes/erts-mode.el | 27 ++++++++++++++++-----------
1 file changed, 16 insertions(+), 11 deletions(-)
diff --git a/lisp/progmodes/erts-mode.el b/lisp/progmodes/erts-mode.el
index 8a271ec..a12c964 100644
--- a/lisp/progmodes/erts-mode.el
+++ b/lisp/progmodes/erts-mode.el
@@ -153,6 +153,18 @@ If NAME is nil or the empty string, a name will be
auto-generated."
(insert "Name: " name "\n\n")
(insert "=-=\n")))
+(defun erts-mode--preceding-spec (name)
+ (save-excursion
+ ;; Find the name, but skip if it's in a test.
+ (while (and (re-search-backward (format "^%s:" name) nil t)
+ (erts-mode--in-test-p (point))))
+ (and (not (erts-mode--in-test-p (point)))
+ (re-search-forward "^=-=$" nil t)
+ (progn
+ (goto-char (match-beginning 0))
+ (cdr (assq (intern (downcase name))
+ (ert--erts-specifications (point))))))))
+
(defun erts-run-test (test-function &optional verbose)
"Run the current test.
If the current erts file doesn't define a test function, the user
@@ -161,16 +173,8 @@ will be prompted for one.
If VERBOSE (interactively, the prefix), display a diff of the
expected results and the actual results in a separate buffer."
(interactive
- (list (save-excursion
- ;; Find the preceding Code spec.
- (while (and (re-search-backward "^Code:" nil t)
- (erts-mode--in-test-p (point))))
- (if (and (not (erts-mode--in-test-p (point)))
- (re-search-forward "^=-=$" nil t))
- (progn
- (goto-char (match-beginning 0))
- (cdr (assq 'code (ert--erts-specifications (point)))))
- (read-string "Transformation function: ")))
+ (list (or (erts-mode--preceding-spec "Code")
+ (read-string "Transformation function: "))
current-prefix-arg)
erts-mode)
(save-excursion
@@ -178,7 +182,8 @@ expected results and the actual results in a separate
buffer."
(condition-case arg
(ert-test--erts-test
(list (cons 'dummy t)
- (cons 'code (car (read-from-string test-function))))
+ (cons 'code (car (read-from-string test-function)))
+ (cons 'point-char (erts-mode--preceding-spec "Point-Char")))
(buffer-file-name))
(:success (message "Test successful"))
(ert-test-failed
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master f7c08c8: Make `C-c C-c' in erts-mode work with Point-Char elems,
Lars Ingebrigtsen <=