Lots of refactorings and a few minor improvements.
[docutils.git] / docutils / tools / editors / emacs / tests / init.el
blobc6a9045aff8538226d76efc7d58295e48d80000b
1 ;; Initialize tests -*- lexical-binding: t -*-
3 (defun init-rst-ert (&optional with-buffer)
4 "Initialize tests.
5 Prepare for buffer using tests if WITH-BUFFER."
6 (when with-buffer
7 (add-to-list 'load-path ".")
8 (load "ert-buffer" nil t)
9 (if (equal (car load-path) ".")
10 (setq load-path (cdr load-path))))
12 (add-to-list 'load-path "..")
13 (load "rst.el" nil t)
14 (if (equal (car load-path) "..")
15 (setq load-path (cdr load-path)))
17 ;; Emacs 24 should have a patch in `testcover-after` declaring a
18 ;; `gv-expander'.
19 (if (< emacs-major-version 24)
20 ;; Define a setf-method for `testcover-after' so `ert' tests can be run
21 ;; without problems.
22 (defsetf testcover-after (idx val) (store)
23 (list 'progn
24 (list 'testcover-after idx val)
25 ;; FIXME: Though it solves the problem it is not really correct
26 ;; because `val' is only a temporary variable here.
27 (list 'setf val store)))))
29 ;; Clean up `load-path' if set caller just to load this file.
30 (if (equal (car load-path) ".")
31 (setq load-path (cdr load-path)))