org-test: Fix <point> feature

* testing/org-test.el (org-test-with-temp-text): Fix point position.

According to the docstring, if the string "<point>" appears in TEXT
then the string "<point>" is removed and point is placed there. The
problem was that after string "<point>" was removed, the point
was *not* placed at the position of the removed text, rather, it was
placed one character before that position which is wrong. The reason
is that Emacs buffer position is a number started from 1, instead of
0, in other words, the value of `(point-min)' is 1 not 0. The problem
is addressed by adding 1 to the calculated position.

TINYCHANGE
This commit is contained in:
York Zhao 2014-04-09 13:39:16 -04:00 committed by Nicolas Goaziou
parent a768cf045d
commit d01d22b74f
1 changed files with 6 additions and 5 deletions

View File

@ -209,11 +209,12 @@ otherwise place the point at the beginning of the inserted text."
(with-temp-buffer
(org-mode)
(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)))))
(if point
(progn
(insert (replace-match "" nil nil inside-text))
(goto-char (1+ (match-beginning 0))))
(progn (insert inside-text)
(goto-char (point-min)))))
,@body)))
(def-edebug-spec org-test-with-temp-text (form body))