summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Guerry <bzg@altern.org>2013-01-30 09:46:43 (GMT)
committer Bastien Guerry <bzg@altern.org>2013-01-30 09:46:43 (GMT)
commit35f944aaf06cf4403fa99df030483c17b03aad44 (patch)
tree88d2993cd2f1caaed9082a5e549c9f566ffb613b
parent08c2938e7db0ae65b104759d74d67566b0d5c66f (diff)
downloadorg-mode-35f944aaf06cf4403fa99df030483c17b03aad44.zip
org-mode-35f944aaf06cf4403fa99df030483c17b03aad44.tar.gz
org-e-odt.el (org-e-odt--export-wrap): Use `condition-case'
* org-e-odt.el (org-e-odt--export-wrap): Use `condition-case'.
-rw-r--r--contrib/lisp/org-e-odt.el176
1 files changed, 88 insertions, 88 deletions
diff --git a/contrib/lisp/org-e-odt.el b/contrib/lisp/org-e-odt.el
index 5953cc6..b52d5ef 100644
--- a/contrib/lisp/org-e-odt.el
+++ b/contrib/lisp/org-e-odt.el
@@ -3434,94 +3434,94 @@ contextual information."
;; Delete temporary directory and also other embedded
;; files that get copied there.
(delete-directory org-e-odt-zip-dir t)))))
- (org-condition-case-unless-debug
- err
- (progn
- (unless (executable-find "zip")
- ;; Not at all OSes ship with zip by default
- (error "Executable \"zip\" needed for creating OpenDocument files"))
- ;; Do export. This creates a bunch of xml files ready to be
- ;; saved and zipped.
- (progn ,@body)
- ;; Create a manifest entry for content.xml.
- (org-e-odt-create-manifest-file-entry "text/xml" "content.xml")
-
- ;; Write mimetype file
- (let* ((mimetypes
- '(("odt" . "application/vnd.oasis.opendocument.text")
- ("odf" . "application/vnd.oasis.opendocument.formula")))
- (mimetype (cdr (assoc-string out-file-type mimetypes t))))
- (unless mimetype
- (error "Unknown OpenDocument backend %S" out-file-type))
- (write-region mimetype nil (concat org-e-odt-zip-dir "mimetype"))
- (org-e-odt-create-manifest-file-entry mimetype "/" "1.2"))
- ;; Write out the manifest entries before zipping
- (org-e-odt-write-manifest-file)
- ;; Save all XML files.
- (mapc (lambda (file)
- (let ((buf (get-file-buffer (concat org-e-odt-zip-dir file))))
- (when buf
- (with-current-buffer buf
- ;; Prettify output if needed.
- (when org-e-odt-prettify-xml
- (indent-region (point-min) (point-max)))
- (save-buffer 0)))))
- org-e-odt-xml-files)
- ;; Run zip.
- (let* ((target --out-file)
- (target-name (file-name-nondirectory target))
- (target-dir (file-name-directory target))
- (cmds `(("zip" "-mX0" ,target-name "mimetype")
- ("zip" "-rmTq" ,target-name "."))))
- ;; If a file with same name as the desired output file
- ;; exists, remove it.
- (when (file-exists-p target)
- (delete-file target))
- ;; Zip up the xml files.
- (let ((coding-system-for-write 'no-conversion) exitcode err-string)
- (message "Creating ODT file...")
- ;; Switch temporarily to content.xml. This way Zip
- ;; process will inherit `org-e-odt-zip-dir' as the current
- ;; directory.
- (with-current-buffer
- (find-file-noselect (concat org-e-odt-zip-dir "content.xml") t)
- (mapc
- (lambda (cmd)
- (message "Running %s" (mapconcat 'identity cmd " "))
- (setq err-string
- (with-output-to-string
- (setq exitcode
- (apply 'call-process (car cmd)
- nil standard-output nil (cdr cmd)))))
- (or (zerop exitcode)
- (error (concat "Unable to create OpenDocument file."
- (format " Zip failed with error (%s)"
- err-string)))))
- cmds)
- ;; Zip file is now in the rightful place.
- (rename-file target-name target)))
- (message "Created %s" target)
- ;; Cleanup work directory and work files.
- (funcall --cleanup-xml-buffers)
- ;; Open the OpenDocument file in archive-mode for
- ;; examination.
- (find-file-noselect target t)
- ;; Return exported file.
- (cond
- ;; Case 1: Conversion desired on exported file. Run the
- ;; converter on the OpenDocument file. Return the
- ;; converted file.
- (org-e-odt-preferred-output-format
- (or (org-e-odt-convert target org-e-odt-preferred-output-format)
- target))
- ;; Case 2: No further conversion. Return exported
- ;; OpenDocument file.
- (t target))))
- ((quit error)
- ;; Cleanup work directory and work files.
- (funcall --cleanup-xml-buffers)
- (message "OpenDocument export failed: %s"
- (error-message-string err))))))
+ (condition-case
+ err
+ (progn
+ (unless (executable-find "zip")
+ ;; Not at all OSes ship with zip by default
+ (error "Executable \"zip\" needed for creating OpenDocument files"))
+ ;; Do export. This creates a bunch of xml files ready to be
+ ;; saved and zipped.
+ (progn ,@body)
+ ;; Create a manifest entry for content.xml.
+ (org-e-odt-create-manifest-file-entry "text/xml" "content.xml")
+
+ ;; Write mimetype file
+ (let* ((mimetypes
+ '(("odt" . "application/vnd.oasis.opendocument.text")
+ ("odf" . "application/vnd.oasis.opendocument.formula")))
+ (mimetype (cdr (assoc-string out-file-type mimetypes t))))
+ (unless mimetype
+ (error "Unknown OpenDocument backend %S" out-file-type))
+ (write-region mimetype nil (concat org-e-odt-zip-dir "mimetype"))
+ (org-e-odt-create-manifest-file-entry mimetype "/" "1.2"))
+ ;; Write out the manifest entries before zipping
+ (org-e-odt-write-manifest-file)
+ ;; Save all XML files.
+ (mapc (lambda (file)
+ (let ((buf (get-file-buffer (concat org-e-odt-zip-dir file))))
+ (when buf
+ (with-current-buffer buf
+ ;; Prettify output if needed.
+ (when org-e-odt-prettify-xml
+ (indent-region (point-min) (point-max)))
+ (save-buffer 0)))))
+ org-e-odt-xml-files)
+ ;; Run zip.
+ (let* ((target --out-file)
+ (target-name (file-name-nondirectory target))
+ (target-dir (file-name-directory target))
+ (cmds `(("zip" "-mX0" ,target-name "mimetype")
+ ("zip" "-rmTq" ,target-name "."))))
+ ;; If a file with same name as the desired output file
+ ;; exists, remove it.
+ (when (file-exists-p target)
+ (delete-file target))
+ ;; Zip up the xml files.
+ (let ((coding-system-for-write 'no-conversion) exitcode err-string)
+ (message "Creating ODT file...")
+ ;; Switch temporarily to content.xml. This way Zip
+ ;; process will inherit `org-e-odt-zip-dir' as the current
+ ;; directory.
+ (with-current-buffer
+ (find-file-noselect (concat org-e-odt-zip-dir "content.xml") t)
+ (mapc
+ (lambda (cmd)
+ (message "Running %s" (mapconcat 'identity cmd " "))
+ (setq err-string
+ (with-output-to-string
+ (setq exitcode
+ (apply 'call-process (car cmd)
+ nil standard-output nil (cdr cmd)))))
+ (or (zerop exitcode)
+ (error (concat "Unable to create OpenDocument file."
+ (format " Zip failed with error (%s)"
+ err-string)))))
+ cmds)
+ ;; Zip file is now in the rightful place.
+ (rename-file target-name target)))
+ (message "Created %s" target)
+ ;; Cleanup work directory and work files.
+ (funcall --cleanup-xml-buffers)
+ ;; Open the OpenDocument file in archive-mode for
+ ;; examination.
+ (find-file-noselect target t)
+ ;; Return exported file.
+ (cond
+ ;; Case 1: Conversion desired on exported file. Run the
+ ;; converter on the OpenDocument file. Return the
+ ;; converted file.
+ (org-e-odt-preferred-output-format
+ (or (org-e-odt-convert target org-e-odt-preferred-output-format)
+ target))
+ ;; Case 2: No further conversion. Return exported
+ ;; OpenDocument file.
+ (t target))))
+ ((quit error)
+ ;; Cleanup work directory and work files.
+ (funcall --cleanup-xml-buffers)
+ (message "OpenDocument export failed: %s"
+ (error-message-string err))))))