From a611170b5772efa6be1937c4d237f241fe407f97 Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Thu, 1 Sep 2011 12:03:33 -0600 Subject: [PATCH 01/47] ob-R: improve prompt detection regexp. Thanks to the users of ess-tracebug for this new regexp * lisp/ob-R.el (org-babel-R-evaluate-session): Improve prompt detection regexp. --- lisp/ob-R.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/ob-R.el b/lisp/ob-R.el index 396949757..09c895016 100644 --- a/lisp/ob-R.el +++ b/lisp/ob-R.el @@ -294,7 +294,7 @@ last statement in BODY, as elisp." (mapcar (lambda (line) ;; cleanup extra prompts left in output (if (string-match - "^\\([ ]*[>+][ ]?\\)+\\([[0-9]+\\|[ ]\\)" line) + "^\\([ ]*[>+\\.][ ]?\\)+\\([[0-9]+\\|[ ]\\)" line) (substring line (match-end 1)) line)) (org-babel-comint-with-output (session org-babel-R-eoe-output) From 30aa8f61dafb7d105d61954737b72d4bb11d4ce0 Mon Sep 17 00:00:00 2001 From: Jambunathan K Date: Thu, 1 Sep 2011 22:26:17 +0530 Subject: [PATCH 02/47] Revert "Introduce org-odt-begin-table-cell and org-odt-end-table-cell" This reverts commit e887881e1302a9bba8fda296ec8b4723269b2a76. Keep things simple for now. --- contrib/lisp/org-lparse.el | 9 +-------- contrib/lisp/org-odt.el | 32 ++++++++------------------------ 2 files changed, 9 insertions(+), 32 deletions(-) diff --git a/contrib/lisp/org-lparse.el b/contrib/lisp/org-lparse.el index 48eb60bd1..fac221da6 100755 --- a/contrib/lisp/org-lparse.el +++ b/contrib/lisp/org-lparse.el @@ -693,12 +693,6 @@ and then converted to \"doc\" then org-lparse-backend is set to (defvar org-lparse-to-buffer nil "Bind this to TO-BUFFER arg of `org-lparse'.") -(defvar org-lparse-current-paragraph-style nil - "Default paragraph style to use. -Exporter sets or resets this as it enters and leaves special -contexts. Currently this is used for formatting of paragraphs -that are part of table-cells created from list-tables.") - (defun org-do-lparse (arg &optional hidden ext-plist to-buffer body-only pub-dir) "Export the outline to various formats. @@ -728,7 +722,6 @@ version." ; collecting styles org-lparse-encode-pending org-lparse-par-open - org-lparse-current-paragraph-style org-lparse-list-table-p (org-lparse-list-level 0) ; list level starts at 1. A ; value of 0 implies we are @@ -1274,7 +1267,7 @@ version." ;; kill collection buffer (when org-lparse-collect-buffer (kill-buffer org-lparse-collect-buffer)) - + (goto-char (point-min)) (or (org-export-push-to-kill-ring (upcase (symbol-name org-lparse-backend))) diff --git a/contrib/lisp/org-odt.el b/contrib/lisp/org-odt.el index a7e6950f2..f36e684fa 100644 --- a/contrib/lisp/org-odt.el +++ b/contrib/lisp/org-odt.el @@ -383,8 +383,6 @@ PUB-DIR is set, use this as the publishing directory." . (org-odt-begin-table org-odt-end-table)) (TABLE-ROWGROUP . (org-odt-begin-table-rowgroup org-odt-end-table-rowgroup)) - (TABLE-CELL - . (org-odt-begin-table-cell org-odt-end-table-cell)) (LIST . (org-odt-begin-list org-odt-end-list)) (LIST-ITEM @@ -524,10 +522,7 @@ PUB-DIR is set, use this as the publishing directory." (defun org-odt-end-outline-text () (ignore)) -(defvar org-lparse-current-paragraph-style) ; bound during - ; `org-do-lparse' (defun org-odt-begin-paragraph (&optional style) - (setq style (or style org-lparse-current-paragraph-style)) (org-lparse-insert-tag "" (org-odt-get-extra-attrs-for-paragraph-style style))) @@ -548,8 +543,7 @@ PUB-DIR is set, use this as the publishing directory." (defun org-odt-format-stylized-paragraph (style text) (org-odt-format-tags '("" . "") text - (org-odt-get-extra-attrs-for-paragraph-style - (or style org-lparse-current-paragraph-style)))) + (org-odt-get-extra-attrs-for-paragraph-style style))) (defun org-odt-begin-environment (style) (case style @@ -728,26 +722,16 @@ PUB-DIR is set, use this as the publishing directory." (when org-lparse-table-is-styled (format "@@table-cell:style-name@@%03d@@%03d@@" r c))) -(defun org-odt-begin-table-cell (r c) - (setq org-lparse-current-paragraph-style - (org-odt-get-paragraph-style-cookie-for-table-cell r c)) - (let* ((style-name-cookie +(defun org-odt-format-table-cell (data r c) + (let* ((paragraph-style-cookie + (org-odt-get-paragraph-style-cookie-for-table-cell r c)) + (style-name-cookie (org-odt-get-style-name-cookie-for-table-cell r c)) (extra (if style-name-cookie (format " table:style-name=\"%s\"" style-name-cookie) ""))) - (org-lparse-insert-tag "" extra))) - -(defun org-odt-end-table-cell () - (org-lparse-insert-tag "") - (setq org-lparse-current-paragraph-style nil)) - -(defun org-odt-format-table-cell (data r c) - (with-temp-buffer - (org-odt-begin-table-cell r c) - (insert (org-odt-format-stylized-paragraph - org-lparse-current-paragraph-style data)) - (org-odt-end-table-cell) - (buffer-string))) + (org-odt-format-tags + '("" . "") + (org-odt-format-stylized-paragraph paragraph-style-cookie data) extra))) (defun org-odt-begin-footnote-definition (n) (org-lparse-begin-paragraph 'footnote)) From 74e78a145669aba89b894ebac6f2f486afdf09b4 Mon Sep 17 00:00:00 2001 From: Jambunathan K Date: Thu, 1 Sep 2011 23:41:26 +0530 Subject: [PATCH 03/47] org-lparse.el: Support for list-tables (first cut) * contrib/lisp/org-lparse.el (org-lparse-list-table:table-cell-open): New variable. (org-lparse-begin-list-table:table-cell) (org-lparse-end-list-table:table-cell): New routines. Use `org-lparse-begin-collect' and `org-lparse-end-collect' to get a string representation of a multi-line table cell. (org-lparse-list-table-p, org-lparse-list-level) (org-lparse-list-item-count, org-lparse-list-stack) (org-lparse-list-table:table-cell-open) (org-lparse-list-table:table-row) (org-lparse-list-table:lines): New variables to keep track of the state of the list at a point in time during export. (org-do-lparse): Init above variables. (org-lparse-begin-list, org-lparse-end-list) (org-lparse-begin-list-item, org-lparse-end-list-item): Modified so that list marked as list-table are exported as a table. Refer notes in the file for more information. (org-lparse-do-format-list-table): Make sure that `org-table' is loaded. * contrib/lisp/org-odt.el (org-odt-format-table-cell): Table cells are list-tables are already paragraphs. No need to enclose them in paragraphs again. --- contrib/lisp/org-lparse.el | 137 +++++++++++++++++++++++++++++++++++-- contrib/lisp/org-odt.el | 3 +- 2 files changed, 132 insertions(+), 8 deletions(-) diff --git a/contrib/lisp/org-lparse.el b/contrib/lisp/org-lparse.el index fac221da6..56af33ea1 100755 --- a/contrib/lisp/org-lparse.el +++ b/contrib/lisp/org-lparse.el @@ -722,10 +722,20 @@ version." ; collecting styles org-lparse-encode-pending org-lparse-par-open - org-lparse-list-table-p + + ;; list related vars (org-lparse-list-level 0) ; list level starts at 1. A ; value of 0 implies we are ; outside of any list + (org-lparse-list-item-count 0) + org-lparse-list-stack + + ;; list-table related vars + org-lparse-list-table-p + org-lparse-list-table:table-cell-open + org-lparse-list-table:table-row + org-lparse-list-table:lines + org-lparse-outline-text-open (org-lparse-latex-fragment-fallback ; currently used only by ; odt exporter @@ -1267,7 +1277,7 @@ version." ;; kill collection buffer (when org-lparse-collect-buffer (kill-buffer org-lparse-collect-buffer)) - + (goto-char (point-min)) (or (org-export-push-to-kill-ring (upcase (symbol-name org-lparse-backend))) @@ -1389,6 +1399,8 @@ for formatting. This is required for the DocBook exporter." (defun org-lparse-do-format-list-table (lines &optional splice caption label attributes head org-lparse-table-colalign-info) + (or (featurep 'org-table) ; required for + (require 'org-table)) ; `org-table-number-regexp' (let* ((org-lparse-table-rownum -1) org-lparse-table-ncols i (cnt 0) tbopen fields line org-lparse-table-cur-rowgrp-is-hdr @@ -2184,20 +2196,131 @@ When TITLE is nil, just close all open levels." ("u" . unordered) ("d" . description))))) -(defvar org-lparse-list-level) ; dynamically bound in 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-table:table-row) +(defvar org-lparse-list-table:lines) + +;; Notes on LIST-TABLES +;; ==================== +;; When `org-lparse-list-table-enable' is non-nil, the following list +;; +;; #+begin_list-table +;; - Row 1 +;; - 1.1 +;; - 1.2 +;; - 1.3 +;; - Row 2 +;; - 2.1 +;; - 2.2 +;; - 2.3 +;; #+end_list-table +;; +;; will be exported as though it were a table as shown below. +;; +;; | Row 1 | 1.1 | 1.2 | 1.3 | +;; | Row 2 | 2.1 | 2.2 | 2.3 | +;; +;; Note that org-tables are NOT multi-line and each line is mapped to +;; a unique row in the exported document. So if an exported table +;; needs to contain a single paragraph (with copious text) it needs to +;; be typed up in a single line. Editing such long lines using the +;; table editor will be a cumbersome task. Furthermore inclusion of +;; multi-paragraph text in a table cell is well-nigh impossible. +;; +;; LIST-TABLEs are meant to circumvent the above problems with +;; org-tables. +;; +;; Note that in the example above the list items could be paragraphs +;; themselves and the list can be arbitrarily deep. +;; +;; Inspired by following thread: +;; https://lists.gnu.org/archive/html/emacs-orgmode/2011-03/msg01101.html + (defun org-lparse-begin-list (ltype) (incf org-lparse-list-level) - (org-lparse-begin 'LIST ltype)) + (push org-lparse-list-item-count org-lparse-list-stack) + (setq org-lparse-list-item-count 0) + (cond + ((not org-lparse-list-table-p) + (org-lparse-begin 'LIST ltype)) + ;; process LIST-TABLE + ((= 1 org-lparse-list-level) + ;; begin LIST-TABLE + (setq org-lparse-list-table:lines nil) + (setq org-lparse-list-table:table-row nil)) + ((= 2 org-lparse-list-level) + (ignore)) + (t + (org-lparse-begin 'LIST ltype)))) (defun org-lparse-end-list (ltype) + (setq org-lparse-list-item-count (pop org-lparse-list-stack)) (decf org-lparse-list-level) - (org-lparse-end 'LIST ltype)) + (cond + ((not org-lparse-list-table-p) + (org-lparse-end 'LIST ltype)) + ;; process LIST-TABLE + ((= 0 org-lparse-list-level) + ;; end LIST-TABLE + (insert (org-lparse-format-list-table + (nreverse org-lparse-list-table:lines)))) + ((= 1 org-lparse-list-level) + (ignore)) + (t + (org-lparse-end 'LIST ltype)))) (defun org-lparse-begin-list-item (ltype &optional arg headline) - (org-lparse-begin 'LIST-ITEM ltype arg headline)) + (incf org-lparse-list-item-count) + (cond + ((not org-lparse-list-table-p) + (org-lparse-begin 'LIST-ITEM ltype arg headline)) + ;; process LIST-TABLE + ((and (= 1 org-lparse-list-level) + (= 1 org-lparse-list-item-count)) + ;; begin TABLE-ROW for LIST-TABLE + (setq org-lparse-list-table:table-row nil) + (org-lparse-begin-list-table:table-cell)) + ((and (= 2 org-lparse-list-level) + (= 1 org-lparse-list-item-count)) + ;; begin TABLE-CELL for LIST-TABLE + (org-lparse-begin-list-table:table-cell)) + (t + (org-lparse-begin 'LIST-ITEM ltype arg headline)))) (defun org-lparse-end-list-item (ltype) - (org-lparse-end 'LIST-ITEM ltype)) + (decf org-lparse-list-item-count) + (cond + ((not org-lparse-list-table-p) + (org-lparse-end 'LIST-ITEM ltype)) + ;; process LIST-TABLE + ((and (= 1 org-lparse-list-level) + (= 0 org-lparse-list-item-count)) + ;; end TABLE-ROW for LIST-TABLE + (org-lparse-end-list-table:table-cell) + (push (nreverse org-lparse-list-table:table-row) + org-lparse-list-table:lines)) + ((= 2 org-lparse-list-level) + ;; end TABLE-CELL for LIST-TABLE + (org-lparse-end-list-table:table-cell)) + (t + (org-lparse-end 'LIST-ITEM ltype)))) + +(defvar org-lparse-list-table:table-cell-open) +(defun org-lparse-begin-list-table:table-cell () + (org-lparse-end-list-table:table-cell) + (setq org-lparse-list-table:table-cell-open t) + (org-lparse-begin-collect) + (org-lparse-begin-paragraph)) + +(defun org-lparse-end-list-table:table-cell () + (when org-lparse-list-table:table-cell-open + (setq org-lparse-list-table:table-cell-open nil) + (org-lparse-end-paragraph) + (push (org-lparse-end-collect) + org-lparse-list-table:table-row))) (defvar org-lparse-table-rowgrp-info) (defun org-lparse-begin-table-rowgroup (&optional is-header-row) diff --git a/contrib/lisp/org-odt.el b/contrib/lisp/org-odt.el index f36e684fa..7f7435e77 100644 --- a/contrib/lisp/org-odt.el +++ b/contrib/lisp/org-odt.el @@ -731,7 +731,8 @@ PUB-DIR is set, use this as the publishing directory." (format " table:style-name=\"%s\"" style-name-cookie) ""))) (org-odt-format-tags '("" . "") - (org-odt-format-stylized-paragraph paragraph-style-cookie data) extra))) + (if org-lparse-list-table-p data + (org-odt-format-stylized-paragraph paragraph-style-cookie data)) extra))) (defun org-odt-begin-footnote-definition (n) (org-lparse-begin-paragraph 'footnote)) From c51b7cfd40d8d9b1e65f21053dc62948cce72d55 Mon Sep 17 00:00:00 2001 From: Jambunathan K Date: Fri, 2 Sep 2011 00:18:43 +0530 Subject: [PATCH 04/47] org-xhtml.el: Fix a crash during export of list-tables * contrib/lisp/org-xhtml.el (org-xhtml-end-table): During export of list-tables, `org-xhtml-format-table-no-css' is not bound. In such cases pretend that it's value is nil. --- contrib/lisp/org-xhtml.el | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/contrib/lisp/org-xhtml.el b/contrib/lisp/org-xhtml.el index c5813a69e..9e5f324de 100644 --- a/contrib/lisp/org-xhtml.el +++ b/contrib/lisp/org-xhtml.el @@ -1524,7 +1524,8 @@ lang=\"%s\" xml:lang=\"%s\"> "") (let* ((align (aref org-lparse-table-colalign-vector c)) - (alignspec (if org-xhtml-format-table-no-css + (alignspec (if (and (boundp 'org-xhtml-format-table-no-css) + org-xhtml-format-table-no-css) " align=\"%s\"" " class=\"%s\"")) (extra (format alignspec align))) (format "" extra)) @@ -1541,8 +1542,9 @@ lang=\"%s\" xml:lang=\"%s\"> (let ((c (string-to-number (match-string 1)))) (replace-match (if org-export-xhtml-table-align-individual-fields - (format (if org-xhtml-format-table-no-css " align=\"%s\"" - " class=\"%s\"") + (format (if (and (boundp 'org-xhtml-format-table-no-css) + org-xhtml-format-table-no-css) + " align=\"%s\"" " class=\"%s\"") (or (aref org-lparse-table-colalign-vector c) "left")) "") t t))) (goto-char (point-max))) From d85635306b11e4a5549303cce9eea3dc91c83d11 Mon Sep 17 00:00:00 2001 From: Jambunathan K Date: Fri, 2 Sep 2011 14:27:31 +0530 Subject: [PATCH 05/47] org-lparse.el: Abort export if list-tables are malformed * contrib/lisp/org-lparse.el (org-lparse-format-table-row): In list-tables, require that the header row be a row with max number of columns. Abort export if this condition is not met. --- contrib/lisp/org-lparse.el | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/contrib/lisp/org-lparse.el b/contrib/lisp/org-lparse.el index 56af33ea1..9a33cb92b 100755 --- a/contrib/lisp/org-lparse.el +++ b/contrib/lisp/org-lparse.el @@ -2049,7 +2049,12 @@ See `org-xhtml-entity-format-callbacks-alist' for more information." lines) (defun org-lparse-format-table-row (fields &optional text-for-empty-fields) - (unless org-lparse-table-ncols + (if org-lparse-table-ncols + ;; second and subsequent rows of the table + (when (and org-lparse-list-table-p + (> (length fields) org-lparse-table-ncols)) + (error "Table row has %d columns but header row claims %d columns" + (length fields) org-lparse-table-ncols)) ;; first row of the table (setq org-lparse-table-ncols (length fields)) (when org-lparse-table-is-styled From 4a8634e1a53c7771db33a31b5f1570e6a0e4e36f Mon Sep 17 00:00:00 2001 From: Martin Rudalics Date: Fri, 2 Sep 2011 18:18:56 +0200 Subject: [PATCH 06/47] org-compat.el: Remove LABEL argument from pop-to-buffer-same-window call. * org-compat.el (org-pop-to-buffer-same-window): Remove LABEL argument from pop-to-buffer-same-window call. --- lisp/org-compat.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/org-compat.el b/lisp/org-compat.el index 3e9c202d2..3577db695 100644 --- a/lisp/org-compat.el +++ b/lisp/org-compat.el @@ -438,7 +438,7 @@ With two arguments, return floor and remainder of their quotient." "Pop to buffer specified by BUFFER-OR-NAME in the selected window." (if (fboundp 'pop-to-buffer-same-window) (funcall - 'pop-to-buffer-same-window buffer-or-name norecord label) + 'pop-to-buffer-same-window buffer-or-name norecord) (funcall 'switch-to-buffer buffer-or-name norecord))) (provide 'org-compat) From 235e993ae66f0f54b51f8214db043c5b53ff150d Mon Sep 17 00:00:00 2001 From: David Maus Date: Sun, 28 Aug 2011 16:03:38 +0200 Subject: [PATCH 07/47] Provide edebug spec for with-org-lparse-preserve-paragraph-state * contrib/lisp/org-lparse.el (with-org-lparse-preserve-paragraph-state): Provide edebug spec. --- contrib/lisp/org-lparse.el | 1 + 1 file changed, 1 insertion(+) diff --git a/contrib/lisp/org-lparse.el b/contrib/lisp/org-lparse.el index 9a33cb92b..6e391c88f 100755 --- a/contrib/lisp/org-lparse.el +++ b/contrib/lisp/org-lparse.el @@ -335,6 +335,7 @@ OPT-PLIST is the export options list." ,@body (when org-lparse-do-open-par (org-lparse-begin-paragraph)))) +(def-edebug-spec with-org-lparse-preserve-paragraph-state (body)) (defvar org-lparse-native-backends nil "List of native backends registered with `org-lparse'. From ff4af45e687cadb77d5784e756126187052e720c Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sun, 4 Sep 2011 16:45:39 +0200 Subject: [PATCH 08/47] org-footnote: no footnote in latex fragments * lisp/org-footnote.el (org-footnote-in-valid-context-p): No footnote in latex fragments. --- lisp/org-footnote.el | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lisp/org-footnote.el b/lisp/org-footnote.el index 04389efad..7ef433bfa 100644 --- a/lisp/org-footnote.el +++ b/lisp/org-footnote.el @@ -52,6 +52,7 @@ (declare-function org-in-indented-comment-line "org" ()) (declare-function org-in-regexp "org" (re &optional nlines visually)) (declare-function org-in-verbatim-emphasis "org" ()) +(declare-function org-inside-LaTeX-fragment-p "org" ()) (declare-function org-inside-latex-macro-p "org" ()) (declare-function org-mark-ring-push "org" (&optional pos buffer)) (declare-function org-show-context "org" (&optional key)) @@ -178,6 +179,7 @@ extracted will be filled again." (save-match-data (not (or (org-in-commented-line) (org-in-indented-comment-line) + (org-inside-LaTeX-fragment-p) ;; Avoid protected environments (LaTeX export) (get-text-property (point) 'org-protected) ;; Avoid literal example. From 0b6de9a026f7995cc684c7a68cb71d603684eb34 Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Sun, 4 Sep 2011 10:50:37 -0600 Subject: [PATCH 09/47] corrected file insertion for inline results * lisp/ob.el (org-babel-insert-result): Corrected file insertion for inline results. --- lisp/ob.el | 1 + 1 file changed, 1 insertion(+) diff --git a/lisp/ob.el b/lisp/ob.el index 74432e7b5..6fe597a4e 100644 --- a/lisp/ob.el +++ b/lisp/ob.el @@ -1632,6 +1632,7 @@ code ---- the results are extracted in the syntax of the source '(:fmt (lambda (cell) (format "%s" cell)))) "\n")) (goto-char beg) (when (org-at-table-p) (org-table-align))) ((member "file" result-params) + (when inlinep (goto-char inlinep)) (insert result)) (t (goto-char beg) (insert result))) (when (listp result) (goto-char (org-table-end))) From 0d580520cc438659bab67004bf1789b2305f6d58 Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Sun, 4 Sep 2011 17:06:07 -0600 Subject: [PATCH 10/47] better code block demarcation * lisp/ob.el (org-babel-demarcate-block): Copy headers and indent to column of point when a block is split. --- lisp/ob.el | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lisp/ob.el b/lisp/ob.el index 6fe597a4e..e424ff1df 100644 --- a/lisp/ob.el +++ b/lisp/ob.el @@ -1334,6 +1334,8 @@ is created. In both cases if the region is demarcated and if the region is not active then the point is demarcated." (interactive "P") (let ((info (org-babel-get-src-block-info 'light)) + (headers (progn (org-babel-where-is-src-block-head) + (match-string 4))) (stars (concat (make-string (or (org-current-level) 1) ?*) " "))) (if info (mapc @@ -1346,11 +1348,16 @@ region is not active then the point is demarcated." (buffer-substring (point-at-bol) (point-at-eol))) (delete-region (point-at-bol) (point-at-eol))) - (insert (concat (if (looking-at "^") "" "\n") - indent "#+end_src\n" - (if arg stars indent) "\n" - indent "#+begin_src " lang - (if (looking-at "[\n\r]") "" "\n"))))) + (insert (concat + (if (looking-at "^") "" "\n") + indent "#+end_src\n" + (if arg stars indent) "\n" + indent "#+begin_src " lang + (if (> (length headers) 1) + (concat " " headers) headers) + (if (looking-at "[\n\r]") + "" + (concat "\n" (make-string (current-column) ? ))))))) (move-end-of-line 2)) (sort (if (region-active-p) (list (mark) (point)) (list (point))) #'>)) (let ((start (point)) From c08183d0434aae24f6f4627c221778402718d2ac Mon Sep 17 00:00:00 2001 From: Jambunathan K Date: Mon, 5 Sep 2011 11:17:10 +0530 Subject: [PATCH 11/47] org-odt.el: Create and update meta.xml towards end of the export * contrib/lisp/org-odt.el (org-odt-init-outfile): Don't create meta.xml here. (org-odt-update-meta-file): Create and update meta.xml here instead. Note that this routine gets called just before the component files are zipped. (org-export-odt-meta-lines): Remove it. Not needed any longer. (org-odt-save-as-outfile): No need to create backup files while saving xml buffers. --- contrib/lisp/org-odt.el | 78 ++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 44 deletions(-) diff --git a/contrib/lisp/org-odt.el b/contrib/lisp/org-odt.el index 7f7435e77..8fc24814c 100644 --- a/contrib/lisp/org-odt.el +++ b/contrib/lisp/org-odt.el @@ -1287,17 +1287,6 @@ MAY-INLINE-P allows inlining it as an image." "" "") . (""))) -(defconst org-export-odt-meta-lines - '(("" - "" - " ") . (" " ""))) - (defun org-odt-copy-image-file (path &optional target-file) "Returns the internal name of the file" (let* ((image-type (file-name-extension path)) @@ -1433,14 +1422,6 @@ MAY-INLINE-P allows inlining it as an image." (save-excursion (insert (mapconcat 'identity (cdr org-export-odt-manifest-lines) "\n")))) - ;; meta file - (with-current-buffer (find-file-noselect meta-file t) - (erase-buffer) - (insert (mapconcat 'identity (car org-export-odt-meta-lines) "\n")) - (insert "\n") - (save-excursion - (insert (mapconcat 'identity (cdr org-export-odt-meta-lines) "\n")))) - ;; mimetype (with-current-buffer (find-file-noselect mimetype-file t) (insert "application/vnd.oasis.opendocument.text")) @@ -1512,7 +1493,7 @@ visually." ;; prettify output if needed (when org-export-odt-prettify-xml (indent-region (point-min) (point-max))) - (save-buffer))) + (save-buffer 0))) org-export-odt-save-list) (let* ((target-name (file-name-nondirectory target)) @@ -1575,31 +1556,40 @@ visually." (format-time-string "%Y-%m-%dT%T%:z"))))) (defun org-odt-update-meta-file (opt-plist) - (with-current-buffer - (find-file-noselect (expand-file-name "meta.xml") t) - (let ((date (org-odt-format-date (plist-get opt-plist :date))) - (author (or (plist-get opt-plist :author) "")) - (email (plist-get opt-plist :email)) - (keywords (plist-get opt-plist :keywords)) - (description (plist-get opt-plist :description)) - (title (plist-get opt-plist :title))) + (let ((date (org-odt-format-date (plist-get opt-plist :date))) + (author (or (plist-get opt-plist :author) "")) + (email (plist-get opt-plist :email)) + (keywords (plist-get opt-plist :keywords)) + (description (plist-get opt-plist :description)) + (title (plist-get opt-plist :title))) - (insert - "\n" - (org-odt-format-tags '("" . "") author) - (org-odt-format-tags - '("\n" . "") author) - (org-odt-format-tags '("\n" . "") date) - (org-odt-format-tags - '("\n" . "") date) - (org-odt-format-tags '("\n" . "") - (when org-export-creator-info - (format "Org-%s/Emacs-%s" - org-version emacs-version))) - (org-odt-format-tags '("\n" . "") keywords) - (org-odt-format-tags '("\n" . "") description) - (org-odt-format-tags '("\n" . "") title) - "\n")))) + (write-region + (concat + " + + " "\n" + (org-odt-format-tags '("" . "") author) + (org-odt-format-tags + '("\n" . "") author) + (org-odt-format-tags '("\n" . "") date) + (org-odt-format-tags + '("\n" . "") date) + (org-odt-format-tags '("\n" . "") + (when org-export-creator-info + (format "Org-%s/Emacs-%s" + org-version emacs-version))) + (org-odt-format-tags '("\n" . "") keywords) + (org-odt-format-tags '("\n" . "") description) + (org-odt-format-tags '("\n" . "") title) + "\n" + " " "") + nil (expand-file-name "meta.xml")))) (defun org-odt-update-manifest-file (media-type full-path) (with-current-buffer From 82cf5d59e7ee391101ff696bf27b7cfa2b1dcae2 Mon Sep 17 00:00:00 2001 From: Jambunathan K Date: Mon, 5 Sep 2011 11:33:20 +0530 Subject: [PATCH 12/47] org-odt.el: Create mimetype file towards the end of export * contrib/lisp/org-odt.el (org-odt-init-outfile): Don't create mimetype file here. (org-odt-save-as-outfile): Create mimetype file here. Note that this routine gets called towards the end of the export just before files are zipped. --- contrib/lisp/org-odt.el | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/contrib/lisp/org-odt.el b/contrib/lisp/org-odt.el index 8fc24814c..3dfc01817 100644 --- a/contrib/lisp/org-odt.el +++ b/contrib/lisp/org-odt.el @@ -1422,10 +1422,6 @@ MAY-INLINE-P allows inlining it as an image." (save-excursion (insert (mapconcat 'identity (cdr org-export-odt-manifest-lines) "\n")))) - ;; mimetype - (with-current-buffer (find-file-noselect mimetype-file t) - (insert "application/vnd.oasis.opendocument.text")) - ;; styles file ;; (copy-file org-export-odt-styles-file styles-file t) @@ -1451,6 +1447,10 @@ visually." (defvar hfy-user-sheet-assoc) ; bound during org-do-lparse (defun org-odt-save-as-outfile (target opt-plist) + ;; create mimetype file + (write-region "application/vnd.oasis.opendocument.text" nil + (expand-file-name "mimetype")) + ;; write meta file (org-odt-update-meta-file opt-plist) From 0c48918be551e0aac1ed4787a4211a825d545763 Mon Sep 17 00:00:00 2001 From: Jambunathan K Date: Mon, 5 Sep 2011 11:53:00 +0530 Subject: [PATCH 13/47] org-odt.el: Trivial cleanup * contrib/lisp/org-odt.el (org-export-odt-nosave-list): Remove a useless variable. (org-odt-init-outfile): Propagate above change. --- contrib/lisp/org-odt.el | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/contrib/lisp/org-odt.el b/contrib/lisp/org-odt.el index 3dfc01817..60a5a96e3 100644 --- a/contrib/lisp/org-odt.el +++ b/contrib/lisp/org-odt.el @@ -1272,9 +1272,6 @@ MAY-INLINE-P allows inlining it as an image." (defconst org-export-odt-save-list '("mimetype" "META-INF/manifest.xml" "content.xml" "meta.xml" "styles.xml")) -;; xml files that are copied -(defconst org-export-odt-nosave-list '()) - ;; xml files that contribute to the final odt file (defvar org-export-odt-file-list nil) @@ -1429,8 +1426,7 @@ MAY-INLINE-P allows inlining it as an image." (make-directory pictures-dir) ;; initialize list of files that contribute to the odt file - (setq org-export-odt-file-list - (append org-export-odt-save-list org-export-odt-nosave-list))) + (setq org-export-odt-file-list org-export-odt-save-list)) content-file)) (defconst org-odt-manifest-file-entry-tag From 933e508e0516d3969e2165bd4c39ab63560e1e7e Mon Sep 17 00:00:00 2001 From: Jambunathan K Date: Mon, 5 Sep 2011 23:30:14 +0530 Subject: [PATCH 14/47] org-odt.el: Create and update manifest.xml towards end of export * contrib/lisp/org-odt.el (org-export-odt-manifest-lines): Removed. (org-odt-update-manifest-file): Removed. (org-odt-create-manifest-file-entry) (org-odt-write-manifest-file): New function. (org-odt-manifest-file-entries): New variable. (org-odt-manifest-file-entry-tag): Updated. (org-odt-init-outfile): Don't create manifest.xml here. Don't create Pictures directory so early in the export. Reset `org-odt-manifest-file-entries'. (org-odt-save-as-outfile): Modified. Use `org-odt-create-manifest-file-entry' and `org-odt-write-manifest-file'. (org-odt-copy-image-file, org-odt-update-meta-file) (org-odt-copy-styles-file): Use `org-odt-create-manifest-file-entry'. Rationalized creation of Manifest file entries. New entries are created right at the point where new files are added to the odt file. --- contrib/lisp/org-odt.el | 98 +++++++++++++++++++++++++---------------- 1 file changed, 61 insertions(+), 37 deletions(-) diff --git a/contrib/lisp/org-odt.el b/contrib/lisp/org-odt.el index 60a5a96e3..37d33d4a1 100644 --- a/contrib/lisp/org-odt.el +++ b/contrib/lisp/org-odt.el @@ -1275,15 +1275,6 @@ MAY-INLINE-P allows inlining it as an image." ;; xml files that contribute to the final odt file (defvar org-export-odt-file-list nil) -(defconst org-export-odt-manifest-lines - '(("" - "" - "" - "" - "" - "" - "") . (""))) - (defun org-odt-copy-image-file (path &optional target-file) "Returns the internal name of the file" (let* ((image-type (file-name-extension path)) @@ -1297,9 +1288,18 @@ MAY-INLINE-P allows inlining it as an image." (when (not org-lparse-to-buffer) (message "Embedding %s as %s ..." (substring-no-properties path) target-file) - (copy-file src-file target-file 'overwrite) - (org-odt-update-manifest-file media-type target-file) - (push target-file org-export-odt-file-list)) target-file)) + + ;; create Pictures dir if needed + (let ((pictures-dir (file-name-directory target-file))) + (unless (file-directory-p pictures-dir) + (make-directory pictures-dir) + (org-odt-create-manifest-file-entry "" pictures-dir))) + + ;; copy image file + (unless (file-readable-p target-file) + (copy-file src-file target-file 'overwrite) + (org-odt-create-manifest-file-entry media-type target-file) + (push target-file org-export-odt-file-list))) target-file)) (defun org-odt-image-attrs-from-size (&optional width height) (concat @@ -1410,28 +1410,14 @@ MAY-INLINE-P allows inlining it as an image." ;; FIXME: How to factor in body-only here (unless body-only - ;; manifest file - (make-directory (file-name-directory manifest-file)) - (with-current-buffer (find-file-noselect manifest-file t) - (erase-buffer) - (insert (mapconcat 'identity (car org-export-odt-manifest-lines) "\n")) - (insert "\n") - (save-excursion - (insert (mapconcat 'identity (cdr org-export-odt-manifest-lines) "\n")))) + ;; initialize list of files that contribute to the odt file + (setq org-export-odt-file-list org-export-odt-save-list)) - ;; styles file - ;; (copy-file org-export-odt-styles-file styles-file t) + ;; no manifest file entries for now + (setq org-odt-manifest-file-entries nil) - ;; Pictures dir - (make-directory pictures-dir) - - ;; initialize list of files that contribute to the odt file - (setq org-export-odt-file-list org-export-odt-save-list)) content-file)) -(defconst org-odt-manifest-file-entry-tag - "") - (defcustom org-export-odt-prettify-xml nil "Specify whether or not the xml output should be prettified. When this option is turned on, `indent-region' is run on all @@ -1479,6 +1465,15 @@ visually." (format " %s\n" (cddr style))) hfy-user-sheet-assoc "")) + ;; create a manifest entry for content.xml + (org-odt-create-manifest-file-entry + "application/vnd.oasis.opendocument.text" "/" "1.2") + + (org-odt-create-manifest-file-entry "text/xml" "content.xml") + + ;; write out the manifest entries before zipping + (org-odt-write-manifest-file) + (let ((zipdir default-directory)) (message "Switching to directory %s" (expand-file-name zipdir)) @@ -1551,6 +1546,34 @@ visually." ;; ISO 8601 format (format-time-string "%Y-%m-%dT%T%:z"))))) +(defconst org-odt-manifest-file-entry-tag + " +") + +(defvar org-odt-manifest-file-entries nil) + +(defun org-odt-create-manifest-file-entry (&rest args) + (push args org-odt-manifest-file-entries)) + +(defun org-odt-write-manifest-file () + (make-directory "META-INF") + (let ((manifest-file (expand-file-name "META-INF/manifest.xml"))) + (write-region + " + \n" + nil manifest-file) + (mapc + (lambda (file-entry) + (let* ((version (nth 2 file-entry)) + (extra (if version + (format " manifest:version=\"%s\"" version) + ""))) + (write-region + (format org-odt-manifest-file-entry-tag + (nth 0 file-entry) (nth 1 file-entry) extra) + nil manifest-file t))) org-odt-manifest-file-entries) + (write-region "\n" nil manifest-file t))) + (defun org-odt-update-meta-file (opt-plist) (let ((date (org-odt-format-date (plist-get opt-plist :date))) (author (or (plist-get opt-plist :author) "")) @@ -1585,12 +1608,10 @@ visually." (org-odt-format-tags '("\n" . "") title) "\n" " " "") - nil (expand-file-name "meta.xml")))) + nil (expand-file-name "meta.xml"))) -(defun org-odt-update-manifest-file (media-type full-path) - (with-current-buffer - (find-file-noselect (expand-file-name "META-INF/manifest.xml") t) - (insert (format org-odt-manifest-file-entry-tag media-type full-path)))) + ;; create a manifest entry for meta.xml + (org-odt-create-manifest-file-entry "text/xml" "meta.xml")) (defun org-odt-finalize-outfile () (org-odt-delete-empty-paragraphs)) @@ -1731,7 +1752,7 @@ visually." (when (org-file-image-p member) (let* ((image-type (file-name-extension member)) (media-type (format "image/%s" image-type))) - (org-odt-update-manifest-file media-type member)))) + (org-odt-create-manifest-file-entry media-type member)))) members))) ((and (stringp styles-file) (file-exists-p styles-file)) (let ((styles-file-type (file-name-extension styles-file))) @@ -1742,7 +1763,10 @@ visually." (org-odt-zip-extract styles-file "styles.xml"))))) (t (error (format "Invalid specification of styles.xml file: %S" - org-export-odt-styles-file))))) + org-export-odt-styles-file)))) + + ;; create a manifest entry for styles.xml + (org-odt-create-manifest-file-entry "text/xml" "styles.xml")) (defvar org-export-odt-factory-settings "d4328fb9d1b6cb211d4320ff546829f26700dc5e" From d7d052ec7ccb1e5530f80d32f9ce60a28b061ba6 Mon Sep 17 00:00:00 2001 From: Martyn Jago Date: Mon, 5 Sep 2011 22:53:07 +0100 Subject: [PATCH 15/47] Bug fixes to inline source block execution triggering. * lisp/ob.el: Created org-babel-get-inline-src-block-matches() to fix problems with org-ctrl-c-ctrl-c not triggering inline src block execution when point is on or after a space within the inline src block body. Also fixed execution problems where inline src block is on buffer line 1. * testing/examples/babel.org: Test data for org-babel-get-inline-src-block-matches() * testing/lisp/test-ob.el: Tests for org-babel-get-inline-src-block-matches() --- lisp/ob.el | 48 ++++++++++++++++++++++++++++++-------- testing/examples/babel.org | 9 +++++++ testing/lisp/test-ob.el | 23 ++++++++++++++++++ 3 files changed, 70 insertions(+), 10 deletions(-) diff --git a/lisp/ob.el b/lisp/ob.el index e424ff1df..2964f825b 100644 --- a/lisp/ob.el +++ b/lisp/ob.el @@ -159,6 +159,39 @@ not match KEY should be returned." (lambda (p) (when (funcall (if others #'not #'identity) (eq (car p) key)) p)) params))) +(defun org-babel-get-inline-src-block-matches() + "Set match data if within body of an inline source block. +Returns non-nil if match-data set" + (let ((src-at-0-p (save-excursion + (beginning-of-line 1) + (string= "src" (thing-at-point 'word)))) + (first-line-p (= 1 (line-number-at-pos))) + (orig (point))) + (let ((search-for (cond (src-at-0-p "src_") + (first-line-p " src_") + (t "[ \f\t\n\r\v]src_"))) + (lower-limit (if (= 1 (line-number-at-pos)) + nil + (- (point-at-bol) 1)))) + (save-excursion + (when (or (and src-at-0-p (bobp)) + (and (re-search-forward "}" (point-at-eol) t) + (re-search-backward search-for lower-limit t) + (> orig (point)))) + (when (looking-at org-babel-inline-src-block-regexp) + t )))))) + +(defun org-babel-get-lob-one-liner-matches() + "Set match data if on line of an lob one liner. +Returns non-nil if match-data set" + + (save-excursion + (unless (= (point) (point-at-bol)) ;; move before inline block + (re-search-backward "[ \f\t\n\r\v]" nil t)) + (if (looking-at org-babel-inline-lob-one-liner-regexp) + t + nil))) + (defun org-babel-get-src-block-info (&optional light) "Get information on the current source block. @@ -191,8 +224,7 @@ Returns a list (org-babel-ref-split-args (match-string 6))) (nth 2 info)))))) ;; inline source block - (when (save-excursion (re-search-backward "[ \f\t\n\r\v]" nil t) - (looking-at org-babel-inline-src-block-regexp)) + (when (org-babel-get-inline-src-block-matches) (setq info (org-babel-parse-inline-src-block-match)))) ;; resolve variable references and add summary parameters (when (and info (not light)) @@ -1387,10 +1419,8 @@ following the source block." (let* ((on-lob-line (save-excursion (beginning-of-line 1) (looking-at org-babel-lob-one-liner-regexp))) - (inlinep (save-excursion - (re-search-backward "[ \f\t\n\r\v]" nil t) - (when (looking-at org-babel-inline-src-block-regexp) - (match-end 0)))) + (inlinep (when (org-babel-get-inline-src-block-matches) + (match-end 0))) (name (if on-lob-line (nth 0 (org-babel-lob-get-info)) (nth 4 (or info (org-babel-get-src-block-info 'light))))) @@ -1578,10 +1608,8 @@ code ---- the results are extracted in the syntax of the source (save-excursion (let* ((inlinep (save-excursion - (unless (= (point) (point-at-bol)) ;; move before inline block - (re-search-backward "[ \f\t\n\r\v]" nil t)) - (when (or (looking-at org-babel-inline-src-block-regexp) - (looking-at org-babel-inline-lob-one-liner-regexp)) + (when (or (org-babel-get-inline-src-block-matches) + (org-babel-get-lob-one-liner-matches)) (goto-char (match-end 0)) (insert (if (listp result) "\n" " ")) (point)))) diff --git a/testing/examples/babel.org b/testing/examples/babel.org index 3dc603dd6..f85e1f089 100644 --- a/testing/examples/babel.org +++ b/testing/examples/babel.org @@ -279,3 +279,12 @@ this is simple :ID: d4faa7b3-072b-4dcf-813c-dd7141c633f3 :END: has length 14 +* org-babel-get-inline-src-block-matches + :PROPERTIES: + :results: silent + :ID: 0D0983D4-DE33-400A-8A05-A225A567BC74 + :END: +src_sh{echo "One"} block at start of line + One spaced block in src_sh{ echo "middle" } of line +src_sh{echo 2} blocks on the src_emacs-lisp{"same"} line + Inline block with src_sh[:results silent]{ echo "parameters" }. diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el index dbc7dbdfa..71ea7e2f7 100644 --- a/testing/lisp/test-ob.el +++ b/testing/lisp/test-ob.el @@ -223,6 +223,29 @@ (next) (should (equal 2 (org-babel-execute-src-block))) (next) (should (equal 3 (org-babel-execute-src-block)))))) +(ert-deftest test-org-babel/org-babel-get-inline-src-block-matches () + (org-test-at-id "0D0983D4-DE33-400A-8A05-A225A567BC74" + (should (fboundp 'org-babel-get-inline-src-block-matches)) + (should (re-search-forward "src_" nil t)) ;; 1 + (should (= 6132 (match-end 0))) + (should (org-babel-get-inline-src-block-matches)) + (should (re-search-forward "}" nil (point-at-bol))) ;; 1 + (should-not (org-babel-get-inline-src-block-matches)) + (should (re-search-forward "in" nil t)) ;; 2 + (should-not (org-babel-get-inline-src-block-matches)) + (should (re-search-forward "echo" nil t)) ;; 2 + (should (org-babel-get-inline-src-block-matches)) + (should (re-search-forward "blocks" nil t)) ;; 3 + (left-char 8) ;; 3 + (should (org-babel-get-inline-src-block-matches)) + (right-char 1) ;;3 + (should-not (org-babel-get-inline-src-block-matches)) + (should (re-search-forward ":results" nil t)) ;; 4 + (should (org-babel-get-inline-src-block-matches)) + (end-of-line) + (should-not (org-babel-get-inline-src-block-matches)) + )) + (provide 'test-ob) ;;; test-ob ends here From 223ac134862826d4aad0b1ef485148394703ce07 Mon Sep 17 00:00:00 2001 From: Martyn Jago Date: Tue, 6 Sep 2011 09:00:24 +0100 Subject: [PATCH 16/47] Inline source block and test fixes * lisp/ob.el: Fixed late night refactoring error * testing/examples/babel.org: whitespace * testing/lisp/test-ob.el: Fixed test-org-babel/inline-src-block-regexp (regression error) Renamed test-org-babel/parse-header-args2 since duplicate test heading Made test-org-babel/parse-header-args less brittle --- lisp/ob.el | 8 +++---- testing/examples/babel.org | 1 + testing/lisp/test-ob.el | 45 +++++++++++++++++++------------------- 3 files changed, 28 insertions(+), 26 deletions(-) diff --git a/lisp/ob.el b/lisp/ob.el index 2964f825b..d6b0ba350 100644 --- a/lisp/ob.el +++ b/lisp/ob.el @@ -166,11 +166,11 @@ Returns non-nil if match-data set" (beginning-of-line 1) (string= "src" (thing-at-point 'word)))) (first-line-p (= 1 (line-number-at-pos))) - (orig (point))) - (let ((search-for (cond (src-at-0-p "src_") - (first-line-p " src_") + (orig (point))) + (let ((search-for (cond ((and src-at-0-p first-line-p "src_")) + (first-line-p "[ \t]src_") (t "[ \f\t\n\r\v]src_"))) - (lower-limit (if (= 1 (line-number-at-pos)) + (lower-limit (if first-line-p nil (- (point-at-bol) 1)))) (save-excursion diff --git a/testing/examples/babel.org b/testing/examples/babel.org index f85e1f089..5b7f2eff8 100644 --- a/testing/examples/babel.org +++ b/testing/examples/babel.org @@ -279,6 +279,7 @@ this is simple :ID: d4faa7b3-072b-4dcf-813c-dd7141c633f3 :END: has length 14 + * org-babel-get-inline-src-block-matches :PROPERTIES: :results: silent diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el index 71ea7e2f7..f9884ddcd 100644 --- a/testing/lisp/test-ob.el +++ b/testing/lisp/test-ob.el @@ -108,7 +108,7 @@ (ert-deftest test-org-babel/inline-src-block-regexp () - (should(equal (concat "[^-[:alnum:]]\\(src_\\([^ \f\t\n\r\v]+\\)" + (should(equal (concat "\\(?:^\\|[^-[:alnum:]]\\)\\(src_\\([^ \f\t\n\r\v]+\\)" "\\(\\|\\[\\(.*?\\)\\]\\)" "{\\([^\f\n\r\v]+?\\)}\\)") org-babel-inline-src-block-regexp)) @@ -206,7 +206,7 @@ (should(equal '(:result-type . output) (assoc :result-type params))) (should(equal '(num . 9) (cdr (assoc :var params))))))) -(ert-deftest test-org-babel/parse-header-args () +(ert-deftest test-org-babel/parse-header-args2 () (org-test-at-id "2409e8ba-7b5f-4678-8888-e48aa02d8cb4" (should (string-match (regexp-quote "this is simple") (org-babel-ref-resolve "simple-subtree"))) @@ -225,26 +225,27 @@ (ert-deftest test-org-babel/org-babel-get-inline-src-block-matches () (org-test-at-id "0D0983D4-DE33-400A-8A05-A225A567BC74" - (should (fboundp 'org-babel-get-inline-src-block-matches)) - (should (re-search-forward "src_" nil t)) ;; 1 - (should (= 6132 (match-end 0))) - (should (org-babel-get-inline-src-block-matches)) - (should (re-search-forward "}" nil (point-at-bol))) ;; 1 - (should-not (org-babel-get-inline-src-block-matches)) - (should (re-search-forward "in" nil t)) ;; 2 - (should-not (org-babel-get-inline-src-block-matches)) - (should (re-search-forward "echo" nil t)) ;; 2 - (should (org-babel-get-inline-src-block-matches)) - (should (re-search-forward "blocks" nil t)) ;; 3 - (left-char 8) ;; 3 - (should (org-babel-get-inline-src-block-matches)) - (right-char 1) ;;3 - (should-not (org-babel-get-inline-src-block-matches)) - (should (re-search-forward ":results" nil t)) ;; 4 - (should (org-babel-get-inline-src-block-matches)) - (end-of-line) - (should-not (org-babel-get-inline-src-block-matches)) - )) + (let ((test-point (point))) + (should (fboundp 'org-babel-get-inline-src-block-matches)) + (should (re-search-forward "src_" nil t)) ;; 1 + (should (= (+ test-point 140) (match-end 0))) + (should (org-babel-get-inline-src-block-matches)) + (should (re-search-forward "}" nil (point-at-bol))) ;; 1 + (should-not (org-babel-get-inline-src-block-matches)) + (should (re-search-forward "in" nil t)) ;; 2 + (should-not (org-babel-get-inline-src-block-matches)) + (should (re-search-forward "echo" nil t)) ;; 2 + (should (org-babel-get-inline-src-block-matches)) + (should (re-search-forward "blocks" nil t)) ;; 3 + (left-char 8) ;; 3 + (should (org-babel-get-inline-src-block-matches)) + (right-char 1) ;;3 + (should-not (org-babel-get-inline-src-block-matches)) + (should (re-search-forward ":results" nil t)) ;; 4 + (should (org-babel-get-inline-src-block-matches)) + (end-of-line) + (should-not (org-babel-get-inline-src-block-matches)) + ))) (provide 'test-ob) From 242a9286466b10b0a64b35ccf0c81a53033f98b1 Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Tue, 6 Sep 2011 08:57:10 -0600 Subject: [PATCH 17/47] removing test: shouldn't test a variables value, should test its functionality * testing/lisp/test-ob.el (test-org-babel/get-header): Removing a test, shouldn't test a variables value, should test its functionality. --- testing/lisp/test-ob.el | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el index f9884ddcd..e0f7c655c 100644 --- a/testing/lisp/test-ob.el +++ b/testing/lisp/test-ob.el @@ -106,17 +106,6 @@ org-babel-src-block-regexp (replace-regexp-in-string body "" test-block))))) - -(ert-deftest test-org-babel/inline-src-block-regexp () - (should(equal (concat "\\(?:^\\|[^-[:alnum:]]\\)\\(src_\\([^ \f\t\n\r\v]+\\)" - "\\(\\|\\[\\(.*?\\)\\]\\)" - "{\\([^\f\n\r\v]+?\\)}\\)") - org-babel-inline-src-block-regexp)) - ;; (should (org-test-string-exact-match - ;; org-babel-inline-src-block-regexp - ;; "src_lang[:testing1 yes :testing2 no]{ echo This is a test }\n")) - ) - (ert-deftest test-org-babel/get-header () (should (not (org-babel-get-header org-babel-default-header-args :doesnt-exist))) From 966ec3f1f12b0017cdef306e36d6573cc11d2e90 Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Tue, 6 Sep 2011 09:07:00 -0600 Subject: [PATCH 18/47] ensure all tests have unique names * testing/lisp/test-ob-exp.el (test-ob-exp/org-babel-exp-src-blocks/w-no-headers2): Renamed to be unique. --- testing/lisp/test-ob-exp.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/lisp/test-ob-exp.el b/testing/lisp/test-ob-exp.el index 931346f7d..a0182a1d6 100644 --- a/testing/lisp/test-ob-exp.el +++ b/testing/lisp/test-ob-exp.el @@ -50,7 +50,7 @@ (buffer-string)))) (when (get-buffer "*Org HTML Export*") (kill-buffer "*Org HTML Export*"))) -(ert-deftest test-ob-exp/org-babel-exp-src-blocks/w-no-headers () +(ert-deftest test-ob-exp/org-babel-exp-src-blocks/w-no-headers2 () "Testing export without any headlines in the org-mode file." (let ((html-file (concat (file-name-sans-extension org-test-link-in-heading-file) From 09986fa3954ac7875158219539c32e1d80d74ef3 Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Tue, 6 Sep 2011 09:09:09 -0600 Subject: [PATCH 19/47] commenting out single failing test * testing/lisp/test-ob-fortran.el: Commenting out single failing test. --- testing/lisp/test-ob-fortran.el | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/testing/lisp/test-ob-fortran.el b/testing/lisp/test-ob-fortran.el index b9ffbfdb7..1eb58b880 100644 --- a/testing/lisp/test-ob-fortran.el +++ b/testing/lisp/test-ob-fortran.el @@ -29,11 +29,12 @@ (org-babel-next-src-block 2) (should (= 42 (org-babel-execute-src-block))))) -(ert-deftest ob-fortran/character-var () - "Test string input" - (org-test-at-id "d8d1dfd3-5f0c-48fe-b55d-777997e02242" - (org-babel-next-src-block 3) - (should (equal "word" (org-babel-execute-src-block))))) +;; ;; TODO: test fails +;; (ert-deftest ob-fortran/character-var () +;; "Test string input" +;; (org-test-at-id "d8d1dfd3-5f0c-48fe-b55d-777997e02242" +;; (org-babel-next-src-block 3) +;; (should (equal "word" (org-babel-execute-src-block))))) (ert-deftest ob-fortran/list-var () "Test real array input" From fe77c6674194e0f7e16adaa33d01b48990164fd2 Mon Sep 17 00:00:00 2001 From: David Maus Date: Thu, 1 Sep 2011 06:49:29 +0200 Subject: [PATCH 20/47] Use `string=' to compare strings * org-elisp-symbol.el (org-elisp-symbol-store-link): Use `string=' to compare strings. (let ((foo "foo")) (eq foo "foo")) => nil --- contrib/lisp/org-elisp-symbol.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/lisp/org-elisp-symbol.el b/contrib/lisp/org-elisp-symbol.el index e614e974b..6eb811418 100644 --- a/contrib/lisp/org-elisp-symbol.el +++ b/contrib/lisp/org-elisp-symbol.el @@ -104,8 +104,8 @@ (stype (cond ((commandp sym-name) "Command") ((functionp sym-name) "Function") ((user-variable-p sym-name) "User variable") - ((eq def "defvar") "Variable") - ((eq def "defmacro") "Macro") + ((string= def "defvar") "Variable") + ((string= def "defmacro") "Macro") (t "Symbol"))) (args (if (match-string 3) (mapconcat (lambda (a) (unless (string-match "^&" a) a)) From f0d139adfa3f3b6599072a0b3c1672350fe9834d Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Tue, 6 Sep 2011 11:11:12 -0600 Subject: [PATCH 21/47] correctly resolving load-path in testing files * testing/lisp/test-org.el (testing-lisp-dir): Require all files with load-path set. * testing/lisp/test-ob-lob.el (expand-file-name): Relative load path. * testing/lisp/test-ob-fortran.el (load-path): Relative load path. --- testing/lisp/test-ob-fortran.el | 17 +++++++++++++++-- testing/lisp/test-ob-lob.el | 25 ++++++++++++++----------- testing/lisp/test-org.el | 12 ++++++------ 3 files changed, 35 insertions(+), 19 deletions(-) diff --git a/testing/lisp/test-ob-fortran.el b/testing/lisp/test-ob-fortran.el index 1eb58b880..c3bde0b75 100644 --- a/testing/lisp/test-ob-fortran.el +++ b/testing/lisp/test-ob-fortran.el @@ -1,5 +1,18 @@ -(require 'ob-fortran) - +(let ((load-path (cons (expand-file-name + "langs" + (expand-file-name + "babel" + (expand-file-name + "contrib" + (expand-file-name + ".." + (expand-file-name + ".." + (file-name-directory + (or load-file-name buffer-file-name))))))) + load-path))) + (require 'ob-fortran)) + (ert-deftest ob-fortran/assert () (should t)) diff --git a/testing/lisp/test-ob-lob.el b/testing/lisp/test-ob-lob.el index 60f9399c4..ebfc14a26 100644 --- a/testing/lisp/test-ob-lob.el +++ b/testing/lisp/test-ob-lob.el @@ -8,19 +8,22 @@ ;;;; Comments: -;; Template test file for Org-mode tests - - -;;; Code: -(let ((load-path (cons (expand-file-name - ".." (file-name-directory - (or load-file-name buffer-file-name))) - load-path))) - (require 'org-test) - (require 'org-test-ob-consts)) - ;;; Tests +(org-babel-lob-ingest + (expand-file-name + "library-of-babel.org" + (expand-file-name + "babel" + (expand-file-name + "contrib" + (expand-file-name + ".." + (expand-file-name + ".." + (file-name-directory + (or load-file-name buffer-file-name)))))))) + (ert-deftest test-ob-lob/ingest () "Test the ingestion of an org-mode file." (should (< 0 (org-babel-lob-ingest diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index 85a3e4aa8..1c81fac49 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -12,12 +12,12 @@ ;;; Code: -(let ((load-path (cons (expand-file-name - ".." (file-name-directory - (or load-file-name buffer-file-name))) - load-path))) - (require 'org-test) - (require 'org-test-ob-consts)) +(let* ((testing-lisp-dir (file-name-directory + (or load-file-name buffer-file-name))) + (load-path (cons testing-lisp-dir load-path))) + (dolist (file (directory-files testing-lisp-dir 'full + "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*\\.org$")) + (require (intern (substring file 0 (- (length file) 3)))))) ;;; Tests From 6b955077dc86ee7d5084c49a9aa31d57579d7fab Mon Sep 17 00:00:00 2001 From: Jambunathan K Date: Tue, 6 Sep 2011 17:46:11 +0530 Subject: [PATCH 22/47] org-odt.el: Rework embedding of images * contrib/lisp/org-odt.el (org-odt-embedded-images-count): New variable. (org-odt-copy-image-file): Use the above variable to name the embedded image files. Remove some cruft as well. (org-export-odt-file-list, org-export-odt-save-list): Removed. (org-odt-init-outfile, org-odt-save-as-outfile): Related changes. --- contrib/lisp/org-odt.el | 67 +++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 43 deletions(-) diff --git a/contrib/lisp/org-odt.el b/contrib/lisp/org-odt.el index 37d33d4a1..2ac7b6679 100644 --- a/contrib/lisp/org-odt.el +++ b/contrib/lisp/org-odt.el @@ -1268,38 +1268,28 @@ MAY-INLINE-P allows inlining it as an image." ;; (when par-open (org-odt-open-par)) )))))) -;; xml files generated on-the-fly -(defconst org-export-odt-save-list - '("mimetype" "META-INF/manifest.xml" "content.xml" "meta.xml" "styles.xml")) - -;; xml files that contribute to the final odt file -(defvar org-export-odt-file-list nil) - -(defun org-odt-copy-image-file (path &optional target-file) +(defvar org-odt-embedded-images-count 0) +(defun org-odt-copy-image-file (path) "Returns the internal name of the file" (let* ((image-type (file-name-extension path)) (media-type (format "image/%s" image-type)) (src-file (expand-file-name path (file-name-directory org-current-export-file))) - (target-file (or target-file (org-odt-get-image-name src-file))) - ;; FIXME - (body-only nil)) - + (target-dir "Images/") + (target-file + (format "%s%04d.%s" target-dir + (incf org-odt-embedded-images-count) image-type))) (when (not org-lparse-to-buffer) (message "Embedding %s as %s ..." (substring-no-properties path) target-file) - ;; create Pictures dir if needed - (let ((pictures-dir (file-name-directory target-file))) - (unless (file-directory-p pictures-dir) - (make-directory pictures-dir) - (org-odt-create-manifest-file-entry "" pictures-dir))) + (when (= 1 org-odt-embedded-images-count) + (make-directory target-dir) + (org-odt-create-manifest-file-entry "" target-dir)) - ;; copy image file - (unless (file-readable-p target-file) - (copy-file src-file target-file 'overwrite) - (org-odt-create-manifest-file-entry media-type target-file) - (push target-file org-export-odt-file-list))) target-file)) + (copy-file src-file target-file 'overwrite) + (org-odt-create-manifest-file-entry media-type target-file)) + target-file)) (defun org-odt-image-attrs-from-size (&optional width height) (concat @@ -1393,28 +1383,17 @@ MAY-INLINE-P allows inlining it as an image." (defun org-odt-init-outfile (filename) (unless (executable-find "zip") ;; Not at all OSes ship with zip by default - (error "Executable \"zip\" needed for creating OpenDocument files. Aborting.")) + (error "Executable \"zip\" needed for creating OpenDocument files")) (let* ((outdir (make-temp-file org-export-odt-tmpdir-prefix t)) - (mimetype-file (expand-file-name "mimetype" outdir)) - (content-file (expand-file-name "content.xml" outdir)) - (manifest-file (expand-file-name "META-INF/manifest.xml" outdir)) - (meta-file (expand-file-name "meta.xml" outdir)) - (styles-file (expand-file-name "styles.xml" outdir)) - (pictures-dir (expand-file-name "Pictures" outdir)) - (body-only nil)) + (content-file (expand-file-name "content.xml" outdir))) - ;; content file - (with-current-buffer (find-file-noselect content-file t) - (erase-buffer)) + ;; init conten.xml + (with-current-buffer (find-file-noselect content-file t)) - ;; FIXME: How to factor in body-only here - (unless body-only - ;; initialize list of files that contribute to the odt file - (setq org-export-odt-file-list org-export-odt-save-list)) - - ;; no manifest file entries for now - (setq org-odt-manifest-file-entries nil) + ;; reset variables + (setq org-odt-manifest-file-entries nil + org-odt-embedded-images-count 0) content-file)) @@ -1474,7 +1453,9 @@ visually." ;; write out the manifest entries before zipping (org-odt-write-manifest-file) - (let ((zipdir default-directory)) + (let ((xml-files '("mimetype" "META-INF/manifest.xml" "content.xml" + "meta.xml" "styles.xml")) + (zipdir default-directory)) (message "Switching to directory %s" (expand-file-name zipdir)) ;; save all xml files @@ -1485,7 +1466,7 @@ visually." (when org-export-odt-prettify-xml (indent-region (point-min) (point-max))) (save-buffer 0))) - org-export-odt-save-list) + xml-files) (let* ((target-name (file-name-nondirectory target)) (target-dir (file-name-directory target)) @@ -1513,7 +1494,7 @@ visually." (mapc (lambda (file) (kill-buffer (find-file-noselect (expand-file-name file zipdir) t))) - org-export-odt-save-list) + xml-files) (delete-directory zipdir))) From 0dd10f5d9743a02aa504155a6f8be14b9c587d44 Mon Sep 17 00:00:00 2001 From: Jambunathan K Date: Tue, 6 Sep 2011 23:45:25 +0530 Subject: [PATCH 23/47] org-odt.el: Format date strings in meta.xml using portable means * contrib/lisp/org-odt.el (org-odt-format-date): %:z format specifier of `format-time-string' is not portable. Replace it with an equivalent implementation using %z specifier. Thanks to Anton Tarasenko for reporting this bug and verifying this fix. See http://lists.gnu.org/archive/html/emacs-orgmode/2011-09/msg00099.html --- contrib/lisp/org-odt.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contrib/lisp/org-odt.el b/contrib/lisp/org-odt.el index 2ac7b6679..33ad426c4 100644 --- a/contrib/lisp/org-odt.el +++ b/contrib/lisp/org-odt.el @@ -1525,7 +1525,8 @@ visually." date) (t ;; ISO 8601 format - (format-time-string "%Y-%m-%dT%T%:z"))))) + (let ((stamp (format-time-string "%Y-%m-%dT%H:%M:%S%z"))) + (format "%s:%s" (substring stamp 0 -2) (substring stamp -2))))))) (defconst org-odt-manifest-file-entry-tag " From d0a3a3870f1d8e51d621890728c55ad9862371cb Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Tue, 6 Sep 2011 21:52:04 -0600 Subject: [PATCH 24/47] org-exp: only remove commas on the front line of a code block * lisp/org-exp.el (org-export-select-backend-specific-text): Only remove commas on the front line of a code block. --- lisp/org-exp.el | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lisp/org-exp.el b/lisp/org-exp.el index f795fbd02..42b26e47b 100644 --- a/lisp/org-exp.el +++ b/lisp/org-exp.el @@ -1738,8 +1738,14 @@ from the buffer." (save-excursion (save-match-data (goto-char beg-content) - (while (re-search-forward "^[ \t]*\\(,\\)" end-content t) - (replace-match "" nil nil nil 1)))) + (let ((front-line (save-excursion + (re-search-forward + "[^[:space:]]" end-content t) + (goto-char (match-beginning 0)) + (current-column)))) + (while (re-search-forward "^[ \t]*\\(,\\)" end-content t) + (when (= (current-column) front-line) + (replace-match "" nil nil nil 1)))))) (delete-region (match-beginning 0) (match-end 0)) (save-excursion (goto-char beg) From f1746a51185083b9368810d2d013e73332f90301 Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Tue, 6 Sep 2011 21:58:51 -0600 Subject: [PATCH 25/47] test of comma stripping behavior * testing/examples/org-exp.org: Example file for export tests. * testing/lisp/test-org-exp.el (test-org-exp/stripping-commas): List file for export tests. --- testing/examples/org-exp.org | 14 ++++++++++++++ testing/lisp/test-org-exp.el | 8 ++++++++ 2 files changed, 22 insertions(+) create mode 100644 testing/examples/org-exp.org create mode 100644 testing/lisp/test-org-exp.el diff --git a/testing/examples/org-exp.org b/testing/examples/org-exp.org new file mode 100644 index 000000000..e101335ca --- /dev/null +++ b/testing/examples/org-exp.org @@ -0,0 +1,14 @@ +#+Title: a collection of examples for export tests +#+OPTIONS: ^:nil + +* stripping commas from within blocks on export + :PROPERTIES: + :ID: 76d3a083-67fa-4506-a41d-837cc48158b5 + :END: +The following commas should not be removed. + +#+begin_src r + a <- c(1 + , 2 + , 3) +#+end_src diff --git a/testing/lisp/test-org-exp.el b/testing/lisp/test-org-exp.el new file mode 100644 index 000000000..b7d7387fc --- /dev/null +++ b/testing/lisp/test-org-exp.el @@ -0,0 +1,8 @@ +(ert-deftest test-org-exp/stripping-commas () + "Test the stripping of commas from within blocks during export." + (org-test-at-id "76d3a083-67fa-4506-a41d-837cc48158b5" + ;; don't strip internal commas + (org-narrow-to-subtree) + (should (string-match + ", 2" + (org-export-as-ascii nil nil nil 'string))))) From 14304f6dcd18df99f39e47bd07e998ead382c3d1 Mon Sep 17 00:00:00 2001 From: Christian Egli Date: Wed, 7 Sep 2011 15:45:14 +0200 Subject: [PATCH 26/47] taskjuggler export: take buffer local variables into account * org-taskjuggler.el (org-export-as-taskjuggler): Clone the buffer local variables to the temporary buffer before exporting. The taskjuggler exporter handles properties. When defining buffer local priorities the export fails however, as buffer local variables are not taken into account since the export happens in a new temporary buffer. This commit fixes that by cloning the relevant buffer local variables into the temporary buffer before exporting. --- lisp/org-taskjuggler.el | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lisp/org-taskjuggler.el b/lisp/org-taskjuggler.el index 5ff6a5ef2..78b38be57 100644 --- a/lisp/org-taskjuggler.el +++ b/lisp/org-taskjuggler.el @@ -277,6 +277,7 @@ defined in `org-export-taskjuggler-default-reports'." (file-name-nondirectory buffer-file-name)) org-export-taskjuggler-extension))) (buffer (find-file-noselect filename)) + (old-buffer (current-buffer)) (org-export-taskjuggler-old-level 0) task resource) (unless tasks @@ -304,6 +305,7 @@ defined in `org-export-taskjuggler-default-reports'." (setcar tasks (push (cons "version" version) task)))) (with-current-buffer buffer (erase-buffer) + (org-clone-local-variables old-buffer "^org-") (org-taskjuggler-open-project (car tasks)) (insert org-export-taskjuggler-default-global-properties) (insert "\n") From 86409e89c0a872388ecc18e2095b641445ada1c3 Mon Sep 17 00:00:00 2001 From: Jambunathan K Date: Wed, 7 Sep 2011 22:42:33 +0530 Subject: [PATCH 27/47] org-odt.el: Sanitize formatting of Images * contrib/lisp/org-odt.el (org-odt-format-frame): New. (org-odt-format-textbox): Use the above function. (org-export-odt-do-format-image): Use the above two functions. Use the new custom styles for the Frame and Graphics elements. (org-odt-image-attrs-from-size): Remove this. * contrib/odt/styles/OrgOdtAutomaticStyles.xml: Removed all Frame and Graphics entries. * contrib/odt/styles/OrgOdtStyles.xml: Added following custom styles - OrgSimpleGraphics, OrgCaptionedGraphics, OrgCaptionFrame, OrgInlineGraphics and OrgInlineFormula. --- contrib/lisp/org-odt.el | 95 ++++++++------------ contrib/odt/styles/OrgOdtAutomaticStyles.xml | 82 ----------------- contrib/odt/styles/OrgOdtStyles.xml | 24 +++++ 3 files changed, 63 insertions(+), 138 deletions(-) diff --git a/contrib/lisp/org-odt.el b/contrib/lisp/org-odt.el index 33ad426c4..f41a53722 100644 --- a/contrib/lisp/org-odt.el +++ b/contrib/lisp/org-odt.el @@ -1200,19 +1200,26 @@ MAY-INLINE-P allows inlining it as an image." (plist-get attr-plist :height) (plist-get attr-plist :scale) nil embed-as))) (org-export-odt-do-format-image - embed-as caption attr label size href)))) + embed-as caption attr label (car size) (cdr size) href)))) -(defun org-odt-format-textbox (text style) - (let ((draw-frame-pair - '("" . ""))) +(defun org-odt-format-frame (text style &optional + width height extra anchor-type) + (let ((frame-attrs + (concat + (if width (format " svg:width=\"%0.2fcm\"" width) "") + (if height (format " svg:height=\"%0.2fcm\"" height) "") + extra + (format " text:anchor-type=\"%s\"" (or anchor-type "paragraph"))))) (org-odt-format-tags - draw-frame-pair - (org-odt-format-tags - '("" . "") - text 0) style))) + '("" . "") + text style frame-attrs))) + +(defun org-odt-format-textbox (text style &optional width height) + (org-odt-format-frame + (org-odt-format-tags + '("" . "") + text (format " fo:min-height=\"%0.2fcm\"" (or height 0.5))) + style width nil (and (not width) " style:rel-width=\"100%\""))) (defun org-odt-format-inlinetask (heading content &optional todo priority tags) @@ -1226,47 +1233,29 @@ MAY-INLINE-P allows inlining it as an image." content) "OrgInlineTaskFrame"))) (defun org-export-odt-do-format-image (embed-as caption attr label - size href) + width height href) "Create image tag with source and attributes." (save-match-data - (let ((width (car size)) (height (cdr size)) - (draw-frame-pair - '("" . ""))) - (cond - ((and (not caption) (not label)) - (let (style-name anchor-type) - (cond - ((eq embed-as 'paragraph) - (setq style-name "OrgGraphicsParagraph" anchor-type "paragraph")) - ((eq embed-as 'character) - (setq style-name "OrgGraphicsBaseline" anchor-type "as-char"))) - (org-odt-format-tags - draw-frame-pair href style-name anchor-type 0 - (org-odt-image-attrs-from-size width height)))) - - (t - (concat - ;; (when par-open (org-odt-close-par)) - (org-odt-format-tags - draw-frame-pair - (org-odt-format-tags - '("" . "") - (org-odt-format-stylized-paragraph - 'illustration - (concat - (let ((extra " style:rel-width=\"100%\" style:rel-height=\"scale\"")) - (org-odt-format-tags - draw-frame-pair href "OrgGraphicsParagraphContent" "paragraph" 2 - (concat (org-odt-image-attrs-from-size width height) extra))) - (org-odt-format-entity-caption label caption))) - height) - "OrgFrame" "paragraph" 1 - (org-odt-image-attrs-from-size width)) - - ;; (when par-open (org-odt-open-par)) - )))))) + (cond + ((and (not caption) (not label)) + (let (style-name anchor-type) + (cond + ((eq embed-as 'paragraph) + (setq style-name "OrgSimpleGraphics" anchor-type "paragraph")) + ((eq embed-as 'character) + (setq style-name "OrgInlineGraphics" anchor-type "as-char"))) + (org-odt-format-frame href style-name width height nil anchor-type))) + (t + (concat + (org-odt-format-textbox + (org-odt-format-stylized-paragraph + 'illustration + (concat + (let ((extra " style:rel-width=\"100%\" style:rel-height=\"scale\"")) + (org-odt-format-frame + href "OrgCaptionedGraphics" width height extra "paragraph")) + (org-odt-format-entity-caption label caption))) + "OrgCaptionFrame" width height)))))) (defvar org-odt-embedded-images-count 0) (defun org-odt-copy-image-file (path) @@ -1291,12 +1280,6 @@ MAY-INLINE-P allows inlining it as an image." (org-odt-create-manifest-file-entry media-type target-file)) target-file)) -(defun org-odt-image-attrs-from-size (&optional width height) - (concat - (when width (format "svg:width=\"%0.2fcm\"" width)) - " " - (when height (format "svg:height=\"%0.2fcm\"" height)))) - (defvar org-export-odt-image-size-probe-method '(emacs imagemagick force) "Ordered list of methods by for determining size of an embedded diff --git a/contrib/odt/styles/OrgOdtAutomaticStyles.xml b/contrib/odt/styles/OrgOdtAutomaticStyles.xml index c4116c0f3..d3f73bb83 100644 --- a/contrib/odt/styles/OrgOdtAutomaticStyles.xml +++ b/contrib/odt/styles/OrgOdtAutomaticStyles.xml @@ -72,86 +72,4 @@ - - - - - - - - - - - - - - - - diff --git a/contrib/odt/styles/OrgOdtStyles.xml b/contrib/odt/styles/OrgOdtStyles.xml index 0cdff5f7c..7f6f0ad61 100644 --- a/contrib/odt/styles/OrgOdtStyles.xml +++ b/contrib/odt/styles/OrgOdtStyles.xml @@ -362,6 +362,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + From 5b98dfb6441d59f21b910324148de082eeba4c69 Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Thu, 8 Sep 2011 09:11:26 -0600 Subject: [PATCH 28/47] adding function for batch test evaluation * testing/org-test.el (org-test-run-batch-tests): Allows for batch evaluation of the Org-mode test suite. --- testing/org-test.el | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/testing/org-test.el b/testing/org-test.el index e639a3243..331dfa167 100644 --- a/testing/org-test.el +++ b/testing/org-test.el @@ -228,6 +228,14 @@ files." "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*\\.org$")) (find-file file))) +(defun org-test-run-batch-tests () + "Run all defined tests matching \"\\(org\\|ob\\)\". +Load all test files first." + (interactive) + (org-test-touch-all-examples) + (org-test-load) + (ert-run-tests-batch-and-exit "\\(org\\|ob\\)")) + (defun org-test-run-all-tests () "Run all defined tests matching \"\\(org\\|ob\\)\". Load all test files first." From be69dd2d50e7d7aa5c93af1f2d7a0872e3244a51 Mon Sep 17 00:00:00 2001 From: Jambunathan K Date: Thu, 8 Sep 2011 20:41:27 +0530 Subject: [PATCH 29/47] org-odt.el: Embed links to mathml files as ODF formula * contrib/lisp/org-odt.el (org-odt-embedded-formulas-count):New variable. (org-odt-init-outfile): Reset above variable. (org-odt-is-formula-link-p, org-odt-format-inline-formula) (org-odt-copy-formula-file, org-export-odt-format-formula) (org-export-odt-do-format-formula) (org-export-odt-do-format-numbered-formula): New functions for formatting mathml file links as embedded ODF formulae. (org-odt-format-org-link): Add check for links to mathml files and call `org-odt-format-inline-formula'. (org-export-odt-format-image): Update function signature. Use `org-latex-src' property to identify latex dvipng images. Use the (to be committed) `org-latex-src-embed-type' to identify whether the equation image should be inlined or displayed. (org-odt-format-textbox): Modified to accomodate correct formatting of captioned formula. (org-odt-format-inlinetask): Modified to accomodate changes to the previous function. (org-export-odt-do-format-image): Minor change. (org-export-odt-do-preprocess-latex-fragments): When LaTeX fragment option is set to `t' or `mathjax' check for availability of latex to mathml converter using (to be committed) `org-format-latex-mathml-available-p'. If such a converter is available and configured, use it. Otherwise default to the earlier behaviour. Refer the following post for more information: http://article.gmane.org/gmane.emacs.orgmode/46712 --- contrib/lisp/org-odt.el | 168 ++++++++++++++++++++++++++++++++-------- 1 file changed, 137 insertions(+), 31 deletions(-) diff --git a/contrib/lisp/org-odt.el b/contrib/lisp/org-odt.el index f41a53722..16d6441d4 100644 --- a/contrib/lisp/org-odt.el +++ b/contrib/lisp/org-odt.el @@ -1055,6 +1055,98 @@ value of `org-export-odt-use-htmlfontify." (org-odt-copy-image-file thefile) thelink)))) (org-export-odt-format-image thefile href))) +(defun org-export-odt-do-format-numbered-formula (embed-as caption attr label + width height href) + (with-temp-buffer + (let ((org-lparse-table-colalign-info '((0 "c" "8") (0 "c" "1")))) + (org-lparse-do-format-list-table + `((,(org-export-odt-do-format-formula ; caption and label + ; should be nil + embed-as nil attr nil width height href) + ,(org-odt-format-entity-caption label caption "Equation"))) + nil nil nil nil nil org-lparse-table-colalign-info)) + (buffer-substring-no-properties (point-min) (point-max)))) + +(defun org-export-odt-do-format-formula (embed-as caption attr label + width height href) + "Create image tag with source and attributes." + (save-match-data + (cond + ((and (not caption) (not label)) + (let (style-name anchor-type) + (case embed-as + (paragraph + (setq style-name "OrgSimpleGraphics" anchor-type "paragraph")) + (character + (setq style-name "OrgInlineGraphics" anchor-type "as-char")) + (t + (error "Unknown value for embed-as %S" embed-as))) + (org-odt-format-frame href style-name width height nil anchor-type))) + (t + (concat + (org-odt-format-textbox + (org-odt-format-stylized-paragraph + 'illustration + (concat + (let ((extra "")) + (org-odt-format-frame + href "" width height extra "paragraph")) + (org-odt-format-entity-caption label caption))) + "OrgCaptionFrame" width height)))))) + +(defun org-export-odt-format-formula (src href &optional embed-as) + "Create image tag with source and attributes." + (save-match-data + (let* ((caption (org-find-text-property-in-string 'org-caption src)) + (caption (and caption (org-xml-format-desc caption))) + (attr (org-find-text-property-in-string 'org-attributes src)) + (label (org-find-text-property-in-string 'org-label src)) + (embed-as (or embed-as + (and (org-find-text-property-in-string + 'org-latex-src src) + (org-find-text-property-in-string + 'org-latex-src-embed-type src)) + 'paragraph)) + (attr-plist (when attr (read attr))) + (width (plist-get attr-plist :width)) + (height (plist-get attr-plist :height))) + (org-export-odt-do-format-formula + embed-as caption attr label width height href)))) + +(defvar org-odt-embedded-formulas-count 0) +(defun org-odt-copy-formula-file (path) + "Returns the internal name of the file" + (let* ((src-file (expand-file-name + path (file-name-directory org-current-export-file))) + (target-dir (format "Formula-%04d/" + (incf org-odt-embedded-formulas-count))) + (target-file (concat target-dir "content.xml"))) + (when (not org-lparse-to-buffer) + (message "Embedding %s as %s ..." + (substring-no-properties path) target-file) + + (make-directory target-dir) + (org-odt-create-manifest-file-entry + "application/vnd.oasis.opendocument.formula" target-dir "1.2") + + (copy-file src-file target-file 'overwrite) + (org-odt-create-manifest-file-entry "text/xml" target-file)) + target-file)) + +(defun org-odt-format-inline-formula (thefile) + (let* ((thelink (if (file-name-absolute-p thefile) thefile + (org-xml-format-href + (org-odt-relocate-relative-path + thefile org-current-export-file)))) + (href + (org-odt-format-tags + "" "" + (file-name-directory (org-odt-copy-formula-file thefile))))) + (org-export-odt-format-formula thefile href))) + +(defun org-odt-is-formula-link-p (file) + (member (downcase (file-name-extension file)) '("mathml"))) + (defun org-odt-format-org-link (opt-plist type-1 path fragment desc attr descp) "Make an HTML link. @@ -1065,7 +1157,6 @@ FRAGMENT is the fragment part of the link, if any (foo.html#THIS) DESC is the link description, if any. ATTR is a string of other attributes of the a element. MAY-INLINE-P allows inlining it as an image." - (declare (special org-lparse-par-open)) (save-match-data (let* ((may-inline-p @@ -1075,7 +1166,6 @@ MAY-INLINE-P allows inlining it as an image." (type (if (equal type-1 "id") "file" type-1)) (filename path) (thefile path)) - (cond ;; check for inlined images ((and (member type '("file")) @@ -1084,12 +1174,13 @@ MAY-INLINE-P allows inlining it as an image." filename org-odt-export-inline-image-extensions) (or (eq t org-odt-export-inline-images) (and org-odt-export-inline-images (not descp)))) - - ;; (when (and (string= type "file") (file-name-absolute-p path)) - ;; (setq thefile (concat "file://" (expand-file-name path)))) - ;; (setq thefile (org-xml-format-href thefile)) - ;; (org-export-html-format-image thefile) (org-odt-format-inline-image thefile)) + ;; check for embedded formulas + ((and (member type '("file")) + (not fragment) + (org-odt-is-formula-link-p filename) + (or (not descp))) + (org-odt-format-inline-formula thefile)) (t (when (string= type "file") (setq thefile @@ -1186,14 +1277,19 @@ MAY-INLINE-P allows inlining it as an image." (expand-file-name (concat (sha1 file-name) "." (file-name-extension file-name)) "Pictures"))) -(defun org-export-odt-format-image (src href) +(defun org-export-odt-format-image (src href &optional embed-as) "Create image tag with source and attributes." (save-match-data (let* ((caption (org-find-text-property-in-string 'org-caption src)) (caption (and caption (org-xml-format-desc caption))) (attr (org-find-text-property-in-string 'org-attributes src)) (label (org-find-text-property-in-string 'org-label src)) - (embed-as (if (string-match "^ltxpng/" src) 'character 'paragraph)) + (embed-as (or embed-as + (if (org-find-text-property-in-string + 'org-latex-src src) + (or (org-find-text-property-in-string + 'org-latex-src-embed-type src) 'character) + 'paragraph))) (attr-plist (when attr (read attr))) (size (org-odt-image-size-from-file src (plist-get attr-plist :width) @@ -1214,12 +1310,13 @@ MAY-INLINE-P allows inlining it as an image." '("" . "") text style frame-attrs))) -(defun org-odt-format-textbox (text style &optional width height) +(defun org-odt-format-textbox (text style &optional width height extra) (org-odt-format-frame (org-odt-format-tags '("" . "") - text (format " fo:min-height=\"%0.2fcm\"" (or height 0.5))) - style width nil (and (not width) " style:rel-width=\"100%\""))) + text (concat (format " fo:min-height=\"%0.2fcm\"" (or height .2)) + (format " fo:min-width=\"%0.2fcm\"" (or width .2)))) + style width nil extra)) (defun org-odt-format-inlinetask (heading content &optional todo priority tags) @@ -1230,8 +1327,7 @@ MAY-INLINE-P allows inlining it as an image." (org-lparse-format 'HEADLINE (concat (org-lparse-format-todo todo) " " heading) nil tags)) - content) "OrgInlineTaskFrame"))) - + content) "OrgInlineTaskFrame" nil nil " style:rel-width=\"100%\""))) (defun org-export-odt-do-format-image (embed-as caption attr label width height href) "Create image tag with source and attributes." @@ -1239,11 +1335,13 @@ MAY-INLINE-P allows inlining it as an image." (cond ((and (not caption) (not label)) (let (style-name anchor-type) - (cond - ((eq embed-as 'paragraph) - (setq style-name "OrgSimpleGraphics" anchor-type "paragraph")) - ((eq embed-as 'character) - (setq style-name "OrgInlineGraphics" anchor-type "as-char"))) + (case embed-as + (paragraph + (setq style-name "OrgSimpleGraphics" anchor-type "paragraph")) + (character + (setq style-name "OrgInlineGraphics" anchor-type "as-char")) + (t + (error "Unknown value for embed-as %S" embed-as))) (org-odt-format-frame href style-name width height nil anchor-type))) (t (concat @@ -1376,7 +1474,8 @@ MAY-INLINE-P allows inlining it as an image." ;; reset variables (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) content-file)) @@ -1625,24 +1724,31 @@ visually." (defun org-export-odt-do-preprocess-latex-fragments () "Convert LaTeX fragments to images." (let* ((latex-frag-opt (plist-get org-lparse-opt-plist :LaTeX-fragments)) - (latex-frag-opt-1 ; massage the options + (latex-frag-opt ; massage the options (or (and (member latex-frag-opt '(mathjax t)) + (not (and (fboundp 'org-format-latex-mathml-available-p) + (org-format-latex-mathml-available-p))) (prog1 org-lparse-latex-fragment-fallback (org-lparse-warn (concat - "Use of MathJax is incompatible with ODT exporter. " + "LaTeX to MathML converter not available. " (format "Using %S instead." org-lparse-latex-fragment-fallback))))) - latex-frag-opt))) - (when (and org-current-export-file latex-frag-opt-1) - ;; Investigate MathToWeb for converting TeX equations to MathML - ;; http://lists.gnu.org/archive/html/emacs-orgmode/2011-03/msg01755.html + latex-frag-opt)) + cache-dir display-msg) + (cond + ((eq latex-frag-opt 'dvipng) + (setq cache-dir "ltxpng/") + (setq display-msg "Creating LaTeX image %s")) + ((member latex-frag-opt '(mathjax t)) + (setq cache-dir "ltxmathml/") + (setq display-msg "Creating MathML formula %s"))) + (when (and org-current-export-file) (org-format-latex - (concat "ltxpng/" (file-name-sans-extension - (file-name-nondirectory - org-current-export-file))) - org-current-export-dir nil "Creating LaTeX image %s" - nil nil latex-frag-opt-1)))) + (concat cache-dir (file-name-sans-extension + (file-name-nondirectory org-current-export-file))) + org-current-export-dir nil display-msg + nil nil latex-frag-opt)))) (defun org-export-odt-preprocess-latex-fragments () (when (equal org-export-current-backend 'odt) From a4e881207d476c2366e48410cb8d2e5ce5824a18 Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Thu, 8 Sep 2011 11:33:04 -0600 Subject: [PATCH 30/47] better error message for unassigned variables * lisp/ob.el (org-babel-merge-params): Better error message for unassigned variables. --- lisp/ob.el | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lisp/ob.el b/lisp/ob.el index d6b0ba350..9f70c0bc1 100644 --- a/lisp/ob.el +++ b/lisp/ob.el @@ -1843,12 +1843,16 @@ parameters when merging lists." vars)) vars) (list (cons name pair)))) - ;; if no name is given, then assign to variables in order - (prog1 (setf (cddr (nth variable-index vars)) - (concat (symbol-name - (car (nth variable-index vars))) - "=" (cdr pair))) - (incf variable-index))))) + ;; if no name is given and we already have named variables + ;; then assign to named variables in order + (if (and vars (nth variable-index vars)) + (prog1 (setf (cddr (nth variable-index vars)) + (concat (symbol-name + (car (nth variable-index vars))) + "=" (cdr pair))) + (incf variable-index)) + (error "variable \"%s\" must be assigned a default value" + (cdr pair)))))) (:results (setq results (e-merge results-exclusive-groups results From ab757f9a24e41e504f3a760b80edefa814abb2bc Mon Sep 17 00:00:00 2001 From: Jambunathan K Date: Fri, 9 Sep 2011 00:22:19 +0530 Subject: [PATCH 31/47] org-odt.el: Set mathml option * contrib/lisp/org-odt.el (org-export-odt-do-preprocess-latex-fragments): Pass 'mathml option to `org-format-latex'. --- contrib/lisp/org-odt.el | 1 + 1 file changed, 1 insertion(+) diff --git a/contrib/lisp/org-odt.el b/contrib/lisp/org-odt.el index 16d6441d4..e7cf978ae 100644 --- a/contrib/lisp/org-odt.el +++ b/contrib/lisp/org-odt.el @@ -1741,6 +1741,7 @@ visually." (setq cache-dir "ltxpng/") (setq display-msg "Creating LaTeX image %s")) ((member latex-frag-opt '(mathjax t)) + (setq latex-frag-opt 'mathml) (setq cache-dir "ltxmathml/") (setq display-msg "Creating MathML formula %s"))) (when (and org-current-export-file) From 16333d4a53cbab35ea413fa63d21d6df305025ed Mon Sep 17 00:00:00 2001 From: Jambunathan K Date: Fri, 9 Sep 2011 00:38:31 +0530 Subject: [PATCH 32/47] org-lparse.el: Rename table routines * contrib/lisp/org-lparse.el (org-lparse-insert-org-table): Renamed from `org-lparse-do-format-org-table'. (org-lparse-insert-list-table): Renamed from `org-lparse-do-format-list-table. (org-lparse-insert-table-table): Renamed from `org-lparse-do-format-table-table'. (org-lparse-insert-org-table, org-lparse-format-org-table) (org-lparse-format-list-table, org-lparse-format-table-table): Propagate above renamings. * contrib/lisp/org-odt.el (org-export-odt-do-format-numbered-formula): Propagate above renamings. Maintain a clear distinction between format and insert behaviours. --- contrib/lisp/org-lparse.el | 14 +++++++------- contrib/lisp/org-odt.el | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/contrib/lisp/org-lparse.el b/contrib/lisp/org-lparse.el index 6e391c88f..39d94036e 100755 --- a/contrib/lisp/org-lparse.el +++ b/contrib/lisp/org-lparse.el @@ -1367,7 +1367,7 @@ form (FIELD1 FIELD2 FIELD3 ...) as appropriate." (push (org-split-string line "[ \t]*|[ \t]*") lines-1)))))) (nreverse lines-1))) -(defun org-lparse-do-format-org-table (lines &optional splice) +(defun org-lparse-insert-org-table (lines &optional splice) "Format a org-type table into backend-specific code. LINES is a list of lines. Optional argument SPLICE means, do not insert header and surrounding tags, just format the lines. @@ -1394,10 +1394,10 @@ for formatting. This is required for the DocBook exporter." (lambda (x) (string-match "^[ \t]*|-" x)) (cdr lines)))))) (setq lines (org-lparse-org-table-to-list-table lines splice)) - (org-lparse-do-format-list-table + (org-lparse-insert-list-table lines splice caption label attributes head org-lparse-table-colalign-info))) -(defun org-lparse-do-format-list-table (lines &optional splice +(defun org-lparse-insert-list-table (lines &optional splice caption label attributes head org-lparse-table-colalign-info) (or (featurep 'org-table) ; required for @@ -1433,15 +1433,15 @@ for formatting. This is required for the DocBook exporter." (defun org-lparse-format-org-table (lines &optional splice) (with-temp-buffer - (org-lparse-do-format-org-table lines splice) + (org-lparse-insert-org-table lines splice) (buffer-substring-no-properties (point-min) (point-max)))) (defun org-lparse-format-list-table (lines &optional splice) (with-temp-buffer - (org-lparse-do-format-list-table lines splice) + (org-lparse-insert-list-table lines splice) (buffer-substring-no-properties (point-min) (point-max)))) -(defun org-lparse-do-format-table-table (lines) +(defun org-lparse-insert-table-table (lines) "Format a table generated by table.el into backend-specific code. This conversion does *not* use `table-generate-source' from table.el. This has the advantage that Org-mode's HTML conversions can be used. @@ -1481,7 +1481,7 @@ But it has the disadvantage, that no cell- or row-spanning is allowed." (defun org-lparse-format-table-table (lines) (with-temp-buffer - (org-lparse-do-format-table-table lines) + (org-lparse-insert-table-table lines) (buffer-substring-no-properties (point-min) (point-max)))) (defvar table-source-languages) ; defined in table.el diff --git a/contrib/lisp/org-odt.el b/contrib/lisp/org-odt.el index e7cf978ae..53bd99372 100644 --- a/contrib/lisp/org-odt.el +++ b/contrib/lisp/org-odt.el @@ -1059,7 +1059,7 @@ value of `org-export-odt-use-htmlfontify." width height href) (with-temp-buffer (let ((org-lparse-table-colalign-info '((0 "c" "8") (0 "c" "1")))) - (org-lparse-do-format-list-table + (org-lparse-insert-list-table `((,(org-export-odt-do-format-formula ; caption and label ; should be nil embed-as nil attr nil width height href) From 28ae6b4de1912b1eb3678ea49d92139937d51a1b Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Fri, 9 Sep 2011 19:47:41 +0200 Subject: [PATCH 33/47] Revert "org.el (org-fixup-indentation): Correctly indent meta lines." This reverts commit 6b04befa48f2aed0a44d25bced54adeda4658bf0. --- lisp/org.el | 44 ++++++++++++-------------------------------- 1 file changed, 12 insertions(+), 32 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index d63b85485..d5bef6fde 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -7346,39 +7346,20 @@ After top level, it switches back to sibling level." However, if any line in the current entry has no indentation, or if it would end up with no indentation after the change, nothing at all is done." (save-excursion - (let* ((end (save-excursion (outline-next-heading) - (point-marker))) - ;; FIXME we should use `org-end-of-meta-data-and-drawers' - ;; here but it matches misplaced :END:... - (drawer-end (save-excursion - (and (re-search-forward - org-property-end-re end t) - (match-end 0)))) - (prohibit (if (> diff 0) - "^\\S-" - (concat "^ \\{0," (int-to-string (- diff)) "\\}\\S-"))) - col) - (while (re-search-forward - (concat "\\(" (regexp-opt org-all-time-keywords) - "\\|" "^[ \t]*" org-tsr-regexp-both "*$" - "\\|" "^[ \t]*:[a-zA-Z][a-zA-Z0-9_]*:.*$" - "\\)") (or drawer-end end) t) - (beginning-of-line) - (when (looking-at "^[ \t]+") + (let ((end (save-excursion (outline-next-heading) + (point-marker))) + (prohibit (if (> diff 0) + "^\\S-" + (concat "^ \\{0," (int-to-string (- diff)) "\\}\\S-"))) + col) + (unless (save-excursion (end-of-line 1) + (re-search-forward prohibit end t)) + (while (and (< (point) end) + (re-search-forward "^[ \t]+" end t)) (goto-char (match-end 0)) (setq col (current-column)) (if (< diff 0) (replace-match "")) - (org-indent-to-column (+ diff col)) - (if drawer-end (setq drawer-end (+ diff drawer-end)))) - (end-of-line)) - (unless (save-excursion (end-of-line 1) - (re-search-forward prohibit end t)) - (while (and (< (point) end) - (re-search-forward "^[ \t]+" end t)) - (goto-char (match-end 0)) - (setq col (current-column)) - (if (< diff 0) (replace-match "")) - (org-indent-to-column (+ diff col)))) + (org-indent-to-column (+ diff col)))) (move-marker end nil)))) (defun org-convert-to-odd-levels () @@ -13707,7 +13688,7 @@ Being in this list makes sure that they are offered for completion.") (defsubst org-re-property (property) "Return a regexp matching PROPERTY. -Match group 1 will be set to the value of the property." +Match group 1 will be set to the value " (concat "^[ \t]*:" (regexp-quote property) ":[ \t]*\\(\\S-.*\\)")) (defun org-property-action () @@ -20335,7 +20316,6 @@ If there is no such heading, return nil." (unless (eobp) (backward-char 1))) ad-do-it)) -;; FIXME This should not match :END: for custom drawers? (defun org-end-of-meta-data-and-drawers () "Jump to the first text after meta data and drawers in the current entry. This will move over empty lines, lines with planning time stamps, From bb0b9709ef84a747393eae74e009748255710447 Mon Sep 17 00:00:00 2001 From: Martyn Jago Date: Thu, 8 Sep 2011 16:50:26 +0100 Subject: [PATCH 34/47] * testing/lisp/test-ob.el: More tests for inline source blocks execution via org-ctrl-c-ctrl-c --- testing/lisp/test-ob.el | 172 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 172 insertions(+) diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el index e0f7c655c..9735bd890 100644 --- a/testing/lisp/test-ob.el +++ b/testing/lisp/test-ob.el @@ -236,6 +236,178 @@ (should-not (org-babel-get-inline-src-block-matches)) ))) +(ert-deftest test-org-babel/inline-src_blk-default-results-replace-line-1 () + (with-temp-buffer + + ;; src_ at bol line 1... + (let ((test-line "src_sh{echo 1}")) + (insert test-line) + (should-error (org-ctrl-c-ctrl-c)) + (goto-char (point-min)) (org-ctrl-c-ctrl-c) + (should (string= + (concat test-line " =1=") + (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) + (forward-char) (org-ctrl-c-ctrl-c) + (should (string= + (concat test-line " =1= =1=") + (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) + (re-search-forward "1}") + (should-error (org-ctrl-c-ctrl-c)) + (backward-char) ;; last char of block body + (org-ctrl-c-ctrl-c) + (should (string= + (concat test-line " =1= =1= =1=") + (buffer-substring-no-properties (point-at-bol) (point-at-eol))))) + + ;; src_ follows space line 1... + (let ((test-line " src_emacs-lisp{ 1 }")) + (beginning-of-line) + (insert (concat test-line "\n")) + (goto-char (point-min)) + (should-error (org-ctrl-c-ctrl-c)) + (forward-char) (org-ctrl-c-ctrl-c) + (should (string= + (concat test-line " =1=") + (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) + (re-search-forward "{ 1 ") (org-ctrl-c-ctrl-c) + (should (string= + (concat test-line " =1= =1=") + (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) + (forward-char) + (should-error (org-ctrl-c-ctrl-c)) + ))) + +(ert-deftest test-org-babel/inline-src_blk-default-results-replace-line-2 () + (with-temp-buffer + + ;; src_ at bol line 2... + (let ((test-line " src_emacs-lisp{ \"x\" }")) + (insert (concat "\n" test-line)) + (should-error (org-ctrl-c-ctrl-c)) + (goto-char (point-min)) + (should-error (org-ctrl-c-ctrl-c)) + (forward-line) + (should-error (org-ctrl-c-ctrl-c)) + (forward-char) (org-ctrl-c-ctrl-c) + (should (string= + (concat test-line " =x=") + (buffer-substring-no-properties (point-at-bol) (point-at-eol))))) + + (let ((test-line "Some text prior to block src_emacs-lisp{ \"y\" }")) + (goto-char (point-max)) + (insert (concat "\n" test-line " end")) + (re-search-backward "src") (org-ctrl-c-ctrl-c) + (should (string= + (concat test-line " =y= end") + (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) + (re-search-forward "\" ") (org-ctrl-c-ctrl-c) + (should (string= + (concat test-line " =y= =y= end") + (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) + (forward-char) + (should-error (org-ctrl-c-ctrl-c)) + ))) + +(ert-deftest test-org-babel/inline-src_blk-manual-results-replace () + (with-temp-buffer + + (let ((test-line " src_emacs-lisp[:results replace]{ \"x\" }")) + (insert (concat "\n" test-line)) + (should-error (org-ctrl-c-ctrl-c)) + (goto-char (point-min)) + (should-error (org-ctrl-c-ctrl-c)) + (forward-line) + (should-error (org-ctrl-c-ctrl-c)) + (forward-char) (org-ctrl-c-ctrl-c) + (should (string= + (concat test-line " =x=") + (buffer-substring-no-properties (point-at-bol) (point-at-eol))))) + + (let ((test-line " Some text prior to block src_emacs-lisp[:results replace]{ \"y\" }")) + (goto-char (point-max)) + (insert (concat "\n" test-line " end")) + (re-search-backward "src") (org-ctrl-c-ctrl-c) + (should (string= + (concat test-line " =y= end") + (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) + (re-search-forward "\" ") (org-ctrl-c-ctrl-c) + (should (string= + (concat test-line " =y= =y= end") + (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) + (forward-char) + (should-error (org-ctrl-c-ctrl-c))) + )) + +(ert-deftest test-org-babel/inline-src_blk-results-silent () + (with-temp-buffer + + (let ((test-line "src_emacs-lisp[ :results silent ]{ \"x\" }")) + (insert test-line) + (should-error (org-ctrl-c-ctrl-c)) + (goto-char (point-min)) (org-ctrl-c-ctrl-c) + (should (string= test-line + (buffer-substring-no-properties (point-at-bol) (point-at-eol))))) + (let ((test-line " Some text prior to block src_emacs-lisp[ :results silent ]{ \"y\" }")) + (goto-char (point-max)) + (insert (concat "\n" test-line " end")) + (re-search-backward "src_") (org-ctrl-c-ctrl-c) + (should (string= (concat test-line " end") + (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) + (re-search-forward "\" ") (org-ctrl-c-ctrl-c) + (should (string= (concat test-line " end") + (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) + (forward-char) + (should-error (org-ctrl-c-ctrl-c))) + )) + +(ert-deftest test-org-babel/inline-src_blk-results-raw () + (with-temp-buffer + + (let ((test-line "src_emacs-lisp[ :results raw ]{ \"x\" }")) + (insert test-line) + (goto-char (point-min)) (org-ctrl-c-ctrl-c) + (should (string= (concat test-line " x") + (buffer-substring-no-properties (point-at-bol) (point-at-eol))))) + (let ((test-line " Some text prior to block src_emacs-lisp[ :results raw ]{ \"the\" }")) + (goto-char (point-max)) + (insert (concat "\n" test-line " end")) + (re-search-backward "src_") (org-ctrl-c-ctrl-c) + (should (string= (concat test-line " the end") + (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) + (re-search-forward "\" ") (org-ctrl-c-ctrl-c) + (should (string= (concat test-line " the the end") + (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) + (forward-char) + (should-error (org-ctrl-c-ctrl-c))) + )) + +(ert-deftest test-org-babel/inline-src_blk-results-file () + (with-temp-buffer + + (let ((test-line "src_emacs-lisp[ :results file ]{ \"~/test-file\" }")) + (insert test-line) + (goto-char (point-min)) (org-ctrl-c-ctrl-c) + (should (string= (concat test-line " [[file:~/test-file]]") + (buffer-substring-no-properties (point-min) (point-max))))))) + +(ert-deftest test-org-babel/inline-src_blk-results-scaler () + (with-temp-buffer + + (let ((test-line "src_emacs-lisp[ :results scaler ]{ \"x\" }")) + (insert test-line) + (goto-char (point-min)) (org-ctrl-c-ctrl-c) + (should (string= (concat test-line " =x=") + (buffer-substring-no-properties (point-min) (point-max))))))) + +(ert-deftest test-org-babel/inline-src_blk-results-verbatim () + (with-temp-buffer + + (let ((test-line "src_emacs-lisp[ :results verbatim ]{ \"x\" }")) + (insert test-line) + (goto-char (point-min)) (org-ctrl-c-ctrl-c) + (should (string= (concat test-line " =\"x\"=") + (buffer-substring-no-properties (point-min) (point-max))))))) + (provide 'test-ob) ;;; test-ob ends here From 8fb588d4d32258936d939151a3c65084ab4f0feb Mon Sep 17 00:00:00 2001 From: Martyn Jago Date: Thu, 8 Sep 2011 22:34:38 +0100 Subject: [PATCH 35/47] * testing/lisp/test-ob.el: Fixed typo --- testing/lisp/test-ob.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el index 9735bd890..1f04c5b67 100644 --- a/testing/lisp/test-ob.el +++ b/testing/lisp/test-ob.el @@ -390,13 +390,13 @@ (should (string= (concat test-line " [[file:~/test-file]]") (buffer-substring-no-properties (point-min) (point-max))))))) -(ert-deftest test-org-babel/inline-src_blk-results-scaler () +(ert-deftest test-org-babel/inline-src_blk-results-scalar () (with-temp-buffer - (let ((test-line "src_emacs-lisp[ :results scaler ]{ \"x\" }")) + (let ((test-line "src_emacs-lisp[ :results scalar ]{ \"x\" }")) (insert test-line) (goto-char (point-min)) (org-ctrl-c-ctrl-c) - (should (string= (concat test-line " =x=") + (should (string= (concat test-line " =\"x\"=") (buffer-substring-no-properties (point-min) (point-max))))))) (ert-deftest test-org-babel/inline-src_blk-results-verbatim () From bae8dfed77219bc3133088e171886a0859b03647 Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Fri, 9 Sep 2011 14:21:06 -0600 Subject: [PATCH 36/47] Better Org-mode initialization for batch tests. Thanks to Martyn Jago for this patch. * testing/org-test.el (org-test-dir): Better Org-mode initialization for batch tests. --- testing/org-test.el | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/testing/org-test.el b/testing/org-test.el index 331dfa167..a8b5b49de 100644 --- a/testing/org-test.el +++ b/testing/org-test.el @@ -24,19 +24,26 @@ ;;;; Code: -(let* ((org-test-dir (expand-file-name +(let ((org-test-dir (expand-file-name (file-name-directory - (or load-file-name buffer-file-name)))) - (load-path (cons - (expand-file-name "ert" org-test-dir) - (cons - (expand-file-name "jump" org-test-dir) - load-path)))) - (require 'ert) - (require 'ert-x) - (require 'jump) - (require 'which-func) - (require 'org)) + (or load-file-name buffer-file-name))))) + (let ((org-lisp-dir (expand-file-name + (concat org-test-dir "../lisp")))) + (unless (member 'features "org") + (setq load-path (cons org-lisp-dir load-path)) + (org-babel-do-load-languages + 'org-babel-load-languages '((sh . t))))) + (let* ((load-path (cons + (expand-file-name "ert" org-test-dir) + (cons + (expand-file-name "jump" org-test-dir) + load-path)))) + (require 'ert) + (require 'ert-x) + (require 'jump) + (require 'which-func) + (require 'org))) + (defconst org-test-default-test-file-name "tests.el" "For each defun a separate file with tests may be defined. From 5a373f649e19155cab9fd43c0b22c86446a70ebf Mon Sep 17 00:00:00 2001 From: David Maus Date: Sun, 11 Sep 2011 16:01:59 +0200 Subject: [PATCH 37/47] Remove unnecessary link unescape * org-html.el (org-html-handle-links): Remove unnecessary link unescape. PATH is already unescaped and should never be escaped twice. Big thanks to Jambunathan K for analyzing the problem. --- lisp/org-html.el | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/lisp/org-html.el b/lisp/org-html.el index 28a0e8fec..fde563bc0 100644 --- a/lisp/org-html.el +++ b/lisp/org-html.el @@ -33,7 +33,7 @@ (declare-function org-id-find-id-file "org-id" (id)) (declare-function htmlize-region "ext:htmlize" (beg end)) -(declare-function org-pop-to-buffer-same-window +(declare-function org-pop-to-buffer-same-window "org-compat" (&optional buffer-or-name norecord label)) (defgroup org-export-html nil @@ -906,7 +906,7 @@ OPT-PLIST is the export options list." (string-match "^\\.\\.?/" path))) "file") (t "internal"))) - (setq path (org-extract-attributes (org-link-unescape path))) + (setq path (org-extract-attributes path)) (setq attr (get-text-property 0 'org-attributes path)) (setq desc1 (if (match-end 5) (match-string 5 line)) desc2 (if (match-end 2) (concat type ":" path) path) @@ -919,7 +919,7 @@ OPT-PLIST is the export options list." (if (string-match "^file:" desc) (setq desc (substring desc (match-end 0))))) (setq desc (org-add-props - (concat "\""") '(org-protected t)))) (cond @@ -1356,9 +1356,9 @@ lang=\"%s\" xml:lang=\"%s\"> (insert "\n\n"))) ;; begin wrap around body - (insert (format "\n
" + (insert (format "\n
" ;; FIXME org-export-html-content-div is obsolete since 7.7 - (or org-export-html-content-div + (or org-export-html-content-div (nth 1 org-export-html-divs))) ;; FIXME this should go in the preamble but is here so ;; that org-infojs can still find it @@ -1375,7 +1375,7 @@ lang=\"%s\" xml:lang=\"%s\"> (push "
\n" thetoc) (push "
    \n
  • " thetoc) (setq lines - (mapcar + (mapcar #'(lambda (line) (if (and (string-match org-todo-line-regexp line) (not (get-text-property 0 'org-protected line))) @@ -1401,7 +1401,7 @@ lang=\"%s\" xml:lang=\"%s\"> line lines level)))) (if (string-match (org-re "[ \t]+:\\([[:alnum:]_@:]+\\):[ \t]*$") txt) - (setq txt (replace-match + (setq txt (replace-match "    \\1" t nil txt))) (if (string-match quote-re0 txt) (setq txt (replace-match "" t t txt))) @@ -1429,7 +1429,7 @@ lang=\"%s\" xml:lang=\"%s\"> ;; Check for targets (while (string-match org-any-target-regexp line) (setq line (replace-match - (concat "@" + (concat "@" (match-string 1 line) "@ ") t t line))) (while (string-match "<\\(<\\)+\\|>\\(>\\)+" txt) @@ -1437,8 +1437,8 @@ lang=\"%s\" xml:lang=\"%s\"> (setq href (replace-regexp-in-string "\\." "-" (format "sec-%s" snumber))) - (setq href (org-solidify-link-text - (or (cdr (assoc href + (setq href (org-solidify-link-text + (or (cdr (assoc href org-export-preferred-target-alist)) href))) (push (format @@ -1446,7 +1446,7 @@ lang=\"%s\" xml:lang=\"%s\"> "
  • \n
  • %s" "
  • \n
  • %s") href txt) thetoc) - + (setq org-last-level level))))) line) lines)) @@ -1455,15 +1455,15 @@ lang=\"%s\" xml:lang=\"%s\"> (push "
  • \n
\n" thetoc)) (push "
\n" thetoc) (setq thetoc (if have-headings (nreverse thetoc) nil)))) - + (setq head-count 0) (org-init-section-numbers) - + (org-open-par) - + (while (setq line (pop lines) origline line) (catch 'nextline - + ;; end of quote section? (when (and inquote (string-match org-outline-regexp-bol line)) (insert "\n") @@ -1818,7 +1818,7 @@ lang=\"%s\" xml:lang=\"%s\"> (?d . ,date) (?c . ,creator-info) (?v . ,html-validation-link)))))) (insert "\n
")))) - + ;; FIXME `org-export-html-with-timestamp' has been declared ;; obsolete since Org 7.7 -- don't forget to remove this. (if org-export-html-with-timestamp @@ -1951,7 +1951,7 @@ NO-CSS is passed to the exporter." (if (string-match "^[ \t]*|" (car lines)) ;; A normal org table (org-format-org-table-html lines nil no-css) - ;; Table made by table.el + ;; Table made by table.el (or (org-format-table-table-html-using-table-generate-source olines (not org-export-prefer-native-exporter-for-tables)) ;; We are here only when table.el table has NO col or row From 4122a51366ad83ecea27c9df45dea9d89a538797 Mon Sep 17 00:00:00 2001 From: David Maus Date: Sun, 11 Sep 2011 16:50:22 +0200 Subject: [PATCH 38/47] Unescape plain link before open * org.el (org-open-at-point): Unescape plain link. This should fix a problem with open plain links reported by Sebastien Vauban. --- lisp/org.el | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index d5bef6fde..73b107341 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -365,10 +365,10 @@ In Emacs 23, when `shift-select-mode' is on, shifted cursor keys start selecting a region, or enlarge regions started in this way. In Org-mode, in special contexts, these same keys are used for other purposes, important enough to compete with shift selection. -Org tries to balance these needs by supporting `shift-select-mode' +Org tries to balance these needs by supporting `shift-select-mode' outside these special contexts, under control of this variable. -The default of this variable is nil, to avoid confusing behavior. Shifted +The default of this variable is nil, to avoid confusing behavior. Shifted cursor keys will then execute Org commands in the following contexts: - on a headline, changing TODO state (left/right) and priority (up/down) - on a time stamp, changing the time @@ -9392,7 +9392,8 @@ application the system uses for this file type." (save-excursion (when (or (org-in-regexp org-angle-link-re) (org-in-regexp org-plain-link-re)) - (setq type (match-string 1) path (match-string 2)) + (setq type (match-string 1) + path (org-link-unescape (match-string 2))) (throw 'match t))) (save-excursion (when (org-in-regexp (org-re "\\(:[[:alnum:]_@#%:]+\\):[ \t]*$")) @@ -9999,8 +10000,8 @@ If the file does not exist, an error is thrown." match) (progn (setq in-emacs (or in-emacs line search)) nil))) ; if we have no match in apps-dlink, - ; always open the file in emacs if line or search - ; is given (for backwards compatibility) + ; always open the file in emacs if line or search + ; is given (for backwards compatibility) (assoc-default dfile (org-apps-regexp-alist apps a-m-a-p) 'string-match) (cdr (assoc ext apps)) @@ -17089,7 +17090,7 @@ If not, return to the original position and throw an error." (defun org-speed-command-default-hook (keys) "Hook for activating single-letter speed commands. -`org-speed-commands-default' specifies a minimal command set. +`org-speed-commands-default' specifies a minimal command set. Use `org-speed-commands-user' for further customization." (when (or (and (bolp) (looking-at org-outline-regexp)) (and (functionp org-use-speed-commands) @@ -20504,7 +20505,7 @@ if no description is present" (progn (org-remove-from-invisibility-spec '(org-link)) (org-restart-font-lock) (setq org-descriptive-links nil)) - (progn (add-to-invisibility-spec '(org-link)) + (progn (add-to-invisibility-spec '(org-link)) (org-restart-font-lock) (setq org-descriptive-links t)))) From f78f29ebeafc493be066b4ff4114ed582c323dc9 Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Sun, 11 Sep 2011 14:19:02 -0600 Subject: [PATCH 39/47] all tests should now pass on Emacs23 * testing/lisp/test-ob.el (test-org-babel/org-babel-get-inline-src-block-matches): All tests should now pass on Emacs23. --- testing/lisp/test-ob.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el index 1f04c5b67..ecce41f72 100644 --- a/testing/lisp/test-ob.el +++ b/testing/lisp/test-ob.el @@ -226,9 +226,9 @@ (should (re-search-forward "echo" nil t)) ;; 2 (should (org-babel-get-inline-src-block-matches)) (should (re-search-forward "blocks" nil t)) ;; 3 - (left-char 8) ;; 3 + (backward-char 8) ;; 3 (should (org-babel-get-inline-src-block-matches)) - (right-char 1) ;;3 + (forward-char 1) ;;3 (should-not (org-babel-get-inline-src-block-matches)) (should (re-search-forward ":results" nil t)) ;; 4 (should (org-babel-get-inline-src-block-matches)) From f1fcc592fd9eadeed2daeb2bc10a0de590459306 Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Sun, 11 Sep 2011 14:35:13 -0600 Subject: [PATCH 40/47] re-wrapped test to prevent failure during batch execution * testing/lisp/test-ob.el (test-org-babel/inline-src-blocks): Re-wrapped test to prevent failure during batch execution. --- testing/lisp/test-ob.el | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el index ecce41f72..d51679862 100644 --- a/testing/lisp/test-ob.el +++ b/testing/lisp/test-ob.el @@ -204,13 +204,15 @@ (ert-deftest test-org-babel/inline-src-blocks () (org-test-at-id "54cb8dc3-298c-4883-a933-029b3c9d4b18" - (flet ((next () - (move-end-of-line 1) - (re-search-forward org-babel-inline-src-block-regexp nil t) - (goto-char (match-beginning 1)))) - (next) (should (equal 1 (org-babel-execute-src-block))) - (next) (should (equal 2 (org-babel-execute-src-block))) - (next) (should (equal 3 (org-babel-execute-src-block)))))) + (macrolet ((at-next (&rest body) + `(progn + (move-end-of-line 1) + (re-search-forward org-babel-inline-src-block-regexp nil t) + (goto-char (match-beginning 1)) + (save-match-data ,@body)))) + (at-next (should (equal 1 (org-babel-execute-src-block)))) + (at-next (should (equal 2 (org-babel-execute-src-block)))) + (at-next (should (equal 3 (org-babel-execute-src-block))))))) (ert-deftest test-org-babel/org-babel-get-inline-src-block-matches () (org-test-at-id "0D0983D4-DE33-400A-8A05-A225A567BC74" From 488a2e378caf5d3ab917814d969ab8efee0b0632 Mon Sep 17 00:00:00 2001 From: Jambunathan K Date: Mon, 12 Sep 2011 17:19:14 +0530 Subject: [PATCH 41/47] Replace OrgOdtAutomaticStyles.xml with OrgOdtContentTemplate.xml * contrib/odt/styles/OrgOdtAutomaticStyles.xml: Removed * contrib/odt/styles/OrgOdtContentTemplate.xml: Added. This file is now a fully-formed "content.xml" file but with "empty" content. Note that the original "OrgOdtAutomaticStyles.xml" was just an xml fragment. * contrib/lisp/org-odt.el (org-odt-document-content-header): Removed. (org-export-odt-automatic-styles-file): Removed. (org-export-odt-content-template-file): Renamed from `org-export-odt-automatic-styles-file'. (org-odt-data-dir): Update docstring. (org-odt-begin-office-body, org-odt-begin-document-content): Modified to accomodate changes introduced by the new "OrgOdtContentTemplate.xml" file. --- contrib/lisp/org-odt.el | 74 +++--------- contrib/odt/styles/OrgOdtContentTemplate.xml | 118 +++++++++++++++++++ 2 files changed, 136 insertions(+), 56 deletions(-) create mode 100644 contrib/odt/styles/OrgOdtContentTemplate.xml diff --git a/contrib/lisp/org-odt.el b/contrib/lisp/org-odt.el index 53bd99372..da3fbd571 100644 --- a/contrib/lisp/org-odt.el +++ b/contrib/lisp/org-odt.el @@ -76,9 +76,9 @@ "Directory that holds auxiliary files used by the ODT exporter. The 'styles' subdir contains the following xml files - - 'OrgOdtStyles.xml' and 'OrgOdtAutomaticStyles.xml' - which are + 'OrgOdtStyles.xml' and 'OrgOdtContentTemplate.xml' - which are used as factory settings of `org-export-odt-styles-file' and - `org-export-odt-automatic-styles-file'. + `org-export-odt-content-template-file'. The 'etc/schema' subdir contains rnc files for validating of OpenDocument xml files.") @@ -148,9 +148,13 @@ OpenDocument xml files.") 'org-export-odt-preprocess-latex-fragments) nil) -(defcustom org-export-odt-automatic-styles-file nil - "Automatic styles for use with ODT exporter. -If unspecified, the file under `org-odt-data-dir' is used." +(defcustom org-export-odt-content-template-file nil + "Template file for \"content.xml\". +The exporter embeds the exported content just before +\"\" element. + +If unspecified, the file named \"OrgOdtContentTemplate.xml\" +under `org-odt-data-dir' is used." :type 'file :group 'org-export-odt) @@ -428,16 +432,14 @@ PUB-DIR is set, use this as the publishing directory." ;;;_. control callbacks ;;;_ , document body (defun org-odt-begin-office-body () - (insert " - - - - - - - - - ")) + ;; automatic styles + (insert-file-contents + (or org-export-odt-content-template-file + (expand-file-name "styles/OrgOdtContentTemplate.xml" + org-odt-data-dir))) + (goto-char (point-min)) + (re-search-forward "" nil nil) + (delete-region (match-beginning 0) (point-max))) ;; Following variable is let bound when `org-do-lparse' is in ;; progress. See org-html.el. @@ -460,48 +462,8 @@ PUB-DIR is set, use this as the publishing directory." (org-lparse-insert-tag "") (org-lparse-insert-tag ""))) -(defconst org-odt-document-content-header - " - -") - (defun org-odt-begin-document-content (opt-plist) - ;; document header - (insert org-odt-document-content-header) - - ;; automatic styles - (insert-file-contents - (or org-export-odt-automatic-styles-file - (expand-file-name "styles/OrgOdtAutomaticStyles.xml" - org-odt-data-dir))) - (goto-char (point-max))) + (ignore)) (defun org-odt-end-document-content () (org-lparse-insert-tag "")) diff --git a/contrib/odt/styles/OrgOdtContentTemplate.xml b/contrib/odt/styles/OrgOdtContentTemplate.xml new file mode 100644 index 000000000..980f2646d --- /dev/null +++ b/contrib/odt/styles/OrgOdtContentTemplate.xml @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From c019c31bad9063addea47f0519698f13fb6437fc Mon Sep 17 00:00:00 2001 From: Jambunathan K Date: Mon, 12 Sep 2011 17:26:59 +0530 Subject: [PATCH 42/47] Fix previous commit --- contrib/odt/styles/OrgOdtAutomaticStyles.xml | 75 -------------------- 1 file changed, 75 deletions(-) delete mode 100644 contrib/odt/styles/OrgOdtAutomaticStyles.xml diff --git a/contrib/odt/styles/OrgOdtAutomaticStyles.xml b/contrib/odt/styles/OrgOdtAutomaticStyles.xml deleted file mode 100644 index d3f73bb83..000000000 --- a/contrib/odt/styles/OrgOdtAutomaticStyles.xml +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 7f62b224af99e507d8bb3852e5b6d720be389934 Mon Sep 17 00:00:00 2001 From: Martyn Jago Date: Mon, 12 Sep 2011 16:50:28 +0100 Subject: [PATCH 43/47] Remove jump.el dependency from test execution * testing/org-test.el: Remove jump.el dependency from test execution removing the need for a user to install git submodules --- testing/org-test.el | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/testing/org-test.el b/testing/org-test.el index a8b5b49de..136a287ee 100644 --- a/testing/org-test.el +++ b/testing/org-test.el @@ -16,11 +16,13 @@ ;; called while in a `defun' all ert tests with names matching the ;; name of the function are run. -;;; Prerequisites: - -;; ERT and jump.el are both included as git submodules, install with -;; $ git submodule init -;; $ git submodule update +;;; Test Development +;; For test development purposes a number of navigation and test +;; function construction routines are available as a git submodule +;; (jump.el) +;; Install with... +;; $ git submodule init +;; $ git submodule update ;;;; Code: @@ -38,13 +40,15 @@ (cons (expand-file-name "jump" org-test-dir) load-path)))) + (require 'cl) (require 'ert) (require 'ert-x) - (require 'jump) - (require 'which-func) + (when (file-exists-p + (expand-file-name "jump/jump.el" org-test-dir)) + (require 'jump) + (require 'which-func)) (require 'org))) - (defconst org-test-default-test-file-name "tests.el" "For each defun a separate file with tests may be defined. tests.el is the fallback or default if you like.") @@ -136,6 +140,7 @@ files." ;;; Navigation Functions +(when (featurep 'jump) (defjump org-test-jump (("lisp/\\1.el" . "testing/lisp/test-\\1.el") ("lisp/\\1.el" . "testing/lisp/\\1.el/test.*.el") @@ -178,7 +183,7 @@ files." " (should-error (error \"errr...\")))\n\n\n" "(provide '" name ")\n\n" ";;; " file-name " ends here\n") full-path)) - (lambda () ((lambda (res) (if (listp res) (car res) res)) (which-function)))) + (lambda () ((lambda (res) (if (listp res) (car res) res)) (which-function))))) (define-key emacs-lisp-mode-map "\M-\C-j" 'org-test-jump) From fd1e005e331883c2527a9835239d00533cadd623 Mon Sep 17 00:00:00 2001 From: Martyn Jago Date: Mon, 12 Sep 2011 17:07:21 +0100 Subject: [PATCH 44/47] Add missing FSF / author headers and org-test dependency to some test files * testing/lisp/test-ob-awk.el: * testing/lisp/test-ob-fortran.el: * testing/lisp/test-ob-lilypond.el: * testing/lisp/test-ob.el: * testing/lisp/test-org-exp.el: Add missing FSF / author headers and org-test dependency to some test files. --- testing/lisp/test-ob-awk.el | 16 ++++++++++++++++ testing/lisp/test-ob-fortran.el | 16 ++++++++++++++++ testing/lisp/test-ob-lilypond.el | 19 +++++++++++++++++-- testing/lisp/test-ob.el | 1 - testing/lisp/test-org-exp.el | 15 +++++++++++++++ 5 files changed, 64 insertions(+), 3 deletions(-) diff --git a/testing/lisp/test-ob-awk.el b/testing/lisp/test-ob-awk.el index 018dec4c7..34752f582 100644 --- a/testing/lisp/test-ob-awk.el +++ b/testing/lisp/test-ob-awk.el @@ -1,3 +1,18 @@ +;;; test-ob-awk.el --- tests for ob-awk.el + +;; Copyright (c) 2010 Eric Schulte +;; Authors: Eric Schulte + +;; Released under the GNU General Public License version 3 +;; see: http://www.gnu.org/licenses/gpl-3.0.html + +(let ((load-path (cons (expand-file-name + ".." (file-name-directory + (or load-file-name buffer-file-name))) + load-path))) + (require 'org-test) + (require 'org-test-ob-consts)) + (require 'ob-awk) (ert-deftest ob-awk/input-none () @@ -17,3 +32,4 @@ (org-test-at-id "9e998b2a-3581-43fe-b26d-07d3c507b86a" (org-babel-next-src-block 3) (should (= 150 (org-babel-execute-src-block))))) + diff --git a/testing/lisp/test-ob-fortran.el b/testing/lisp/test-ob-fortran.el index c3bde0b75..1b9fb75ed 100644 --- a/testing/lisp/test-ob-fortran.el +++ b/testing/lisp/test-ob-fortran.el @@ -1,3 +1,18 @@ +;;; test-ob-fortran.el --- tests for ob-fortran.el + +;; Copyright (c) 2010 Eric Schulte +;; Authors: Eric Schulte + +;; Released under the GNU General Public License version 3 +;; see: http://www.gnu.org/licenses/gpl-3.0.html + +(let ((load-path (cons (expand-file-name + ".." (file-name-directory + (or load-file-name buffer-file-name))) + load-path))) + (require 'org-test) + (require 'org-test-ob-consts)) + (let ((load-path (cons (expand-file-name "langs" (expand-file-name @@ -11,6 +26,7 @@ (file-name-directory (or load-file-name buffer-file-name))))))) load-path))) + (require 'ob-fortran)) (ert-deftest ob-fortran/assert () diff --git a/testing/lisp/test-ob-lilypond.el b/testing/lisp/test-ob-lilypond.el index 8469823cb..2ca0597b1 100644 --- a/testing/lisp/test-ob-lilypond.el +++ b/testing/lisp/test-ob-lilypond.el @@ -1,11 +1,26 @@ +;;; test-ob-lilypond.el --- tests for ob-lilypond.el + +;; Copyright (c) 2010 Martyn Jago +;; Authors: Martyn Jago + +;; Released under the GNU General Public License version 3 +;; see: http://www.gnu.org/licenses/gpl-3.0.html + +(let ((load-path (cons (expand-file-name + ".." (file-name-directory + (or load-file-name buffer-file-name))) + load-path))) + (require 'org-test) + (require 'org-test-ob-consts)) + +(require 'ob-lilypond) + (save-excursion (set-buffer (get-buffer-create "test-ob-lilypond.el")) (setq ly-here (file-name-directory (or load-file-name (buffer-file-name))))) -(require 'ob-lilypond) - (ert-deftest ob-lilypond/assert () (should t)) diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el index d51679862..1ed9474b7 100644 --- a/testing/lisp/test-ob.el +++ b/testing/lisp/test-ob.el @@ -12,7 +12,6 @@ load-path))) (require 'org-test) (require 'org-test-ob-consts)) - (require 'org-test) (ert-deftest test-org-babel/src-name-regexp () (should(equal "^[ \t]*#\\+\\(srcname\\|source\\|function\\):[ \t]*" diff --git a/testing/lisp/test-org-exp.el b/testing/lisp/test-org-exp.el index b7d7387fc..348538fe9 100644 --- a/testing/lisp/test-org-exp.el +++ b/testing/lisp/test-org-exp.el @@ -1,3 +1,18 @@ +;;; test-org-exp.el --- tests for org-exp.el + +;; Copyright (c) 2010 Eric Schulte +;; Authors: Eric Schulte + +;; Released under the GNU General Public License version 3 +;; see: http://www.gnu.org/licenses/gpl-3.0.html + +(let ((load-path (cons (expand-file-name + ".." (file-name-directory + (or load-file-name buffer-file-name))) + load-path))) + (require 'org-test) + (require 'org-test-ob-consts)) + (ert-deftest test-org-exp/stripping-commas () "Test the stripping of commas from within blocks during export." (org-test-at-id "76d3a083-67fa-4506-a41d-837cc48158b5" From dbf0e6d5bcbe94c8ee57d68889d3c25bf9cdef55 Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Mon, 12 Sep 2011 10:42:22 -0600 Subject: [PATCH 45/47] fixed author information * testing/lisp/test-ob-awk.el: Fixed author information. * testing/lisp/test-ob-fortran.el: Fixed author information. --- testing/lisp/test-ob-awk.el | 4 ++-- testing/lisp/test-ob-fortran.el | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/testing/lisp/test-ob-awk.el b/testing/lisp/test-ob-awk.el index 34752f582..261f8fd08 100644 --- a/testing/lisp/test-ob-awk.el +++ b/testing/lisp/test-ob-awk.el @@ -1,7 +1,7 @@ ;;; test-ob-awk.el --- tests for ob-awk.el -;; Copyright (c) 2010 Eric Schulte -;; Authors: Eric Schulte +;; Copyright (c) 2010 Sergey Litvinov +;; Authors: Sergey Litvinov ;; Released under the GNU General Public License version 3 ;; see: http://www.gnu.org/licenses/gpl-3.0.html diff --git a/testing/lisp/test-ob-fortran.el b/testing/lisp/test-ob-fortran.el index 1b9fb75ed..d4ccbabce 100644 --- a/testing/lisp/test-ob-fortran.el +++ b/testing/lisp/test-ob-fortran.el @@ -1,7 +1,7 @@ ;;; test-ob-fortran.el --- tests for ob-fortran.el -;; Copyright (c) 2010 Eric Schulte -;; Authors: Eric Schulte +;; Copyright (c) 2010 Sergey Litvinov +;; Authors: Sergey Litvinov ;; Released under the GNU General Public License version 3 ;; see: http://www.gnu.org/licenses/gpl-3.0.html From 597e1eb4fe7b2674c2d5233f215217f7b35e4035 Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Tue, 13 Sep 2011 08:57:29 -0600 Subject: [PATCH 46/47] Don't error on empty code block body. * lisp/ob.el (org-babel-parse-src-block-match): Don't error on empty code block body. --- lisp/ob.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lisp/ob.el b/lisp/ob.el index 9f70c0bc1..7c00f648c 100644 --- a/lisp/ob.el +++ b/lisp/ob.el @@ -1021,7 +1021,8 @@ may be specified in the current buffer." (body (org-babel-clean-text-properties (let* ((body (match-string 5)) (sub-length (- (length body) 1))) - (if (string= "\n" (substring body sub-length)) + (if (and (> sub-length 0) + (string= "\n" (substring body sub-length))) (substring body 0 sub-length) body)))) (preserve-indentation (or org-src-preserve-indentation From 0037ef9261e3d31315d9606e4bd421c1abba4c57 Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Tue, 13 Sep 2011 09:36:03 -0600 Subject: [PATCH 47/47] more robust to code blocks with empty bodies * lisp/ob.el (org-babel-parse-src-block-match): More robust to code blocks with empty bodies. --- lisp/ob.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/ob.el b/lisp/ob.el index 7c00f648c..db8b50a6f 100644 --- a/lisp/ob.el +++ b/lisp/ob.el @@ -1024,7 +1024,7 @@ may be specified in the current buffer." (if (and (> sub-length 0) (string= "\n" (substring body sub-length))) (substring body 0 sub-length) - body)))) + (or body ""))))) (preserve-indentation (or org-src-preserve-indentation (string-match "-i\\>" switches)))) (list lang