From mboxrd@z Thu Jan 1 00:00:00 1970 From: Georg Lehner Subject: Re: Open Document Exporter Date: Thu, 27 Jun 2013 02:19:16 +0200 Message-ID: <51CB8504.9030401@magma.com.ni> References: <51C8BA2B.8010509@magma.com.ni> <20130625013526.GA9892@panahar> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:41766) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Urzxl-0001dX-9G for emacs-orgmode@gnu.org; Wed, 26 Jun 2013 20:21:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Urzxh-0006Rq-RP for emacs-orgmode@gnu.org; Wed, 26 Jun 2013 20:21:25 -0400 Received: from home.umim.anteris.net ([88.198.75.67]:53314) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Urzxh-0005KZ-1E for emacs-orgmode@gnu.org; Wed, 26 Jun 2013 20:21:21 -0400 Received: from cpe90-146-159-28.liwest.at (HELO [192.168.173.13]) (jorge@magma.com.ni@[90.146.159.28]) (envelope-sender ) by home.umim.anteris.net (qmail-ldap-1.03) with AES256-SHA encrypted SMTP for ; 27 Jun 2013 00:39:33 -0000 In-Reply-To: <20130625013526.GA9892@panahar> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org On 06/25/2013 03:35 AM, Vikas Rawal wrote: >> At the end of the export process I get the message: >> >> content.xml changed on disk; really edit the buffer? (y, n, r or C-h) >> Please type y, n or r; or ? for help >> >> After typing 'y', I have to reconfirm with 'yes' and then with 'y' again to >> get a valid export. >> >> Any tips how to fix or avoid this? > You perhaps have content.xml open as a buffer in emacs. Close that > buffer, and you should be fine. > > Vikas The content.xml buffer gets created and modified by the exporter. I have found at least one (and the more annoying) place in ox-odt.el, where this happens. Using the 'write-file function Instead of (save-buffer 0) resolved the issue. In the patch below there are the following "fixes" for ox-odt.el: 1. content.xml changed on disk message avoided ============================= see: @@ -4092,7 +4111,9 @@ 2. Internal cross references ================ By replacing 'OrgXref.' with '__RefHeading__' has prefix of internal link labels, the cross references show the target Heading Line when the mouse hovers over them. The patch is rather brute force, but e.g. table captions and references still show the "original" behavior: The reference shows "Table" and the caption shows the Table number when hovering over them. By replacing: text:reference-format=\"chapter\" with text:reference-format=\"number\" cross references show the real chapter number, not the internal numbering. This is e.g. different, when you decide to change the outline numbering properties "Before" and "After" from their defaults. While looking at that I found out that some 'bookmarks' get generated twice by the exporter: once as "OrgXref.sec-n-m" and once as "sec-n-m", with n and m beeing the chapter and section numbers. 3. Search path for contributed style files ======================= @@ -157,7 +157,7 @@ the search path for "git" based org-mode installations had one parent directory level too much (../). 4. LaTeX like definition lists ================ The rest of the patch deals with trying to make definition lists - term :: definition look as in LaTex and not as in HTML. Caution! the patch is very quirky, it does not work with nested lists at all. It works fine with simple, short definitions though. How to use it: - create a text style named 'OrgDefinitionTerm' in your template file. Bold text is sufficient. - create a paragraph style named 'OrgDefinitionItem' in your template file. I made mine having a hanging indent of 2cm and one (1) tab-stop at 2.1cm. What the patch does: - The 'org-odt--translate-description-lists' filter is removed from the filter stack, so descriptive lists remain just descriptive lists (and do not get split into descriptive-1 and descriptive-2 item pairs. - When transcoding 'descriptive' items to ODT, the term is retrived, typeset in bold, and inserted in front of the 'contents' of the iterm, separated by a tab. - in all "case" constructs where "descriptive-1" and "...-2" occurs, I added "descriptive" too. How *should* it work: I guess the better solution would be to modify the 'org-odt--translate-description-lists' filter in a way to produce the same effect on the parsed tree representation of the document. So nested definition lists would work. Of course a customizable variable, or some per file/per subtree #+ODT tag is needed to switch on demand between the two representations. Best Regards, Georg Lehner - - - diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el index a76f7dd..c8b704c 100644 --- a/lisp/ox-odt.el +++ b/lisp/ox-odt.el @@ -86,7 +86,7 @@ :export-block "ODT" :filters-alist '((:filter-parse-tree . (org-odt--translate-latex-fragments - org-odt--translate-description-lists + ;;org-odt--translate-description-lists org-odt--translate-list-tables))) :menu-entry '(?o "Export to ODT" @@ -157,7 +157,7 @@ and `org-odt-data-dir'.") (eval-when-compile (and (boundp 'org-odt-data-dir) org-odt-data-dir ; see make install (expand-file-name "./styles/" org-odt-data-dir))) - (expand-file-name "../../etc/styles/" org-odt-lib-dir) ; git + (expand-file-name "../etc/styles/" org-odt-lib-dir) ; git (expand-file-name "./etc/styles/" org-odt-lib-dir) ; elpa (expand-file-name "./org/" data-directory) ; system ) @@ -201,7 +201,7 @@ version of org in use and is initialized from from one of: org's own private git repository, GNU ELPA tar or standard Emacs.") -(defconst org-odt-bookmark-prefix "OrgXref.") +(defconst org-odt-bookmark-prefix "__RefHeading__") (defconst org-odt-manifest-file-entry-tag "\n") @@ -1064,9 +1064,9 @@ See `org-odt--build-date-styles' for implementation details." (defun org-odt--target (text id) (if (not id) text (concat - (format "\n" id) + (format "\n" id) (format "\n" id) text - (format "\n" id)))) + (format "\n" id)))) ;;;; Textbox @@ -1997,19 +1997,36 @@ contextual information." (concat (org-odt--checkbox item) (org-export-data tag info)))))) (case type - ((ordered unordered descriptive-1 descriptive-2) - (format "\n\n%s\n%s" - contents - (let* ((--element-has-a-table-p - (function - (lambda (element info) - (loop for el in (org-element-contents element) - thereis (eq (org-element-type el) 'table)))))) - (cond - ((funcall --element-has-a-table-p item info) - "") - (t ""))))) - (t (error "Unknown list type: %S" type))))) + ((ordered unordered descriptive-1 descriptive-2 descriptive) + (case type + ((ordered unordered descriptive-1 descriptive-2) + (format "\n\n%s\n%s" + contents + (let* ((--element-has-a-table-p + (function + (lambda (element info) + (loop for el in (org-element-contents element) + thereis (eq (org-element-type el) 'table)))))) + (cond + ((funcall --element-has-a-table-p item info) + "") + (t ""))))) + (descriptive + (format "\n\n%s\n%s" + (replace-regexp-in-string + "^" + (format "%s" tag) + contents) + (let* ((--element-has-a-table-p + (function + (lambda (element info) + (loop for el in (org-element-contents element) + thereis (eq (org-element-type el) 'table)))))) + (cond + ((funcall --element-has-a-table-p item info) + "") + (t ""))))) + (t (error "Unknown list type: %S" type))))))) ;;;; Keyword @@ -2723,7 +2740,7 @@ Return nil, otherwise." return el))) ;; We found one. (when headline - (format "%s" + (format "%s" (org-export-solidify-link-text label) (mapconcat 'number-to-string (org-export-get-headline-number headline info) ".")))) @@ -2735,7 +2752,7 @@ Return nil, otherwise." return el))) ;; We found one. (when headline - (format "%s" + (format "%s" (org-export-solidify-link-text label) (let ((title (org-element-property :title headline))) (org-export-data title info))))) @@ -2781,7 +2798,7 @@ INFO is a plist holding contextual information. See (let ((desc (org-export-data (org-element-contents destination) info)) (href (org-export-solidify-link-text path))) (format - "%s" + "%s" href desc))))) ;; Links pointing to a headline: Find destination and build ;; appropriate referencing command. @@ -2846,7 +2863,7 @@ INFO is a plist holding contextual information. See (format (org-export-get-coderef-format path desc) (format - "%s" + "%s" href line-no)))) ;; Link type is handled by a special function. ((functionp (setq protocol (nth 2 (assoc type org-link-protocols)))) @@ -2920,6 +2937,7 @@ contextual information." (case (org-element-property :type plain-list) (ordered "OrgNumberedList") (unordered "OrgBulletedList") + (descriptive "OrgDescriptionList") (descriptive-1 "OrgDescriptionList") (descriptive-2 "OrgDescriptionList")) ;; If top-level list, re-start numbering. Otherwise, @@ -3559,6 +3577,7 @@ pertaining to indentation here." (case (org-element-property :type el) (ordered "OrgNumberedList") (unordered "OrgBulletedList") + (descriptive "OrgDescriptionList") (descriptive-1 "OrgDescriptionList") (descriptive-2 "OrgDescriptionList")) "text:continue-numbering=\"true\""))) @@ -4092,7 +4111,9 @@ contextual information." ;; Prettify output if needed. (when org-odt-prettify-xml (indent-region (point-min) (point-max))) - (save-buffer 0))))) + ;;;(save-buffer 0) + (write-file (concat org-odt-zip-dir file)) + )))) org-odt-xml-files) ;; Run zip. (let* ((target --out-file)