emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Georg Lehner <jorge-org@magma.com.ni>
To: emacs-orgmode@gnu.org
Subject: Re: Open Document Exporter
Date: Thu, 27 Jun 2013 02:19:16 +0200	[thread overview]
Message-ID: <51CB8504.9030401@magma.com.ni> (raw)
In-Reply-To: <20130625013526.GA9892@panahar>

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<manifest:file-entry manifest:media-type=\"%s\" 
manifest:full-path=\"%s\"%s/>")
@@ -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<text:bookmark-start text:name=\"OrgXref.%s\"/>" id)
+     (format "\n<text:bookmark-start text:name=\"__RefHeading__%s\"/>" id)
       (format "\n<text:bookmark text:name=\"%s\"/>" id) text
-     (format "\n<text:bookmark-end text:name=\"OrgXref.%s\"/>" id))))
+     (format "\n<text:bookmark-end text:name=\"__RefHeading__%s\"/>" 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<text:list-item>\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)
-           "</text:list-header>")
-          (t "</text:list-item>")))))
-      (t (error "Unknown list type: %S" type)))))
+      ((ordered unordered descriptive-1 descriptive-2 descriptive)
+       (case type
+     ((ordered unordered descriptive-1 descriptive-2)
+      (format "\n<text:list-item>\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)
+              "</text:list-header>")
+             (t "</text:list-item>")))))
+     (descriptive
+      (format "\n<text:list-item>\n%s\n%s"
+          (replace-regexp-in-string
+           "^<text:p ?.*?>"
+           (format "<text:p 
text:style-name=\"OrgDefinitionItem\"><text:span 
text:style-name=\"OrgDefinitionTerm\">%s</text:span><text:tab/>" 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)
+              "</text:list-header>")
+             (t "</text:list-item>")))))
+     (t (error "Unknown list type: %S" type)))))))

  ;;;; Keyword

@@ -2723,7 +2740,7 @@ Return nil, otherwise."
                 return el)))
         ;; We found one.
         (when headline
-     (format "<text:bookmark-ref text:reference-format=\"chapter\" 
text:ref-name=\"OrgXref.%s\">%s</text:bookmark-ref>"
+     (format "<text:bookmark-ref text:reference-format=\"number\" 
text:ref-name=\"__RefHeading__%s\">%s</text:bookmark-ref>"
           (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 "<text:bookmark-ref text:reference-format=\"text\" 
text:ref-name=\"OrgXref.%s\">%s</text:bookmark-ref>"
+     (format "<text:bookmark-ref text:reference-format=\"text\" 
text:ref-name=\"__RefHeading__%s\">%s</text:bookmark-ref>"
           (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
-         "<text:bookmark-ref text:reference-format=\"text\" 
text:ref-name=\"OrgXref.%s\">%s</text:bookmark-ref>"
+         "<text:bookmark-ref text:reference-format=\"text\" 
text:ref-name=\"__RefHeading__%s\">%s</text:bookmark-ref>"
           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
-      "<text:bookmark-ref text:reference-format=\"number\" 
text:ref-name=\"OrgXref.%s\">%s</text:bookmark-ref>"
+      "<text:bookmark-ref text:reference-format=\"number\" 
text:ref-name=\"__RefHeading__%s\">%s</text:bookmark-ref>"
        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)

  reply	other threads:[~2013-06-27  0:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-24 21:29 Open Document Exporter Georg Lehner
2013-06-25  1:35 ` Vikas Rawal
2013-06-27  0:19   ` Georg Lehner [this message]
2013-06-27 13:58     ` Bastien
2013-06-29 12:43     ` Jambunathan K
2013-06-29 20:37       ` Georg Lehner
2013-06-26  9:42 ` Nicolas Goaziou
2013-06-28 21:20 ` Georg Lehner
2013-06-29 13:24 ` Jambunathan K
2013-06-29 13:26 ` Jambunathan K

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51CB8504.9030401@magma.com.ni \
    --to=jorge-org@magma.com.ni \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).