Merge branch 'master' of orgmode.org:org-mode

This commit is contained in:
Bastien Guerry 2012-01-17 08:44:38 +01:00
commit 7233671658
6 changed files with 200 additions and 78 deletions

View File

@ -46,8 +46,61 @@
<!-- automatic styles --> <!-- automatic styles -->
<office:automatic-styles> <office:automatic-styles>
<!-- Section styles -->
<style:style style:name="OrgIndentedSection-Level-1" style:family="section">
<style:section-properties text:dont-balance-text-columns="false" fo:margin-left="1.281cm" fo:margin-right="0cm" style:editable="false">
<style:columns fo:column-count="1" fo:column-gap="0cm"/>
</style:section-properties>
</style:style>
<style:style style:name="OrgIndentedSection-Level-2" style:family="section">
<style:section-properties text:dont-balance-text-columns="false" fo:margin-left="1.905cm" fo:margin-right="0cm" style:editable="false">
<style:columns fo:column-count="1" fo:column-gap="0cm"/>
</style:section-properties>
</style:style>
<style:style style:name="OrgIndentedSection-Level-3" style:family="section">
<style:section-properties text:dont-balance-text-columns="false" fo:margin-left="2.54cm" fo:margin-right="0cm" style:editable="false">
<style:columns fo:column-count="1" fo:column-gap="0cm"/>
</style:section-properties>
</style:style>
<style:style style:name="OrgIndentedSection-Level-4" style:family="section">
<style:section-properties text:dont-balance-text-columns="false" fo:margin-left="3.175cm" fo:margin-right="0cm" style:editable="false">
<style:columns fo:column-count="1" fo:column-gap="0cm"/>
</style:section-properties>
</style:style>
<style:style style:name="OrgIndentedSection-Level-5" style:family="section">
<style:section-properties text:dont-balance-text-columns="false" fo:margin-left="3.81cm" fo:margin-right="0cm" style:editable="false">
<style:columns fo:column-count="1" fo:column-gap="0cm"/>
</style:section-properties>
</style:style>
<style:style style:name="OrgIndentedSection-Level-6" style:family="section">
<style:section-properties text:dont-balance-text-columns="false" fo:margin-left="4.445cm" fo:margin-right="0cm" style:editable="false">
<style:columns fo:column-count="1" fo:column-gap="0cm"/>
</style:section-properties>
</style:style>
<style:style style:name="OrgIndentedSection-Level-7" style:family="section">
<style:section-properties text:dont-balance-text-columns="false" fo:margin-left="5.08cm" fo:margin-right="0cm" style:editable="false">
<style:columns fo:column-count="1" fo:column-gap="0cm"/>
</style:section-properties>
</style:style>
<style:style style:name="OrgIndentedSection-Level-8" style:family="section">
<style:section-properties text:dont-balance-text-columns="false" fo:margin-left="5.715cm" fo:margin-right="0cm" style:editable="false">
<style:columns fo:column-count="1" fo:column-gap="0cm"/>
</style:section-properties>
</style:style>
<style:style style:name="OrgIndentedSection-Level-9" style:family="section">
<style:section-properties text:dont-balance-text-columns="false" fo:margin-left="6.35cm" fo:margin-right="0cm" style:editable="false">
<style:columns fo:column-count="1" fo:column-gap="0cm"/>
</style:section-properties>
</style:style>
<style:style style:name="OrgIndentedSection-Level-10" style:family="section">
<style:section-properties text:dont-balance-text-columns="false" fo:margin-left="6.985cm" fo:margin-right="0cm" style:editable="false">
<style:columns fo:column-count="1" fo:column-gap="0cm"/>
</style:section-properties>
</style:style>
<!-- Table styles -->
<style:style style:name="OrgTable" style:family="table"> <style:style style:name="OrgTable" style:family="table">
<style:table-properties style:rel-width="90%" fo:margin-top="0cm" fo:margin-bottom="0.20cm" table:align="center"/> <style:table-properties style:rel-width="96%" fo:margin-top="0cm" fo:margin-bottom="0.20cm" table:align="center"/>
</style:style> </style:style>
<style:style style:name="OrgTableColumn" style:family="table-column"> <style:style style:name="OrgTableColumn" style:family="table-column">

View File

@ -251,7 +251,8 @@ inhibit insertion of results into the buffer."
(when (and org-export-babel-evaluate (when (and org-export-babel-evaluate
(not (and hash (equal hash (org-babel-current-result-hash))))) (not (and hash (equal hash (org-babel-current-result-hash)))))
(let ((lang (nth 0 info)) (let ((lang (nth 0 info))
(body (nth 1 info))) (body (nth 1 info))
(info (copy-sequence info)))
;; skip code blocks which we can't evaluate ;; skip code blocks which we can't evaluate
(when (fboundp (intern (concat "org-babel-execute:" lang))) (when (fboundp (intern (concat "org-babel-execute:" lang)))
(org-babel-eval-wipe-error-buffer) (org-babel-eval-wipe-error-buffer)

View File

@ -598,11 +598,7 @@ version."
(org-lparse-par-open-stashed 0) (org-lparse-par-open-stashed 0)
;; list related vars ;; list related vars
(org-lparse-list-level 0) ; list level starts at 1. A (org-lparse-list-stack '())
; value of 0 implies we are
; outside of any list
(org-lparse-list-item-count 0)
org-lparse-list-stack
;; list-table related vars ;; list-table related vars
org-lparse-list-table-p org-lparse-list-table-p
@ -1081,10 +1077,11 @@ version."
table-buffer (nreverse table-buffer) table-buffer (nreverse table-buffer)
table-orig-buffer (nreverse table-orig-buffer)) table-orig-buffer (nreverse table-orig-buffer))
(org-lparse-end-paragraph) (org-lparse-end-paragraph)
(when org-lparse-list-table-p
(error "Regular tables are not allowed in a list-table block"))
(org-lparse-insert 'TABLE table-buffer table-orig-buffer))) (org-lparse-insert 'TABLE table-buffer table-orig-buffer)))
;; Normal lines ;; Normal lines
(t (t
;; This line either is list item or end a list. ;; This line either is list item or end a list.
(when (get-text-property 0 'list-item line) (when (get-text-property 0 'list-item line)
@ -2104,8 +2101,6 @@ When TITLE is nil, just close all open levels."
("d" . description))))) ("d" . description)))))
;; following vars are bound during `org-do-lparse' ;; following vars are bound during `org-do-lparse'
(defvar org-lparse-list-level)
(defvar org-lparse-list-item-count)
(defvar org-lparse-list-stack) (defvar org-lparse-list-stack)
(defvar org-lparse-list-table:table-row) (defvar org-lparse-list-table:table-row)
(defvar org-lparse-list-table:lines) (defvar org-lparse-list-table:lines)
@ -2147,73 +2142,69 @@ When TITLE is nil, just close all open levels."
;; https://lists.gnu.org/archive/html/emacs-orgmode/2011-03/msg01101.html ;; https://lists.gnu.org/archive/html/emacs-orgmode/2011-03/msg01101.html
(defun org-lparse-begin-list (ltype) (defun org-lparse-begin-list (ltype)
(incf org-lparse-list-level) (push ltype org-lparse-list-stack)
(push org-lparse-list-item-count org-lparse-list-stack) (let ((list-level (length org-lparse-list-stack)))
(setq org-lparse-list-item-count 0) (cond
(cond ((not org-lparse-list-table-p)
((not org-lparse-list-table-p) (org-lparse-begin 'LIST ltype))
(org-lparse-begin 'LIST ltype)) ;; process LIST-TABLE
;; process LIST-TABLE ((= 1 list-level)
((= 1 org-lparse-list-level) ;; begin LIST-TABLE
;; begin LIST-TABLE (setq org-lparse-list-table:lines nil)
(setq org-lparse-list-table:lines nil) (setq org-lparse-list-table:table-row nil))
(setq org-lparse-list-table:table-row nil)) ((= 2 list-level)
((= 2 org-lparse-list-level) (ignore))
(ignore)) (t
(t (org-lparse-begin 'LIST ltype)))))
(org-lparse-begin 'LIST ltype))))
(defun org-lparse-end-list (ltype) (defun org-lparse-end-list (ltype)
(setq org-lparse-list-item-count (pop org-lparse-list-stack)) (pop org-lparse-list-stack)
(decf org-lparse-list-level) (let ((list-level (length org-lparse-list-stack)))
(cond (cond
((not org-lparse-list-table-p) ((not org-lparse-list-table-p)
(org-lparse-end 'LIST ltype)) (org-lparse-end 'LIST ltype))
;; process LIST-TABLE ;; process LIST-TABLE
((= 0 org-lparse-list-level) ((= 0 list-level)
;; end LIST-TABLE ;; end LIST-TABLE
(insert (org-lparse-format-list-table (insert (org-lparse-format-list-table
(nreverse org-lparse-list-table:lines)))) (nreverse org-lparse-list-table:lines))))
((= 1 org-lparse-list-level) ((= 1 list-level)
(ignore)) (ignore))
(t (t
(org-lparse-end 'LIST ltype)))) (org-lparse-end 'LIST ltype)))))
(defun org-lparse-begin-list-item (ltype &optional arg headline) (defun org-lparse-begin-list-item (ltype &optional arg headline)
(incf org-lparse-list-item-count) (let ((list-level (length org-lparse-list-stack)))
(cond (cond
((not org-lparse-list-table-p) ((not org-lparse-list-table-p)
(org-lparse-begin 'LIST-ITEM ltype arg headline)) (org-lparse-begin 'LIST-ITEM ltype arg headline))
;; process LIST-TABLE ;; process LIST-TABLE
((and (= 1 org-lparse-list-level) ((= 1 list-level)
(= 1 org-lparse-list-item-count)) ;; begin TABLE-ROW for LIST-TABLE
;; begin TABLE-ROW for LIST-TABLE (setq org-lparse-list-table:table-row nil)
(setq org-lparse-list-table:table-row nil) (org-lparse-begin-list-table:table-cell))
(org-lparse-begin-list-table:table-cell)) ((= 2 list-level)
((and (= 2 org-lparse-list-level) ;; begin TABLE-CELL for LIST-TABLE
(= 1 org-lparse-list-item-count)) (org-lparse-begin-list-table:table-cell))
;; begin TABLE-CELL for LIST-TABLE (t
(org-lparse-begin-list-table:table-cell)) (org-lparse-begin 'LIST-ITEM ltype arg headline)))))
(t
(org-lparse-begin 'LIST-ITEM ltype arg headline))))
(defun org-lparse-end-list-item (ltype) (defun org-lparse-end-list-item (ltype)
(decf org-lparse-list-item-count) (let ((list-level (length org-lparse-list-stack)))
(cond (cond
((not org-lparse-list-table-p) ((not org-lparse-list-table-p)
(org-lparse-end 'LIST-ITEM ltype)) (org-lparse-end 'LIST-ITEM ltype))
;; process LIST-TABLE ;; process LIST-TABLE
((and (= 1 org-lparse-list-level) ((= 1 list-level)
(= 0 org-lparse-list-item-count)) ;; end TABLE-ROW for LIST-TABLE
;; end TABLE-ROW for LIST-TABLE (org-lparse-end-list-table:table-cell)
(org-lparse-end-list-table:table-cell) (push (nreverse org-lparse-list-table:table-row)
(push (nreverse org-lparse-list-table:table-row) org-lparse-list-table:lines))
org-lparse-list-table:lines)) ((= 2 list-level)
((= 2 org-lparse-list-level) ;; end TABLE-CELL for LIST-TABLE
;; end TABLE-CELL for LIST-TABLE (org-lparse-end-list-table:table-cell))
(org-lparse-end-list-table:table-cell)) (t
(t (org-lparse-end 'LIST-ITEM ltype)))))
(org-lparse-end 'LIST-ITEM ltype))))
(defvar org-lparse-list-table:table-cell-open) (defvar org-lparse-list-table:table-cell-open)
(defun org-lparse-begin-list-table:table-cell () (defun org-lparse-begin-list-table:table-cell ()

View File

@ -646,6 +646,15 @@ PUB-DIR is set, use this as the publishing directory."
(defun org-odt-end-outline-text () (defun org-odt-end-outline-text ()
(ignore)) (ignore))
(defvar org-odt-section-count 0)
(defun org-odt-begin-section (style &optional name)
(setq name (or name (format "Section-%d" (incf org-odt-section-count))))
(org-lparse-insert-tag
"<text:section text:style-name=\"%s\" text:name=\"%s\">" style name))
(defun org-odt-end-section ()
(org-lparse-insert-tag "</text:section>"))
(defun org-odt-begin-paragraph (&optional style) (defun org-odt-begin-paragraph (&optional style)
(org-lparse-insert-tag (org-lparse-insert-tag
"<text:p%s>" (org-odt-get-extra-attrs-for-paragraph-style style))) "<text:p%s>" (org-odt-get-extra-attrs-for-paragraph-style style)))
@ -729,13 +738,17 @@ PUB-DIR is set, use this as the publishing directory."
(list)) (list))
(t (error "Unknown environment %s" style)))) (t (error "Unknown environment %s" style))))
(defvar org-lparse-list-level) ; dynamically bound in org-do-lparse (defvar org-lparse-list-stack) ; dynamically bound in org-do-lparse
(defvar org-odt-list-stack-stashed)
(defun org-odt-begin-list (ltype) (defun org-odt-begin-list (ltype)
(setq ltype (or (org-lparse-html-list-type-to-canonical-list-type ltype) (setq ltype (or (org-lparse-html-list-type-to-canonical-list-type ltype)
ltype)) ltype))
(let* ((style-name (org-odt-get-style-name-for-entity 'list ltype)) (let* ((style-name (org-odt-get-style-name-for-entity 'list ltype))
(extra (concat (when (= org-lparse-list-level 1) (extra (concat (if (or org-lparse-list-table-p
" text:continue-numbering=\"false\"") (and (= 1 (length org-lparse-list-stack))
(null org-odt-list-stack-stashed)))
" text:continue-numbering=\"false\""
" text:continue-numbering=\"true\"")
(when style-name (when style-name
(format " text:style-name=\"%s\"" style-name))))) (format " text:style-name=\"%s\"" style-name)))))
(case ltype (case ltype
@ -758,11 +771,15 @@ PUB-DIR is set, use this as the publishing directory."
(ordered (ordered
(assert (not headline) t) (assert (not headline) t)
(let* ((counter arg) (extra "")) (let* ((counter arg) (extra ""))
(org-lparse-insert-tag "<text:list-item>") (org-lparse-insert-tag (if (= (length org-lparse-list-stack)
(length org-odt-list-stack-stashed))
"<text:list-header>" "<text:list-item>"))
(org-lparse-begin-paragraph))) (org-lparse-begin-paragraph)))
(unordered (unordered
(let* ((id arg) (extra "")) (let* ((id arg) (extra ""))
(org-lparse-insert-tag "<text:list-item>") (org-lparse-insert-tag (if (= (length org-lparse-list-stack)
(length org-odt-list-stack-stashed))
"<text:list-header>" "<text:list-item>"))
(org-lparse-begin-paragraph) (org-lparse-begin-paragraph)
(insert (if headline (org-odt-format-target headline id) (insert (if headline (org-odt-format-target headline id)
(org-odt-format-bookmark "" id))))) (org-odt-format-bookmark "" id)))))
@ -783,13 +800,30 @@ PUB-DIR is set, use this as the publishing directory."
ltype)) ltype))
(case ltype (case ltype
((ordered unordered) ((ordered unordered)
(org-lparse-insert-tag "</text:list-item>")) (org-lparse-insert-tag (if (= (length org-lparse-list-stack)
(length org-odt-list-stack-stashed))
(prog1 "</text:list-header>"
(setq org-odt-list-stack-stashed nil))
"</text:list-item>")))
(description (description
(org-lparse-end-list-item-1) (org-lparse-end-list-item-1)
(org-lparse-end-list 'description) (org-lparse-end-list 'description)
(org-lparse-end-list-item-1)) (org-lparse-end-list-item-1))
(t (error "Unknown list type")))) (t (error "Unknown list type"))))
(defun org-odt-discontinue-list ()
(let ((stashed-stack org-lparse-list-stack))
(loop for list-type in stashed-stack
do (org-lparse-end-list-item-1 list-type)
(org-lparse-end-list list-type))
(setq org-odt-list-stack-stashed stashed-stack)))
(defun org-odt-continue-list ()
(setq org-odt-list-stack-stashed (nreverse org-odt-list-stack-stashed))
(loop for list-type in org-odt-list-stack-stashed
do (org-lparse-begin-list list-type)
(org-lparse-begin-list-item list-type)))
;; Following variables are let bound when table emission is in ;; Following variables are let bound when table emission is in
;; progress. See org-lparse.el. ;; progress. See org-lparse.el.
(defvar org-lparse-table-begin-marker) (defvar org-lparse-table-begin-marker)
@ -897,7 +931,19 @@ style from the list."
:key-type symbol :key-type symbol
:value-type (const :tag "True" t)))))) :value-type (const :tag "True" t))))))
(defvar org-odt-table-indentedp nil)
(defun org-odt-begin-table (caption label attributes) (defun org-odt-begin-table (caption label attributes)
(setq org-odt-table-indentedp (not (null org-lparse-list-stack)))
(when org-odt-table-indentedp
;; Within the Org file, the table is appearing within a list item.
;; OpenDocument doesn't allow table to appear within list items.
;; Temporarily terminate the list, emit the table and then
;; re-continue the list.
(org-odt-discontinue-list)
;; Put the Table in an indented section.
(let ((level (length org-odt-list-stack-stashed)))
(org-odt-begin-section (format "OrgIndentedSection-Level-%d" level))))
(setq org-odt-table-style attributes) (setq org-odt-table-style attributes)
(setq org-odt-table-style-spec (setq org-odt-table-style-spec
(assoc org-odt-table-style org-export-odt-table-styles)) (assoc org-odt-table-style org-export-odt-table-styles))
@ -940,7 +986,10 @@ style from the list."
((equal spec "table-cell:style-name") ((equal spec "table-cell:style-name")
(replace-match table-cell-style t t)))))) (replace-match table-cell-style t t))))))
(goto-char (point-max)) (goto-char (point-max))
(org-lparse-insert-tag "</table:table>")) (org-lparse-insert-tag "</table:table>")
(when org-odt-table-indentedp
(org-odt-end-section)
(org-odt-continue-list)))
(defun org-odt-begin-table-rowgroup (&optional is-header-row) (defun org-odt-begin-table-rowgroup (&optional is-header-row)
(when org-lparse-table-rowgrp-open (when org-lparse-table-rowgrp-open
@ -2053,7 +2102,9 @@ 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-entity-counts-plist nil) org-odt-entity-counts-plist nil)
content-file)) content-file))

View File

@ -288,3 +288,22 @@ exporting a code block with a name
#+begin_src sh :foo "baz" #+begin_src sh :foo "baz"
echo bar echo bar
#+end_src #+end_src
* noweb no-export and exports both
:PROPERTIES:
:ID: 8a820f6c-7980-43db-8a24-0710d33729c9
:END:
Weird interaction.
here is one block
#+name: noweb-no-export-and-exports-both-1
#+BEGIN_SRC sh :exports none
echo 1
#+END_SRC
and another
#+BEGIN_SRC sh :noweb no-export :exports both
# I am inside the code block
<<noweb-no-export-and-exports-both-1>>
#+END_SRC

View File

@ -217,6 +217,13 @@ elements in the final html."
(should (string-match "baz" ascii)) (should (string-match "baz" ascii))
(should (string-match "replace" ascii)))))) (should (string-match "replace" ascii))))))
(ert-deftest ob-exp/noweb-no-export-and-exports-both ()
(org-test-at-id "8a820f6c-7980-43db-8a24-0710d33729c9"
(org-narrow-to-subtree)
(let ((html (org-export-as-html nil nil nil 'string 'body-only)))
(should (string-match (regexp-quote "noweb-no-export-and-exports-both-1")
html)))))
(provide 'test-ob-exp) (provide 'test-ob-exp)
;;; test-ob-exp.el ends here ;;; test-ob-exp.el ends here