emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Ox unindents lines but I can't see when


From: Léo Ackermann
Subject: Ox unindents lines but I can't see when
Date: Fri, 30 Sep 2022 12:40:16 +0200

Dear all,

I'm currently working on a tiny project org-inline-blocks that aims to provide a simple syntax for latex-blocks in org-mode based on indent. Namely, instead of #+begin_theorem ... #+end_theorem, it will be possible to write "Theorem." and the export will be based on indent to decide whether some text belongs to the block or not.
Unfortunately, ox modifies the indentation of the org-text before running the filter functions. Here is an illustration.

Consider the following file `hamlet.org`:

---
Prince Hamlet of Denmark is the son of the recently deceased King Hamlet, and nephew of King Claudius, his father’s brother and successor.
        Claudius hastily married King Hamlet’s widow, Gertrude, Hamlet’s mother, and took the throne for himself. Denmark has a long-standing feud with neighbouring Norway, in which King Hamlet slew King Fortinbras of Norway in a battle some years ago.
        Although Denmark defeated Norway and the Norwegian throne fell to King Fortinbras’s infirm brother, Denmark fears that an invasion led by the dead Norwegian king’s son, Prince Fortinbras, is imminent.


        On a cold night on the ramparts of Elsinore, the Danish royal castle, the sentries Bernardo and Marcellus discuss a ghost resembling the late King Hamlet which they have recently seen, and bring Prince Hamlet’s friend Horatio as a witness.
---

and this tiny `org-export-filter-body`'s function:

---
    (with-eval-after-load 'ox
      (defun org-strange-behavior (text backend info)
        "Print text, as read by the export-filter-body functions."
        (when (org-export-derived-backend-p backend 'latex)
          (message text)))

       (add-to-list 'org-export-filter-body-functions
                    'org-strange-behavior))
---

When exporting `hamlet.org` in whatever format, the Message buffer shows this:

---
Prince Hamlet of Denmark is the son of the recently deceased King Hamlet, and nephew of King Claudius, his father’s brother and successor.
        Claudius hastily married King Hamlet’s widow, Gertrude, Hamlet’s mother, and took the throne for himself. Denmark has a long-standing feud with neighbouring Norway, in which King Hamlet slew King Fortinbras of Norway in a battle some years ago.
        Although Denmark defeated Norway and the Norwegian throne fell to King Fortinbras’s infirm brother, Denmark fears that an invasion led by the dead Norwegian king’s son, Prince Fortinbras, is imminent.

On a cold night on the ramparts of Elsinore, the Danish royal castle, the sentries Bernardo and Marcellus discuss a ghost resembling the late King Hamlet which they have recently seen, and bring Prince Hamlet’s friend Horatio as a witness.

---

My question is thus: how can I prevent ox from unindenting the last line ? 

I explored ox as much as I could, and did not find anything promising :/. 
I'm aware of an `org-export-preserve-breaks` variable but it preserves too much things (and causes export to be odd, in my opinion). 
If I run org-unindent-buffer in the buffer, the last line is unindented. But this function is not called in ox as far as I saw.
Moreover, given that I'm writing a package, using an org-verse environment all around is not suitable.

Best,
Leo

reply via email to

[Prev in Thread] Current Thread [Next in Thread]