emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] [patch] ox-koma-letter


From: Nicolas Goaziou
Subject: Re: [O] [patch] ox-koma-letter
Date: Tue, 05 Mar 2013 10:52:12 +0100

Hello,

Alan Schmitt <address@hidden> writes:

> Nicolas Goaziou writes:
>
>> Headlines are also possible, with a :location: property, which could be
>> set to, e.g. "closing". See also:
>>
>>   http://orgmode.org/worg/org-tutorials/org-e-groff-documentation.html
>>
>> for a syntax based on headlines.
>>
>> Another possibility is to use a special block. E.g.:
>>
>>   #+begin_closing
>>   ...
>>   #+end_closing
>>
>> The advantage of previous solutions is that it allows contents to be in
>> Org syntax whereas "AFTER_CLOSING" keywords require it to be in LaTeX
>> syntax.
>
> These two approaches look great. Do you have a pointer to some could I
> should look at to try to integrate them in ox-koma?

The principle is the same in both cases. You explicitly ignore the
construct (i.e. return nil) in the transcoding function normally
handling the same type of element. E.g.:

#+begin_src emacs-lisp
(defun org-koma-letter-headline (headline contents info)
  (unless (equal (org-element-property :LOCATION headline) "closing")
    (org-export-with-backend 'latex headline contents info)))
#+end_src

Then, when at the appropriate environment (i.e. template), you
explicitly search for these constructs with `org-element-map' and insert
them here:

#+begin_src emacs-lisp
(defun org-koma-letter-template (contents info)
  (concat
   ...
   ;; Letter body.
   contents
   ;; Closing.
   (format "\n\\closing{%s}\n\n" (plist-get info :closing))
   ;; Add contents of all headlines with "closing" location.
   (mapconcat
    'identity
    (delq nil
          (org-element-map (plist-get info :parse-buffer) 'headline
            (lambda (hl)
              (and (equal (org-element-property :LOCATION hl) "closing")
                   ;; Ignore headline's title.  Focus on contents.
                   (org-export-data (org-element-contents hl) info)))
            info)) "\n")
   ;; Letter end.
   "\\end{letter}\n\\end{document}"))
#+end_src

This is untested, but should get you started.


Regards,

-- 
Nicolas Goaziou



reply via email to

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