From 26d0c053b4cfe0276a3691536260984bf6279664 Mon Sep 17 00:00:00 2001 From: Jambunathan K Date: Sun, 11 Nov 2012 00:26:20 +0530 Subject: [PATCH] org-e-odt.el: Honor `org-export-with-date' * etc/styles/OrgOdtStyles.xml (OrgDate): New date style. * contrib/lisp/org-e-odt.el (org-e-odt--date): Misc. change. (org-e-odt-template): Honor `org-export-with-date'. --- contrib/lisp/org-e-odt.el | 79 ++++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 38 deletions(-) diff --git a/contrib/lisp/org-e-odt.el b/contrib/lisp/org-e-odt.el index c8257d0b2..1018b95b8 100644 --- a/contrib/lisp/org-e-odt.el +++ b/contrib/lisp/org-e-odt.el @@ -914,18 +914,16 @@ style from the list." ;;;; Date (defun org-e-odt--date (&optional org-ts fmt) - (save-match-data - (let* ((time - (and (stringp org-ts) - (string-match org-ts-regexp0 org-ts) - (apply 'encode-time - (org-fix-decoded-time - (org-parse-time-string (match-string 0 org-ts) t))))) - date) - (cond - (fmt (format-time-string fmt time)) - (t (setq date (format-time-string "%Y-%m-%dT%H:%M:%S%z" time)) - (format "%s:%s" (substring date 0 -2) (substring date -2))))))) + (let* ((t1 (and (stringp org-ts) + (string-match org-ts-regexp0 org-ts) + (org-parse-time-string (match-string 0 org-ts) t))) + (with-hm (and (nth 1 t1) (nth 2 t1))) + (time (and t1 (apply 'encode-time (org-fix-decoded-time t1)))) + date) + (cond + (fmt (format-time-string fmt time)) + (t (setq date (format-time-string "%Y-%m-%dT%H:%M:%S%z" time)) + (format "%s:%s" (substring date 0 -2) (substring date -2)))))) ;;;; Frame @@ -1130,8 +1128,6 @@ original parsed data. INFO is a plist holding export options." (let ((title (org-export-data (plist-get info :title) info)) (author (let ((author (plist-get info :author))) (if (not author) "" (org-export-data author info)))) - (date (org-e-odt--date - (org-export-data (plist-get info :date) info))) (email (plist-get info :email)) (keywords (plist-get info :keywords)) (description (plist-get info :description))) @@ -1148,8 +1144,13 @@ original parsed data. INFO is a plist holding export options." \n" (format "%s\n" author) (format "%s\n" author) - (format "%s\n" date) - (format "%s\n" date) + ;; Date, if required. + (when (plist-get info :with-date) + (let ((date (org-e-odt--date (org-export-data + (plist-get info :date) info)))) + (concat + (format "%s\n" date) + (format "%s\n" date)))) (format "%s\n" (let ((creator-info (plist-get info :with-creator))) (if (or (not creator-info) (eq creator-info 'comment)) "" @@ -1289,33 +1290,29 @@ original parsed data. INFO is a plist holding export options." (author (and (plist-get info :with-author) (let ((auth (plist-get info :author))) (and auth (org-export-data auth info))))) - (date (org-export-data (plist-get info :date) info)) - (iso-date (org-e-odt--date date)) - (date (org-e-odt--date date "%d %b %Y")) (email (plist-get info :email)) - ;; switch on or off above vars based on user settings + ;; Switch on or off above vars based on user settings (author (and (plist-get info :with-author) (or author email))) - ;; (date (and (plist-get info :time-stamp-file) date)) (email (and (plist-get info :with-email) email))) (concat - ;; title + ;; Title. (when title (concat (format "\n%s" "OrgTitle" (format "\n%s" title)) - ;; separator + ;; Separator. "\n")) (cond ((and author (not email)) - ;; author only + ;; Author only. (concat (format "\n%s" "OrgSubtitle" (format "%s" author)) - ;; separator + ;; Separator. "\n")) ((and author email) - ;; author and email + ;; Author and E-mail. (concat (format "\n%s" @@ -1324,20 +1321,26 @@ original parsed data. INFO is a plist holding export options." "%s" (concat "mailto:" email) (format "%s" author))) - ;; separator + ;; Separator. "\n"))) - ;; date - (when date - (concat - (format - "\n%s" - "OrgSubtitle" - (format - "\n%s" + ;; Date, if required. + (when (plist-get info :with-date) + (let* ((date (org-export-data (plist-get info :date) info)) + (iso-date (org-e-odt--date date)) + ;; Note that OrgOdtStyles.xml uses en/GB. Render the + ;; date in a style that is consistent with + ;; "OrgDate"-style. + (date (org-e-odt--date date "%d/%m/%Y"))) + (concat + (format + "\n%s" + "OrgSubtitle" + (format + "\n%s" - "OrgDate" iso-date date)) - ;; separator - ""))))) + "OrgDate" iso-date date)) + ;; Separator + "")))))) ;; Table of Contents (let* ((with-toc (plist-get info :with-toc)) (depth (and with-toc (if (wholenump with-toc) -- 2.11.4.GIT