diff options
author | Eric Schulte <schulte.eric@gmail.com> | 2011-09-19 10:01:32 -0600 |
---|---|---|
committer | Eric Schulte <schulte.eric@gmail.com> | 2011-09-19 10:01:32 -0600 |
commit | 9da40a0d6edc7f6df2194ea92c51eb24f0ea10ad (patch) | |
tree | 2b3dffb07f4abaad96ddd13d63d6a3472ddd61b4 | |
parent | 56de2cf7a623e9d9032bd9796aac0049b1d35f77 (diff) | |
download | org-mode-9da40a0d6edc7f6df2194ea92c51eb24f0ea10ad.tar.gz |
Convenience macro for testing.
* testing/org-test.el (org-test-with-temp-text): Convenience macro for
testing.
-rw-r--r-- | testing/org-test.el | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/testing/org-test.el b/testing/org-test.el index 32f52f6..7789cbe 100644 --- a/testing/org-test.el +++ b/testing/org-test.el @@ -161,6 +161,23 @@ files." (re-search-forward (regexp-quote ,marker)) ,@body)) +(defmacro org-test-with-temp-text (text &rest body) + "Run body in a temporary buffer with Org-mode as the active +mode holding TEXT. If the string \"<point>\" appears in TEXT +then remove it and place the point there before running BODY." + (declare (indent 1)) + `(with-temp-buffer + (org-mode) + ,(let ((point (string-match (regexp-quote "<point>") text))) + (if point + `(progn + (insert `(replace-match "" nil nil text)) + (goto-char ,(match-beginning 0))) + `(progn + (insert ,text) + (goto-char (point-min))))) + ,@body)) + ;;; Navigation Functions (when (featurep 'jump) |