Merge branch 'origin-maint'

Conflicts:
	contrib/lisp/org-mac-link-grabber.el
	doc/org.texi
	lisp/org-odt.el
	testing/lisp/test-ob.el
This commit is contained in:
Eric Schulte 2012-02-19 09:36:13 -07:00
commit 3de3c470d8
2 changed files with 191 additions and 49 deletions

View File

@ -46,6 +46,18 @@
(goto-char org-lparse-dyn-first-heading-pos))) (goto-char org-lparse-dyn-first-heading-pos)))
(insert (org-odt-format-toc))) (insert (org-odt-format-toc)))
(defun org-odt-insert-toc ()
(goto-char (point-min))
(cond
((re-search-forward
"\\(<text:p [^>]*>\\)?\\s-*\\[TABLE-OF-CONTENTS\\]\\s-*\\(</text:p>\\)?"
nil t)
(goto-char (match-beginning 0))
(replace-match ""))
(t
(goto-char org-lparse-dyn-first-heading-pos))
(insert (org-odt-format-toc))))
(defun org-odt-end-export () (defun org-odt-end-export ()
(org-odt-insert-toc) (org-odt-insert-toc)
(org-odt-fixup-label-references) (org-odt-fixup-label-references)
@ -2169,6 +2181,7 @@ CATEGORY-HANDLE is used. See
(setq org-odt-manifest-file-entries nil (setq org-odt-manifest-file-entries nil
org-odt-embedded-images-count 0 org-odt-embedded-images-count 0
org-odt-embedded-formulas-count 0 org-odt-embedded-formulas-count 0
org-odt-section-count 0
org-odt-entity-labels-alist nil org-odt-entity-labels-alist nil
org-odt-list-stack-stashed nil org-odt-list-stack-stashed nil
org-odt-automatic-styles nil org-odt-automatic-styles nil

View File

@ -869,65 +869,194 @@ Line 3\"
test-line test-line
(forward-char 1) (forward-char 1)
(org-ctrl-c-ctrl-c) (org-ctrl-c-ctrl-c)
(should (string= (concat test-line " =\"x\"=") (should (re-search-forward "\\#\\+results:" nil t))
(buffer-substring-no-properties (forward-line)
(point-min) (point-max))))))) (should
(string=
""
(buffer-substring-no-properties (point-at-bol) (point-at-eol))))))
(org-test-with-temp-text-in-file "
#+begin_src emacs-lisp
\"some text\";;
#+end_src"
(ert-deftest test-org-babel/inline-src-block-preceded-by-equality () (progn
(let ((test-line "=src_emacs-lisp[ :results verbatim ]{ \"x\" }")) (org-babel-next-src-block)
(org-test-with-temp-text
test-line
(forward-char 1)
(org-ctrl-c-ctrl-c) (org-ctrl-c-ctrl-c)
(should (string= (concat test-line " =\"x\"=") (should (re-search-forward "\\#\\+results:" nil t))
(buffer-substring-no-properties (forward-line)
(point-min) (point-max))))))) (should
(string=
": some text"
(buffer-substring-no-properties (point-at-bol) (point-at-eol)))))))
(ert-deftest test-org-babel/inline-src-block-enclosed-within-parenthesis () (ert-deftest test-ob/commented-last-block-line-with-var ()
(let ((test-line "(src_emacs-lisp[ :results verbatim ]{ \"x\" }")) (org-test-with-temp-text-in-file "
(org-test-with-temp-text #+begin_src emacs-lisp :var a=1
(concat test-line ")") ;;
(forward-char 1) #+end_src"
(progn
(org-babel-next-src-block)
(org-ctrl-c-ctrl-c) (org-ctrl-c-ctrl-c)
(should (string= (concat test-line " =\"x\"=)" ) (re-search-forward "\\#\\+results:" nil t)
(buffer-substring-no-properties (forward-line)
(point-min) (point-max))))))) (should (string=
""
(ert-deftest test-org-babel/inline-src-block-enclosed-within-parenthesis () (buffer-substring-no-properties (point-at-bol) (point-at-eol))))))
(let ((test-line "{src_emacs-lisp[ :results verbatim ]{ \"x\" }")) (org-test-with-temp-text-in-file "
(org-test-with-temp-text #+begin_src emacs-lisp :var a=2
(concat test-line "}") 2;;
(forward-char 1) #+end_src"
(progn
(org-babel-next-src-block)
(org-ctrl-c-ctrl-c) (org-ctrl-c-ctrl-c)
(should (string= (concat test-line " =\"x\"=}") (re-search-forward "\\#\\+results:" nil t)
(buffer-substring-no-properties (forward-line)
(point-min) (point-max))))))) (should (string=
": 2"
(buffer-substring-no-properties (point-at-bol) (point-at-eol)))))))
(ert-deftest test-org-babel/inline-src_blk-preceded-by-letter () (defun test-ob-verify-result-and-removed-result (result buffer-text)
"Test inline source block invalid where preceded by letter" "Test helper function to test `org-babel-remove-result'.
A temp buffer is populated with BUFFER-TEXT, the first block is executed,
and the result of execution is verified against RESULT.
;; inline-src-blk preceded by letter The block is actually executed /twice/ to ensure result
replacement happens correctly."
(org-test-with-temp-text (org-test-with-temp-text
"asrc_emacs-lisp[ :results verbatim ]{ \"x\" }" buffer-text
(forward-char 1) (progn
(let ((error-result (org-babel-next-src-block) (org-ctrl-c-ctrl-c) (org-ctrl-c-ctrl-c)
(should-error (should (re-search-forward "\\#\\+results:" nil t))
(org-ctrl-c-ctrl-c)))) (forward-line)
(should (equal `(error "C-c C-c can do nothing useful at this location") (should (string= result
error-result))))) (buffer-substring-no-properties
(point-at-bol)
(- (point-max) 16))))
(org-babel-previous-src-block) (org-babel-remove-result)
(should (string= buffer-text
(buffer-substring-no-properties
(point-min) (point-max)))))))
(ert-deftest test-org-babel/inline-src_blk-preceded-by-number () (ert-deftest test-ob/org-babel-remove-result--results-default ()
"Test inline source block invalid where preceded by number" "Test `org-babel-remove-result' with default :results."
(mapcar (lambda (language)
(test-ob-verify-result-and-removed-result
"\n"
(concat
"* org-babel-remove-result
#+begin_src " language "
#+end_src
;; inline-src-blk preceded by number * next heading")))
(org-test-with-temp-text '("sh" "emacs-lisp")))
"0src_emacs-lisp[ :results verbatim ]{ \"x\" }"
(forward-char 1) (ert-deftest test-ob/org-babel-remove-result--results-list ()
(let ((error-result "Test `org-babel-remove-result' with :results list."
(should-error (test-ob-verify-result-and-removed-result
(org-ctrl-c-ctrl-c)))) "- 1
(should (equal `(error "C-c C-c can do nothing useful at this location") - 2
error-result))))) - 3
- (quote (4 5))"
"* org-babel-remove-result
#+begin_src emacs-lisp :results list
'(1 2 3 '(4 5))
#+end_src
* next heading"))
(ert-deftest test-ob/org-babel-remove-result--results-wrap ()
"Test `org-babel-remove-result' with :results wrap."
(test-ob-verify-result-and-removed-result
":RESULTS:
hello there
:END:"
"* org-babel-remove-result
#+begin_src emacs-lisp :results wrap
\"hello there\"
#+end_src
* next heading"))
(ert-deftest test-ob/org-babel-remove-result--results-org ()
"Test `org-babel-remove-result' with :results org."
(test-ob-verify-result-and-removed-result
"#+BEGIN_ORG
* heading
** subheading
content
#+END_ORG"
"* org-babel-remove-result
#+begin_src emacs-lisp :results org
\"* heading
** subheading
content\"
#+end_src
* next heading"))
(ert-deftest test-ob/org-babel-remove-result--results-html ()
"Test `org-babel-remove-result' with :results html."
(test-ob-verify-result-and-removed-result
"#+BEGIN_HTML
<head><body></body></head>
#+END_HTML"
"* org-babel-remove-result
#+begin_src emacs-lisp :results html
\"<head><body></body></head>\"
#+end_src
* next heading"))
(ert-deftest test-ob/org-babel-remove-result--results-latex ()
"Test `org-babel-remove-result' with :results latex."
(test-ob-verify-result-and-removed-result
"#+BEGIN_LaTeX
Line 1
Line 2
Line 3
#+END_LaTeX"
"* org-babel-remove-result
#+begin_src emacs-lisp :results latex
\"Line 1
Line 2
Line 3\"
#+end_src
* next heading"))
(ert-deftest test-ob/org-babel-remove-result--results-code ()
"Test `org-babel-remove-result' with :results code."
(test-ob-verify-result-and-removed-result
"#+BEGIN_SRC emacs-lisp
\"I am working!\"
#+END_SRC"
"* org-babel-remove-result
#+begin_src emacs-lisp :results code
(message \"I am working!\")
#+end_src
* next heading"))
(ert-deftest test-ob/org-babel-remove-result--results-pp ()
"Test `org-babel-remove-result' with :results pp."
(test-ob-verify-result-and-removed-result
": \"I /am/ working!\""
"* org-babel-remove-result
#+begin_src emacs-lisp :results pp
\"I /am/ working!\")
#+end_src
* next heading"))
(provide 'test-ob) (provide 'test-ob)