diff options
author | Christian Egli <christian.egli@alumni.ethz.ch> | 2011-09-07 15:45:40 +0200 |
---|---|---|
committer | Christian Egli <christian.egli@alumni.ethz.ch> | 2011-09-07 15:45:40 +0200 |
commit | 2178b635455fbeacfe447a94fb2bbf95ccc9622e (patch) | |
tree | 164f358b8e76e76ee6e1f30f1db357e6d7473aa6 | |
parent | 14304f6dcd18df99f39e47bd07e998ead382c3d1 (diff) | |
parent | f1746a51185083b9368810d2d013e73332f90301 (diff) | |
download | org-mode-2178b635455fbeacfe447a94fb2bbf95ccc9622e.tar.gz |
Merge branch 'master' of orgmode.org:org-mode
-rw-r--r-- | contrib/lisp/org-elisp-symbol.el | 4 | ||||
-rw-r--r-- | contrib/lisp/org-odt.el | 74 | ||||
-rw-r--r-- | lisp/org-exp.el | 10 | ||||
-rw-r--r-- | testing/examples/org-exp.org | 14 | ||||
-rw-r--r-- | testing/lisp/test-ob-fortran.el | 17 | ||||
-rw-r--r-- | testing/lisp/test-ob-lob.el | 25 | ||||
-rw-r--r-- | testing/lisp/test-org-exp.el | 8 | ||||
-rw-r--r-- | testing/lisp/test-org.el | 12 |
8 files changed, 95 insertions, 69 deletions
diff --git a/contrib/lisp/org-elisp-symbol.el b/contrib/lisp/org-elisp-symbol.el index e614e97..6eb8114 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)) diff --git a/contrib/lisp/org-odt.el b/contrib/lisp/org-odt.el index 37d33d4..33ad426 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 - (with-current-buffer (find-file-noselect content-file t) - (erase-buffer)) - - ;; 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) + (content-file (expand-file-name "content.xml" outdir))) + + ;; init conten.xml + (with-current-buffer (find-file-noselect content-file t)) + + ;; 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))) @@ -1544,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 " diff --git a/lisp/org-exp.el b/lisp/org-exp.el index f795fbd..42b26e4 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) diff --git a/testing/examples/org-exp.org b/testing/examples/org-exp.org new file mode 100644 index 0000000..e101335 --- /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-ob-fortran.el b/testing/lisp/test-ob-fortran.el index 1eb58b8..c3bde0b 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 60f9399..ebfc14a 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-exp.el b/testing/lisp/test-org-exp.el new file mode 100644 index 0000000..b7d7387 --- /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))))) diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index 85a3e4a..1c81fac 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 |