Function: erts-tag-region

erts-tag-region is an interactive and byte-compiled function defined in erts-mode.el.gz.

Signature

(erts-tag-region START END NAME)

Documentation

Tag the region between START and END as a test.

Interactively, this is the region.

NAME should be a string appropriate for output by ert if the test fails. If NAME is nil or the empty string, a name will be auto-generated.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/erts-mode.el.gz
(defun erts-tag-region (start end name)
  "Tag the region between START and END as a test.
Interactively, this is the region.

NAME should be a string appropriate for output by ert if the test fails.
If NAME is nil or the empty string, a name will be auto-generated."
  (interactive "r\nsTest name: " erts-mode)
  ;; Automatically make a name.
  (when (zerop (length name))
    (save-excursion
      (goto-char (point-min))
      (let ((names nil))
        (while (re-search-forward "^Name:[ \t]*\\(.*\\)" nil t)
          (let ((name (match-string 1)))
            (unless (erts-mode--in-test-p (point))
              (push name names))))
        (setq name
              (cl-loop with base = (file-name-sans-extension (buffer-name))
                       for i from 1
                       for name = (format "%s%d" base i)
                       unless (member name names)
                       return name)))))
  (save-excursion
    (goto-char end)
    (unless (bolp)
      (insert "\n"))
    (insert "=-=-=\n")
    (goto-char start)
    (insert "Name: " name "\n\n")
    (insert "=-=\n")))