summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAchim Gratz <Stromeko@Stromeko.DE>2013-11-17 21:31:03 +0100
committerAchim Gratz <Stromeko@Stromeko.DE>2014-03-25 19:11:01 +0100
commitc6e015709516437518031655caa5ba983e24b840 (patch)
tree36af2d29c0eb065dbe6c4776cf9fb1e25db31c78
parente89adba685dfe6dad4e67438930945fec8d311a3 (diff)
downloadorg-mode-c6e015709516437518031655caa5ba983e24b840.tar.gz
org-test: fix macro definitions so that eager macro expansion doesn't fail
* testing/org-test.el (org-test-with-temp-text, org-test-with-temp-text-in-file): Correct quoting of macro expansion. Macro arguments must not be used during macro expansion since they are not available at that time; conversely, bindings established during macro expansion generally can not be used at macro execution time (unless un-quoted during expansion).
-rw-r--r--testing/org-test.el29
1 files changed, 15 insertions, 14 deletions
diff --git a/testing/org-test.el b/testing/org-test.el
index e64e99b..ad70262 100644
--- a/testing/org-test.el
+++ b/testing/org-test.el
@@ -205,31 +205,32 @@ mode holding TEXT. If the string \"<point>\" appears in TEXT
then remove it and place the point there before running BODY,
otherwise place the point at the beginning of the inserted text."
(declare (indent 1))
- (let ((inside-text (if (stringp text) text (eval text))))
- `(with-temp-buffer
+ `(let ((inside-text (if (stringp ,text) ,text (eval ,text))))
+ (with-temp-buffer
(org-mode)
- ,(let ((point (string-match (regexp-quote "<point>") inside-text)))
+ (let ((point (string-match (regexp-quote "<point>") inside-text)))
(if point
- `(progn (insert `(replace-match "" nil nil inside-text))
- (goto-char ,(match-beginning 0)))
- `(progn (insert ,inside-text)
- (goto-char (point-min)))))
+ (progn (insert (replace-match "" nil nil inside-text))
+ (goto-char (match-beginning 0)))
+ (progn (insert inside-text)
+ (goto-char (point-min)))))
,@body)))
(def-edebug-spec org-test-with-temp-text (form body))
(defmacro org-test-with-temp-text-in-file (text &rest body)
"Run body in a temporary file buffer with Org-mode as the active mode."
(declare (indent 1))
- (let ((file (make-temp-file "org-test"))
- (inside-text (if (stringp text) text (eval text)))
- (results (gensym)))
- `(let ((kill-buffer-query-functions nil) ,results)
- (with-temp-file ,file (insert ,inside-text))
- (find-file ,file)
+ (let ((results (gensym)))
+ `(let ((file (make-temp-file "org-test"))
+ (kill-buffer-query-functions nil)
+ (inside-text (if (stringp ,text) ,text (eval ,text)))
+ ,results)
+ (with-temp-file file (insert inside-text))
+ (find-file file)
(org-mode)
(setq ,results (progn ,@body))
(save-buffer) (kill-buffer (current-buffer))
- (delete-file ,file)
+ (delete-file file)
,results)))
(def-edebug-spec org-test-with-temp-text-in-file (form body))