From 7d1711266a7879736202b0d1f8fb04b8eabdf3f3 Mon Sep 17 00:00:00 2001 From: Vaidheeswaran C Date: Mon, 2 Mar 2015 22:45:42 +0530 Subject: [PATCH] ox-odt: Implement `org-odt-format-{headline, inlinetask}-default-function' * lisp/ox-odt.el (org-odt-format-headline-function): Set this to `org-odt-format-headline-default-function'. (org-odt-format-headline-default-function): New. Based on `org-odt-format-headline'. (org-odt-format-headline): Remove it. (org-odt-format-toc-headline): Change signature. (org-odt-format-headline--wrap): Change signature. Propagate above changes. (org-odt-format-inlinetask-function): Set this to `org-odt-format-inlinetask-default-function'. (org-odt-inlinetask): Use `:odt-format-inlinetask-function'. (org-odt-format-inlinetask-default-function): New. Factored out from `org-odt-inlinetask'. Port more of 3c22bb19e025e350ebcc25c6fc23e2dd59e49693. --- lisp/ox-odt.el | 92 ++++++++++++++++++++++++++++++---------------------------- 1 file changed, 48 insertions(+), 44 deletions(-) diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el index 4aaf6d302..0eecadb4a 100644 --- a/lisp/ox-odt.el +++ b/lisp/ox-odt.el @@ -649,7 +649,8 @@ The default value simply returns the value of CONTENTS." ;;;; Headline -(defcustom org-odt-format-headline-function 'ignore +(defcustom org-odt-format-headline-function + 'org-odt-format-headline-default-function "Function to format headline text. This function will be called with 5 arguments: @@ -668,7 +669,8 @@ The function result will be used as headline text." ;;;; Inlinetasks -(defcustom org-odt-format-inlinetask-function 'ignore +(defcustom org-odt-format-inlinetask-function + 'org-odt-format-inlinetask-default-function "Function called to format an inlinetask in ODT code. The function must accept six parameters: @@ -1277,7 +1279,7 @@ See `org-odt--build-date-styles' for implementation details." (defun* org-odt-format-toc-headline (todo todo-type priority text tags - &key level section-number headline-label &allow-other-keys) + &key level section-number headline-label) (setq text (concat ;; Section number. @@ -1919,9 +1921,10 @@ CONTENTS is nil. INFO is a plist holding contextual information." ;;;; Headline -(defun* org-odt-format-headline - (todo todo-type priority text tags - &key level section-number headline-label &allow-other-keys) +(defun org-odt-format-headline-default-function + (todo todo-type priority text tags) + "Default format function for a headline. +See `org-odt-format-headline-function' for details." (concat ;; Todo. (when todo @@ -1947,8 +1950,7 @@ CONTENTS is nil. INFO is a plist holding contextual information." "OrgTag" tag)) tags " : ")))))) (defun org-odt-format-headline--wrap (headline backend info - &optional format-function - &rest extra-keys) + &optional format-function) "Transcode a HEADLINE element using BACKEND. INFO is a plist holding contextual information." (setq backend (or backend (plist-get info :back-end))) @@ -1970,19 +1972,17 @@ INFO is a plist holding contextual information." (org-export-get-tags headline info))) (headline-label (concat "sec-" (mapconcat 'number-to-string headline-number "-"))) - (format-function (cond - ((functionp format-function) format-function) - ((not (eq (plist-get info :odt-format-headline-function) 'ignore)) - (function* - (lambda (todo todo-type priority text tags - &allow-other-keys) - (funcall (plist-get info :odt-format-headline-function) - todo todo-type priority text tags)))) - (t 'org-odt-format-headline)))) - (apply format-function - todo todo-type priority text tags - :headline-label headline-label :level level - :section-number section-number extra-keys))) + (format-function + (if (functionp format-function) format-function + (function* + (lambda (todo todo-type priority text tags + &key level section-number headline-label) + (funcall (plist-get info :odt-format-headline-function) + todo todo-type priority text tags)))))) + (funcall format-function + todo todo-type priority text tags + :level level :section-number section-number + :headline-label headline-label))) (defun org-odt-headline (headline contents info) "Transcode a HEADLINE element from Org to ODT. @@ -2097,29 +2097,33 @@ contextual information." "Transcode an INLINETASK element from Org to ODT. CONTENTS holds the contents of the block. INFO is a plist holding contextual information." - (cond - ;; If `org-odt-format-inlinetask-function' is not 'ignore, call it - ;; with appropriate arguments. - ((not (eq (plist-get info :odt-format-inlinetask-function) 'ignore)) - (let ((format-function - (function* - (lambda (todo todo-type priority text tags - &key contents &allow-other-keys) - (funcall (plist-get info :odt-format-inlinetask-function) - todo todo-type priority text tags contents))))) - (org-odt-format-headline--wrap - inlinetask nil info format-function :contents contents))) - ;; Otherwise, use a default template. - (t - (format "\n%s" - "Text_20_body" - (org-odt--textbox - (concat - (format "\n%s" - "OrgInlineTaskHeading" - (org-odt-format-headline--wrap inlinetask nil info)) - contents) - nil nil "OrgInlineTaskFrame" " style:rel-width=\"100%\""))))) + (let* ((todo (and (plist-get info :with-todo-keywords) + (let ((todo (org-element-property :todo-keyword inlinetask))) + (and todo (org-export-data todo info))))) + (todo-type (and todo (org-element-property :todo-type inlinetask))) + (priority (and (plist-get info :with-priority) + (org-element-property :priority inlinetask))) + (name (org-export-data (org-element-property :title inlinetask) info)) + (tags (and (plist-get info :with-tags) + (org-export-get-tags inlinetask info)))) + (funcall (plist-get info :odt-format-inlinetask-function) + todo todo-type priority name tags contents))) + +(defun org-odt-format-inlinetask-default-function + (todo todo-type priority name tags contents) + "Transcode an INLINETASK element from Org to ODT. +CONTENTS holds the contents of the block. INFO is a plist +holding contextual information." + (format "\n%s" + "Text_20_body" + (org-odt--textbox + (concat + (format "\n%s" + "OrgInlineTaskHeading" + (org-odt-format-headline-default-function + todo todo-type priority name tags)) + contents) + nil nil "OrgInlineTaskFrame" " style:rel-width=\"100%\""))) ;;;; Italic -- 2.11.4.GIT