2013-01-27 17:11:34 -05:00
|
|
|
|
;;; ox-koma-letter.el --- KOMA Scrlttr2 Back-End for Org Export Engine
|
2012-11-26 02:55:27 -05:00
|
|
|
|
|
|
|
|
|
;; Copyright (C) 2007-2012 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
|
|
;; Author: Nicolas Goaziou <n.goaziou AT gmail DOT com>
|
|
|
|
|
;; Alan Schmitt <alan.schmitt AT polytechnique DOT org>
|
|
|
|
|
;; Keywords: org, wp, tex
|
|
|
|
|
|
2013-03-10 12:57:47 -04:00
|
|
|
|
;; This program is free software: you can redistribute it and/or modify
|
2012-11-26 02:55:27 -05:00
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
2013-03-10 12:57:47 -04:00
|
|
|
|
;; This program is distributed in the hope that it will be useful,
|
2012-11-26 02:55:27 -05:00
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
|
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
;;
|
|
|
|
|
;; This library implements a KOMA Scrlttr2 back-end, derived from the
|
|
|
|
|
;; LaTeX one.
|
|
|
|
|
;;
|
|
|
|
|
;; Depending on the desired output format, three commands are provided
|
|
|
|
|
;; for export: `org-koma-letter-export-as-latex' (temporary buffer),
|
|
|
|
|
;; `org-koma-letter-export-to-latex' ("tex" file) and
|
|
|
|
|
;; `org-koma-letter-export-to-pdf' ("pdf" file).
|
|
|
|
|
;;
|
2013-01-27 17:11:34 -05:00
|
|
|
|
;; On top of buffer keywords supported by `latex' back-end (see
|
2013-02-08 16:59:47 -05:00
|
|
|
|
;; `org-latex-options-alist'), this back-end introduces the following
|
|
|
|
|
;; keywords: "CLOSING" (see `org-koma-letter-closing'), "FROM_ADDRESS"
|
|
|
|
|
;; (see `org-koma-letter-from-address'), "LCO" (see
|
2012-11-26 02:55:27 -05:00
|
|
|
|
;; `org-koma-letter-class-option-file'), "OPENING" (see
|
|
|
|
|
;; `org-koma-letter-opening'), "PHONE_NUMBER" (see
|
|
|
|
|
;; `org-koma-letter-phone-number'), "SIGNATURE" (see
|
|
|
|
|
;; `org-koma-letter-signature') and "TO_ADDRESS".
|
|
|
|
|
;;
|
|
|
|
|
;; You will need to add an appropriate association in
|
2013-02-08 16:59:47 -05:00
|
|
|
|
;; `org-latex-classes' in order to use the KOMA Scrlttr2 class. For
|
2012-11-26 02:55:27 -05:00
|
|
|
|
;; example, you can use the following code:
|
|
|
|
|
;;
|
2013-01-27 17:11:34 -05:00
|
|
|
|
;; (add-to-list 'org-latex-classes
|
2012-11-26 02:55:27 -05:00
|
|
|
|
;; '("my-letter"
|
|
|
|
|
;; "\\documentclass\[%
|
|
|
|
|
;; DIV=14,
|
|
|
|
|
;; fontsize=12pt,
|
|
|
|
|
;; parskip=half,
|
|
|
|
|
;; subject=titled,
|
|
|
|
|
;; backaddress=false,
|
|
|
|
|
;; fromalign=left,
|
|
|
|
|
;; fromemail=true,
|
|
|
|
|
;; fromphone=true\]\{scrlttr2\}
|
|
|
|
|
;; \[DEFAULT-PACKAGES]
|
|
|
|
|
;; \[PACKAGES]
|
|
|
|
|
;; \[EXTRA]"))
|
|
|
|
|
;;
|
|
|
|
|
;; Then, in your Org document, be sure to require the proper class
|
|
|
|
|
;; with :
|
|
|
|
|
;;
|
|
|
|
|
;; #+LATEX_CLASS: my-letter
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
2013-01-27 17:11:34 -05:00
|
|
|
|
(require 'ox-latex)
|
2012-11-26 02:55:27 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; User-Configurable Variables
|
|
|
|
|
|
|
|
|
|
(defgroup org-export-koma-letter nil
|
|
|
|
|
"Options for exporting to KOMA scrlttr2 class in LaTeX export."
|
|
|
|
|
:tag "Org Koma-Letter"
|
2013-02-26 11:57:13 -05:00
|
|
|
|
:group 'org-export)
|
2012-11-26 02:55:27 -05:00
|
|
|
|
|
|
|
|
|
(defcustom org-koma-letter-class-option-file "NF"
|
|
|
|
|
"Letter Class Option File."
|
|
|
|
|
:group 'org-export-koma-letter
|
|
|
|
|
:type 'string)
|
|
|
|
|
|
|
|
|
|
|
2013-04-21 07:41:22 -04:00
|
|
|
|
(defcustom org-koma-letter-from-address nil
|
2012-11-26 02:55:27 -05:00
|
|
|
|
"Sender's address, as a string."
|
|
|
|
|
:group 'org-export-koma-letter
|
|
|
|
|
:type 'string)
|
|
|
|
|
|
ox-koma-letter: Export options to control letter
* ox-koma-letter.el ((org-koma-letter-use-subject):
Configure printing of subject line.
(org-koma-letter-use-backaddress): Configure presence of back
address.
(org-koma-letter-use-foldmarks): Configure presence of foldmarks.
(org-koma-letter-use-phone): Configure printing of phone number.
(org-koma-letter-use-email): Configure printing of email.
(org-koma-letter-use-place): Configure printing of place.
(koma-letter): Add export option to exporter backend.
(org-koma-letter-template): Evaluate export options in
exporter template.
Usage:
#+OPTIONS: backaddress:t foldmarks:t subject:titled phone:t email:t place:t
Except for `subject', all options are boolean, i.e., the accept the
values `nil' and `t'. `subject' accepts the values defined in
`scrlttr2`, i.e., `afteropening', `beforeopening', `centered', `left',
`right', `titled', `underlined', and `untitled'.
Signed-off-by: Alan Schmitt <alan.schmitt@polytechnique.org>
2013-04-21 10:34:35 -04:00
|
|
|
|
(defcustom org-koma-letter-phone-number nil
|
|
|
|
|
"Sender's phone number, as a string."
|
|
|
|
|
:group 'org-export-koma-letter
|
|
|
|
|
:type 'string)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defcustom org-koma-letter-place nil
|
|
|
|
|
"Place from which the letter is sent."
|
|
|
|
|
:group 'org-export-koma-letter
|
|
|
|
|
:type 'string)
|
|
|
|
|
|
2013-05-05 09:11:15 -04:00
|
|
|
|
(defcustom org-koma-letter-opening nil
|
2012-11-26 02:55:27 -05:00
|
|
|
|
"Letter's opening, as a string."
|
|
|
|
|
:group 'org-export-koma-letter
|
|
|
|
|
:type 'string)
|
|
|
|
|
|
2013-05-05 09:11:15 -04:00
|
|
|
|
(defcustom org-koma-letter-closing nil
|
ox-koma-letter: Export options to control letter
* ox-koma-letter.el ((org-koma-letter-use-subject):
Configure printing of subject line.
(org-koma-letter-use-backaddress): Configure presence of back
address.
(org-koma-letter-use-foldmarks): Configure presence of foldmarks.
(org-koma-letter-use-phone): Configure printing of phone number.
(org-koma-letter-use-email): Configure printing of email.
(org-koma-letter-use-place): Configure printing of place.
(koma-letter): Add export option to exporter backend.
(org-koma-letter-template): Evaluate export options in
exporter template.
Usage:
#+OPTIONS: backaddress:t foldmarks:t subject:titled phone:t email:t place:t
Except for `subject', all options are boolean, i.e., the accept the
values `nil' and `t'. `subject' accepts the values defined in
`scrlttr2`, i.e., `afteropening', `beforeopening', `centered', `left',
`right', `titled', `underlined', and `untitled'.
Signed-off-by: Alan Schmitt <alan.schmitt@polytechnique.org>
2013-04-21 10:34:35 -04:00
|
|
|
|
"Koma-Letter's closing, as a string."
|
2012-11-26 02:55:27 -05:00
|
|
|
|
:group 'org-export-koma-letter
|
|
|
|
|
:type 'string)
|
|
|
|
|
|
|
|
|
|
(defcustom org-koma-letter-signature "\\usekomavar{fromname}"
|
|
|
|
|
"String used as the signature."
|
|
|
|
|
:group 'org-export-koma-letter
|
|
|
|
|
:type 'string)
|
|
|
|
|
|
ox-koma-letter: Export options to control letter
* ox-koma-letter.el ((org-koma-letter-use-subject):
Configure printing of subject line.
(org-koma-letter-use-backaddress): Configure presence of back
address.
(org-koma-letter-use-foldmarks): Configure presence of foldmarks.
(org-koma-letter-use-phone): Configure printing of phone number.
(org-koma-letter-use-email): Configure printing of email.
(org-koma-letter-use-place): Configure printing of place.
(koma-letter): Add export option to exporter backend.
(org-koma-letter-template): Evaluate export options in
exporter template.
Usage:
#+OPTIONS: backaddress:t foldmarks:t subject:titled phone:t email:t place:t
Except for `subject', all options are boolean, i.e., the accept the
values `nil' and `t'. `subject' accepts the values defined in
`scrlttr2`, i.e., `afteropening', `beforeopening', `centered', `left',
`right', `titled', `underlined', and `untitled'.
Signed-off-by: Alan Schmitt <alan.schmitt@polytechnique.org>
2013-04-21 10:34:35 -04:00
|
|
|
|
(defcustom org-koma-letter-use-subject "untitled"
|
|
|
|
|
"Use the title as the letter's subject."
|
2013-04-21 07:41:22 -04:00
|
|
|
|
:group 'org-export-koma-letter
|
|
|
|
|
:type 'string)
|
|
|
|
|
|
ox-koma-letter: Export options to control letter
* ox-koma-letter.el ((org-koma-letter-use-subject):
Configure printing of subject line.
(org-koma-letter-use-backaddress): Configure presence of back
address.
(org-koma-letter-use-foldmarks): Configure presence of foldmarks.
(org-koma-letter-use-phone): Configure printing of phone number.
(org-koma-letter-use-email): Configure printing of email.
(org-koma-letter-use-place): Configure printing of place.
(koma-letter): Add export option to exporter backend.
(org-koma-letter-template): Evaluate export options in
exporter template.
Usage:
#+OPTIONS: backaddress:t foldmarks:t subject:titled phone:t email:t place:t
Except for `subject', all options are boolean, i.e., the accept the
values `nil' and `t'. `subject' accepts the values defined in
`scrlttr2`, i.e., `afteropening', `beforeopening', `centered', `left',
`right', `titled', `underlined', and `untitled'.
Signed-off-by: Alan Schmitt <alan.schmitt@polytechnique.org>
2013-04-21 10:34:35 -04:00
|
|
|
|
(defcustom org-koma-letter-use-backaddress t
|
|
|
|
|
"Print return address in small line above to address."
|
2013-04-21 07:41:22 -04:00
|
|
|
|
:group 'org-export-koma-letter
|
ox-koma-letter: Export options to control letter
* ox-koma-letter.el ((org-koma-letter-use-subject):
Configure printing of subject line.
(org-koma-letter-use-backaddress): Configure presence of back
address.
(org-koma-letter-use-foldmarks): Configure presence of foldmarks.
(org-koma-letter-use-phone): Configure printing of phone number.
(org-koma-letter-use-email): Configure printing of email.
(org-koma-letter-use-place): Configure printing of place.
(koma-letter): Add export option to exporter backend.
(org-koma-letter-template): Evaluate export options in
exporter template.
Usage:
#+OPTIONS: backaddress:t foldmarks:t subject:titled phone:t email:t place:t
Except for `subject', all options are boolean, i.e., the accept the
values `nil' and `t'. `subject' accepts the values defined in
`scrlttr2`, i.e., `afteropening', `beforeopening', `centered', `left',
`right', `titled', `underlined', and `untitled'.
Signed-off-by: Alan Schmitt <alan.schmitt@polytechnique.org>
2013-04-21 10:34:35 -04:00
|
|
|
|
:type 'boolean)
|
|
|
|
|
|
2013-05-05 09:22:51 -04:00
|
|
|
|
(defcustom org-koma-letter-use-foldmarks "true"
|
|
|
|
|
"Configure appearence of fold marks.
|
|
|
|
|
|
|
|
|
|
Accepts any valid value for the KOMA-Script `foldmarks' option.
|
|
|
|
|
|
|
|
|
|
Use `foldmarks:true' to activate default fold marks or
|
|
|
|
|
`foldmarks:nil' to deactivate fold marks."
|
ox-koma-letter: Export options to control letter
* ox-koma-letter.el ((org-koma-letter-use-subject):
Configure printing of subject line.
(org-koma-letter-use-backaddress): Configure presence of back
address.
(org-koma-letter-use-foldmarks): Configure presence of foldmarks.
(org-koma-letter-use-phone): Configure printing of phone number.
(org-koma-letter-use-email): Configure printing of email.
(org-koma-letter-use-place): Configure printing of place.
(koma-letter): Add export option to exporter backend.
(org-koma-letter-template): Evaluate export options in
exporter template.
Usage:
#+OPTIONS: backaddress:t foldmarks:t subject:titled phone:t email:t place:t
Except for `subject', all options are boolean, i.e., the accept the
values `nil' and `t'. `subject' accepts the values defined in
`scrlttr2`, i.e., `afteropening', `beforeopening', `centered', `left',
`right', `titled', `underlined', and `untitled'.
Signed-off-by: Alan Schmitt <alan.schmitt@polytechnique.org>
2013-04-21 10:34:35 -04:00
|
|
|
|
:group 'org-export-koma-letter
|
2013-05-05 09:22:51 -04:00
|
|
|
|
:type 'string)
|
ox-koma-letter: Export options to control letter
* ox-koma-letter.el ((org-koma-letter-use-subject):
Configure printing of subject line.
(org-koma-letter-use-backaddress): Configure presence of back
address.
(org-koma-letter-use-foldmarks): Configure presence of foldmarks.
(org-koma-letter-use-phone): Configure printing of phone number.
(org-koma-letter-use-email): Configure printing of email.
(org-koma-letter-use-place): Configure printing of place.
(koma-letter): Add export option to exporter backend.
(org-koma-letter-template): Evaluate export options in
exporter template.
Usage:
#+OPTIONS: backaddress:t foldmarks:t subject:titled phone:t email:t place:t
Except for `subject', all options are boolean, i.e., the accept the
values `nil' and `t'. `subject' accepts the values defined in
`scrlttr2`, i.e., `afteropening', `beforeopening', `centered', `left',
`right', `titled', `underlined', and `untitled'.
Signed-off-by: Alan Schmitt <alan.schmitt@polytechnique.org>
2013-04-21 10:34:35 -04:00
|
|
|
|
|
|
|
|
|
(defcustom org-koma-letter-use-phone t
|
|
|
|
|
"Print sender's phone number."
|
|
|
|
|
:group 'org-export-koma-letter
|
|
|
|
|
:type 'boolean)
|
|
|
|
|
|
|
|
|
|
(defcustom org-koma-letter-use-email t
|
|
|
|
|
"Print sender's email address."
|
|
|
|
|
:group 'org-export-koma-letter
|
|
|
|
|
:type 'boolean)
|
|
|
|
|
|
|
|
|
|
(defcustom org-koma-letter-use-place t
|
|
|
|
|
"Print the letter's place next to the date."
|
|
|
|
|
:group 'org-export-koma-letter
|
|
|
|
|
:type 'boolean)
|
2013-04-21 07:41:22 -04:00
|
|
|
|
|
2012-11-26 02:55:27 -05:00
|
|
|
|
|
|
|
|
|
;;; Define Back-End
|
|
|
|
|
|
2013-03-19 11:26:30 -04:00
|
|
|
|
(org-export-define-derived-backend 'koma-letter 'latex
|
2012-11-26 02:55:27 -05:00
|
|
|
|
:options-alist
|
2013-04-21 07:41:22 -04:00
|
|
|
|
'((:lco "LCO" nil org-koma-letter-class-option-file)
|
2013-05-19 16:14:54 -04:00
|
|
|
|
(:sender "AUTHOR" nil user-full-name t)
|
2013-03-19 11:26:30 -04:00
|
|
|
|
(:from-address "FROM_ADDRESS" nil org-koma-letter-from-address newline)
|
|
|
|
|
(:phone-number "PHONE_NUMBER" nil org-koma-letter-phone-number)
|
2013-05-19 16:14:54 -04:00
|
|
|
|
(:email "EMAIL" nil user-mail-address t)
|
2013-04-21 07:41:22 -04:00
|
|
|
|
(:to-address "TO_ADDRESS" nil nil newline)
|
ox-koma-letter: Export options to control letter
* ox-koma-letter.el ((org-koma-letter-use-subject):
Configure printing of subject line.
(org-koma-letter-use-backaddress): Configure presence of back
address.
(org-koma-letter-use-foldmarks): Configure presence of foldmarks.
(org-koma-letter-use-phone): Configure printing of phone number.
(org-koma-letter-use-email): Configure printing of email.
(org-koma-letter-use-place): Configure printing of place.
(koma-letter): Add export option to exporter backend.
(org-koma-letter-template): Evaluate export options in
exporter template.
Usage:
#+OPTIONS: backaddress:t foldmarks:t subject:titled phone:t email:t place:t
Except for `subject', all options are boolean, i.e., the accept the
values `nil' and `t'. `subject' accepts the values defined in
`scrlttr2`, i.e., `afteropening', `beforeopening', `centered', `left',
`right', `titled', `underlined', and `untitled'.
Signed-off-by: Alan Schmitt <alan.schmitt@polytechnique.org>
2013-04-21 10:34:35 -04:00
|
|
|
|
(:place "PLACE" nil org-koma-letter-place)
|
2013-04-21 07:41:22 -04:00
|
|
|
|
(:opening "OPENING" nil org-koma-letter-opening)
|
|
|
|
|
(:closing "CLOSING" nil org-koma-letter-closing)
|
ox-koma-letter: Export options to control letter
* ox-koma-letter.el ((org-koma-letter-use-subject):
Configure printing of subject line.
(org-koma-letter-use-backaddress): Configure presence of back
address.
(org-koma-letter-use-foldmarks): Configure presence of foldmarks.
(org-koma-letter-use-phone): Configure printing of phone number.
(org-koma-letter-use-email): Configure printing of email.
(org-koma-letter-use-place): Configure printing of place.
(koma-letter): Add export option to exporter backend.
(org-koma-letter-template): Evaluate export options in
exporter template.
Usage:
#+OPTIONS: backaddress:t foldmarks:t subject:titled phone:t email:t place:t
Except for `subject', all options are boolean, i.e., the accept the
values `nil' and `t'. `subject' accepts the values defined in
`scrlttr2`, i.e., `afteropening', `beforeopening', `centered', `left',
`right', `titled', `underlined', and `untitled'.
Signed-off-by: Alan Schmitt <alan.schmitt@polytechnique.org>
2013-04-21 10:34:35 -04:00
|
|
|
|
(:signature "SIGNATURE" nil org-koma-letter-signature newline)
|
|
|
|
|
|
|
|
|
|
(:with-backaddress nil "backaddress" org-koma-letter-use-backaddress)
|
|
|
|
|
(:with-foldmarks nil "foldmarks" org-koma-letter-use-foldmarks)
|
|
|
|
|
(:with-phone nil "phone" org-koma-letter-use-phone)
|
|
|
|
|
(:with-email nil "email" org-koma-letter-use-email)
|
|
|
|
|
(:with-place nil "place" org-koma-letter-use-place)
|
|
|
|
|
(:with-subject nil "subject" org-koma-letter-use-subject))
|
2013-03-19 11:26:30 -04:00
|
|
|
|
:translate-alist '((export-block . org-koma-letter-export-block)
|
|
|
|
|
(export-snippet . org-koma-letter-export-snippet)
|
|
|
|
|
(keyword . org-koma-letter-keyword)
|
|
|
|
|
(template . org-koma-letter-template))
|
2012-11-26 02:55:27 -05:00
|
|
|
|
:menu-entry
|
2013-03-19 11:26:30 -04:00
|
|
|
|
'(?k "Export with KOMA Scrlttr2"
|
2013-04-21 07:40:09 -04:00
|
|
|
|
((?L "As LaTeX buffer" org-koma-letter-export-as-latex)
|
|
|
|
|
(?l "As LaTeX file" org-koma-letter-export-to-latex)
|
2013-03-19 11:26:30 -04:00
|
|
|
|
(?p "As PDF file" org-koma-letter-export-to-pdf)
|
2013-04-21 07:40:09 -04:00
|
|
|
|
(?o "As PDF file and open"
|
2013-03-19 11:26:30 -04:00
|
|
|
|
(lambda (a s v b)
|
|
|
|
|
(if a (org-koma-letter-export-to-pdf t s v b)
|
|
|
|
|
(org-open-file (org-koma-letter-export-to-pdf nil s v b))))))))
|
2012-11-26 02:55:27 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Transcode Functions
|
|
|
|
|
|
|
|
|
|
;;;; Export Block
|
|
|
|
|
|
|
|
|
|
(defun org-koma-letter-export-block (export-block contents info)
|
|
|
|
|
"Transcode an EXPORT-BLOCK element into KOMA Scrlttr2 code.
|
|
|
|
|
CONTENTS is nil. INFO is a plist used as a communication
|
|
|
|
|
channel."
|
|
|
|
|
(when (member (org-element-property :type export-block) '("KOMA-LETTER" "LATEX"))
|
|
|
|
|
(org-remove-indentation (org-element-property :value export-block))))
|
|
|
|
|
|
|
|
|
|
;;;; Export Snippet
|
|
|
|
|
|
|
|
|
|
(defun org-koma-letter-export-snippet (export-snippet contents info)
|
|
|
|
|
"Transcode an EXPORT-SNIPPET object into KOMA Scrlttr2 code.
|
|
|
|
|
CONTENTS is nil. INFO is a plist used as a communication
|
|
|
|
|
channel."
|
2013-02-08 17:07:36 -05:00
|
|
|
|
(when (memq (org-export-snippet-backend export-snippet) '(latex koma-letter))
|
2012-11-26 02:55:27 -05:00
|
|
|
|
(org-element-property :value export-snippet)))
|
|
|
|
|
|
|
|
|
|
;;;; Keyword
|
|
|
|
|
|
|
|
|
|
(defun org-koma-letter-keyword (keyword contents info)
|
|
|
|
|
"Transcode a KEYWORD element into KOMA Scrlttr2 code.
|
|
|
|
|
CONTENTS is nil. INFO is a plist used as a communication
|
|
|
|
|
channel."
|
|
|
|
|
(let ((key (org-element-property :key keyword))
|
|
|
|
|
(value (org-element-property :value keyword)))
|
|
|
|
|
;; Handle specifically BEAMER and TOC (headlines only) keywords.
|
2013-02-08 17:07:36 -05:00
|
|
|
|
;; Otherwise, fallback to `latex' back-end.
|
2012-11-26 02:55:27 -05:00
|
|
|
|
(if (equal key "KOMA-LETTER") value
|
2013-01-27 17:11:34 -05:00
|
|
|
|
(org-export-with-backend 'latex keyword contents info))))
|
2012-11-26 02:55:27 -05:00
|
|
|
|
|
|
|
|
|
;;;; Template
|
|
|
|
|
|
|
|
|
|
(defun org-koma-letter-template (contents info)
|
|
|
|
|
"Return complete document string after KOMA Scrlttr2 conversion.
|
|
|
|
|
CONTENTS is the transcoded contents string. INFO is a plist
|
|
|
|
|
holding export options."
|
|
|
|
|
(concat
|
|
|
|
|
;; Time-stamp.
|
|
|
|
|
(and (plist-get info :time-stamp-file)
|
|
|
|
|
(format-time-string "%% Created %Y-%m-%d %a %H:%M\n"))
|
|
|
|
|
;; Document class and packages.
|
|
|
|
|
(let ((class (plist-get info :latex-class))
|
|
|
|
|
(class-options (plist-get info :latex-class-options)))
|
|
|
|
|
(org-element-normalize-string
|
2013-02-08 16:59:47 -05:00
|
|
|
|
(let* ((header (nth 1 (assoc class org-latex-classes)))
|
2012-11-26 02:55:27 -05:00
|
|
|
|
(document-class-string
|
|
|
|
|
(and (stringp header)
|
2013-02-20 14:26:08 -05:00
|
|
|
|
(if (not class-options) header
|
|
|
|
|
(replace-regexp-in-string
|
|
|
|
|
"^[ \t]*\\\\documentclass\\(\\(\\[[^]]*\\]\\)?\\)"
|
|
|
|
|
class-options header t nil 1)))))
|
2013-02-08 16:59:47 -05:00
|
|
|
|
(if (not document-class-string)
|
|
|
|
|
(user-error "Unknown LaTeX class `%s'")
|
|
|
|
|
(org-latex-guess-babel-language
|
|
|
|
|
(org-latex-guess-inputenc
|
2012-11-26 02:55:27 -05:00
|
|
|
|
(org-splice-latex-header
|
|
|
|
|
document-class-string
|
2013-02-08 11:09:45 -05:00
|
|
|
|
org-latex-default-packages-alist ; defined in org.el
|
2013-02-08 16:59:47 -05:00
|
|
|
|
org-latex-packages-alist nil ; defined in org.el
|
2013-03-07 02:59:23 -05:00
|
|
|
|
(concat (plist-get info :latex-header)
|
|
|
|
|
(plist-get info :latex-header-extra))))
|
2012-11-26 02:55:27 -05:00
|
|
|
|
info)))))
|
2013-04-21 07:41:22 -04:00
|
|
|
|
(let ((lco (plist-get info :lco))
|
|
|
|
|
(sender (plist-get info :sender))
|
|
|
|
|
(from-address (plist-get info :from-address))
|
|
|
|
|
(phone-number (plist-get info :phone-number))
|
|
|
|
|
(email (plist-get info :email))
|
|
|
|
|
(signature (plist-get info :signature)))
|
|
|
|
|
(concat
|
|
|
|
|
;; Letter Class Option File
|
2013-04-21 12:43:11 -04:00
|
|
|
|
(when lco
|
|
|
|
|
(let ((lco-files (split-string lco " "))
|
|
|
|
|
(lco-def ""))
|
|
|
|
|
(dolist (lco-file lco-files lco-def)
|
|
|
|
|
(setq lco-def (format "%s\\LoadLetterOption{%s}\n" lco-def lco-file)))
|
|
|
|
|
lco-def))
|
2013-04-21 07:41:22 -04:00
|
|
|
|
;; Define "From" data.
|
2013-05-19 16:14:54 -04:00
|
|
|
|
(when sender (format "\\setkomavar{fromname}{%s}\n"
|
|
|
|
|
(org-export-data sender info)))
|
2013-04-21 07:41:22 -04:00
|
|
|
|
(when from-address (format "\\setkomavar{fromaddress}{%s}\n" from-address))
|
|
|
|
|
(when phone-number (format "\\setkomavar{fromphone}{%s}\n" phone-number))
|
|
|
|
|
(when email (format "\\setkomavar{fromemail}{%s}\n" email))
|
|
|
|
|
(when signature (format "\\setkomavar{signature}{%s}\n" signature))))
|
2012-11-26 02:55:27 -05:00
|
|
|
|
;; Date.
|
2013-04-02 18:02:15 -04:00
|
|
|
|
(format "\\date{%s}\n" (org-export-data (org-export-get-date info) info))
|
ox-koma-letter: Export options to control letter
* ox-koma-letter.el ((org-koma-letter-use-subject):
Configure printing of subject line.
(org-koma-letter-use-backaddress): Configure presence of back
address.
(org-koma-letter-use-foldmarks): Configure presence of foldmarks.
(org-koma-letter-use-phone): Configure printing of phone number.
(org-koma-letter-use-email): Configure printing of email.
(org-koma-letter-use-place): Configure printing of place.
(koma-letter): Add export option to exporter backend.
(org-koma-letter-template): Evaluate export options in
exporter template.
Usage:
#+OPTIONS: backaddress:t foldmarks:t subject:titled phone:t email:t place:t
Except for `subject', all options are boolean, i.e., the accept the
values `nil' and `t'. `subject' accepts the values defined in
`scrlttr2`, i.e., `afteropening', `beforeopening', `centered', `left',
`right', `titled', `underlined', and `untitled'.
Signed-off-by: Alan Schmitt <alan.schmitt@polytechnique.org>
2013-04-21 10:34:35 -04:00
|
|
|
|
;; Place
|
|
|
|
|
(let ((with-place (plist-get info :with-place))
|
|
|
|
|
(place (plist-get info :place)))
|
|
|
|
|
(when (or place (not with-place))
|
|
|
|
|
(format "\\setkomavar{place}{%s}\n" (if with-place place ""))))
|
|
|
|
|
;; KOMA options
|
|
|
|
|
(let ((with-backaddress (plist-get info :with-backaddress))
|
|
|
|
|
(with-foldmarks (plist-get info :with-foldmarks))
|
|
|
|
|
(with-phone (plist-get info :with-phone))
|
|
|
|
|
(with-email (plist-get info :with-email)))
|
|
|
|
|
(concat
|
|
|
|
|
(format "\\KOMAoption{backaddress}{%s}\n" (if with-backaddress "true" "false"))
|
2013-05-05 09:22:51 -04:00
|
|
|
|
(format "\\KOMAoption{foldmarks}{%s}\n" (if with-foldmarks with-foldmarks "false"))
|
ox-koma-letter: Export options to control letter
* ox-koma-letter.el ((org-koma-letter-use-subject):
Configure printing of subject line.
(org-koma-letter-use-backaddress): Configure presence of back
address.
(org-koma-letter-use-foldmarks): Configure presence of foldmarks.
(org-koma-letter-use-phone): Configure printing of phone number.
(org-koma-letter-use-email): Configure printing of email.
(org-koma-letter-use-place): Configure printing of place.
(koma-letter): Add export option to exporter backend.
(org-koma-letter-template): Evaluate export options in
exporter template.
Usage:
#+OPTIONS: backaddress:t foldmarks:t subject:titled phone:t email:t place:t
Except for `subject', all options are boolean, i.e., the accept the
values `nil' and `t'. `subject' accepts the values defined in
`scrlttr2`, i.e., `afteropening', `beforeopening', `centered', `left',
`right', `titled', `underlined', and `untitled'.
Signed-off-by: Alan Schmitt <alan.schmitt@polytechnique.org>
2013-04-21 10:34:35 -04:00
|
|
|
|
(format "\\KOMAoption{fromphone}{%s}\n" (if with-phone "true" "false"))
|
|
|
|
|
(format "\\KOMAoption{fromemail}{%s}\n" (if with-email "true" "false"))))
|
|
|
|
|
;; Document start
|
2012-11-26 02:55:27 -05:00
|
|
|
|
"\\begin{document}\n\n"
|
ox-koma-letter: Export options to control letter
* ox-koma-letter.el ((org-koma-letter-use-subject):
Configure printing of subject line.
(org-koma-letter-use-backaddress): Configure presence of back
address.
(org-koma-letter-use-foldmarks): Configure presence of foldmarks.
(org-koma-letter-use-phone): Configure printing of phone number.
(org-koma-letter-use-email): Configure printing of email.
(org-koma-letter-use-place): Configure printing of place.
(koma-letter): Add export option to exporter backend.
(org-koma-letter-template): Evaluate export options in
exporter template.
Usage:
#+OPTIONS: backaddress:t foldmarks:t subject:titled phone:t email:t place:t
Except for `subject', all options are boolean, i.e., the accept the
values `nil' and `t'. `subject' accepts the values defined in
`scrlttr2`, i.e., `afteropening', `beforeopening', `centered', `left',
`right', `titled', `underlined', and `untitled'.
Signed-off-by: Alan Schmitt <alan.schmitt@polytechnique.org>
2013-04-21 10:34:35 -04:00
|
|
|
|
;; Subject
|
|
|
|
|
(let ((with-subject (plist-get info :with-subject)))
|
|
|
|
|
(when with-subject
|
|
|
|
|
(concat
|
|
|
|
|
(format "\\KOMAoption{subject}{%s}\n" with-subject)
|
|
|
|
|
(format "\\setkomavar{subject}{%s}\n\n"
|
|
|
|
|
(org-export-data (plist-get info :title) info)))))
|
|
|
|
|
;; Letter start
|
2013-01-27 17:11:34 -05:00
|
|
|
|
(format "\\begin{letter}{%%\n%s}\n\n"
|
|
|
|
|
(or (plist-get info :to-address) "no address given"))
|
2012-11-26 02:55:27 -05:00
|
|
|
|
;; Opening.
|
|
|
|
|
(format "\\opening{%s}\n\n" (plist-get info :opening))
|
|
|
|
|
;; Letter body.
|
|
|
|
|
contents
|
|
|
|
|
;; Closing.
|
|
|
|
|
(format "\n\\closing{%s}\n\n" (plist-get info :closing))
|
|
|
|
|
;; Letter end.
|
|
|
|
|
"\\end{letter}\n\\end{document}"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Commands
|
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun org-koma-letter-export-as-latex
|
2012-12-14 10:55:17 -05:00
|
|
|
|
(&optional async subtreep visible-only body-only ext-plist)
|
2012-11-26 02:55:27 -05:00
|
|
|
|
"Export current buffer as a KOMA Scrlttr2 letter.
|
|
|
|
|
|
|
|
|
|
If narrowing is active in the current buffer, only export its
|
|
|
|
|
narrowed part.
|
|
|
|
|
|
|
|
|
|
If a region is active, export that region.
|
|
|
|
|
|
2012-12-14 10:55:17 -05:00
|
|
|
|
A non-nil optional argument ASYNC means the process should happen
|
|
|
|
|
asynchronously. The resulting buffer should be accessible
|
|
|
|
|
through the `org-export-stack' interface.
|
|
|
|
|
|
2012-11-26 02:55:27 -05:00
|
|
|
|
When optional argument SUBTREEP is non-nil, export the sub-tree
|
|
|
|
|
at point, extracting information from the headline properties
|
|
|
|
|
first.
|
|
|
|
|
|
|
|
|
|
When optional argument VISIBLE-ONLY is non-nil, don't export
|
|
|
|
|
contents of hidden elements.
|
|
|
|
|
|
|
|
|
|
When optional argument BODY-ONLY is non-nil, only write code
|
|
|
|
|
between \"\\begin{letter}\" and \"\\end{letter}\".
|
|
|
|
|
|
|
|
|
|
EXT-PLIST, when provided, is a property list with external
|
|
|
|
|
parameters overriding Org default settings, but still inferior to
|
|
|
|
|
file-local settings.
|
|
|
|
|
|
|
|
|
|
Export is done in a buffer named \"*Org KOMA-LETTER Export*\". It
|
|
|
|
|
will be displayed if `org-export-show-temporary-export-buffer' is
|
|
|
|
|
non-nil."
|
|
|
|
|
(interactive)
|
2012-12-14 10:55:17 -05:00
|
|
|
|
(if async
|
|
|
|
|
(org-export-async-start
|
|
|
|
|
(lambda (output)
|
|
|
|
|
(with-current-buffer (get-buffer-create "*Org KOMA-LETTER Export*")
|
|
|
|
|
(erase-buffer)
|
|
|
|
|
(insert output)
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(LaTeX-mode)
|
|
|
|
|
(org-export-add-to-stack (current-buffer) 'koma-letter)))
|
|
|
|
|
`(org-export-as 'koma-letter ,subtreep ,visible-only ,body-only
|
|
|
|
|
',ext-plist))
|
|
|
|
|
(let ((outbuf (org-export-to-buffer
|
|
|
|
|
'koma-letter "*Org KOMA-LETTER Export*"
|
|
|
|
|
subtreep visible-only body-only ext-plist)))
|
|
|
|
|
(with-current-buffer outbuf (LaTeX-mode))
|
|
|
|
|
(when org-export-show-temporary-export-buffer
|
|
|
|
|
(switch-to-buffer-other-window outbuf)))))
|
2012-11-26 02:55:27 -05:00
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun org-koma-letter-export-to-latex
|
2012-12-14 10:55:17 -05:00
|
|
|
|
(&optional async subtreep visible-only body-only ext-plist)
|
2012-11-26 02:55:27 -05:00
|
|
|
|
"Export current buffer as a KOMA Scrlttr2 letter (tex).
|
|
|
|
|
|
|
|
|
|
If narrowing is active in the current buffer, only export its
|
|
|
|
|
narrowed part.
|
|
|
|
|
|
|
|
|
|
If a region is active, export that region.
|
|
|
|
|
|
2012-12-14 10:55:17 -05:00
|
|
|
|
A non-nil optional argument ASYNC means the process should happen
|
|
|
|
|
asynchronously. The resulting file should be accessible through
|
|
|
|
|
the `org-export-stack' interface.
|
|
|
|
|
|
2012-11-26 02:55:27 -05:00
|
|
|
|
When optional argument SUBTREEP is non-nil, export the sub-tree
|
|
|
|
|
at point, extracting information from the headline properties
|
|
|
|
|
first.
|
|
|
|
|
|
|
|
|
|
When optional argument VISIBLE-ONLY is non-nil, don't export
|
|
|
|
|
contents of hidden elements.
|
|
|
|
|
|
|
|
|
|
When optional argument BODY-ONLY is non-nil, only write code
|
|
|
|
|
between \"\\begin{letter}\" and \"\\end{letter}\".
|
|
|
|
|
|
|
|
|
|
EXT-PLIST, when provided, is a property list with external
|
|
|
|
|
parameters overriding Org default settings, but still inferior to
|
|
|
|
|
file-local settings.
|
|
|
|
|
|
|
|
|
|
When optional argument PUB-DIR is set, use it as the publishing
|
|
|
|
|
directory.
|
|
|
|
|
|
|
|
|
|
Return output file's name."
|
|
|
|
|
(interactive)
|
2012-11-29 15:52:43 -05:00
|
|
|
|
(let ((outfile (org-export-output-file-name ".tex" subtreep)))
|
2012-12-14 10:55:17 -05:00
|
|
|
|
(if async
|
|
|
|
|
(org-export-async-start
|
|
|
|
|
(lambda (f) (org-export-add-to-stack f 'koma-letter))
|
|
|
|
|
`(expand-file-name
|
|
|
|
|
(org-export-to-file
|
|
|
|
|
'koma-letter ,outfile ,subtreep ,visible-only ,body-only
|
|
|
|
|
',ext-plist)))
|
|
|
|
|
(org-export-to-file
|
|
|
|
|
'koma-letter outfile subtreep visible-only body-only ext-plist))))
|
2012-11-26 02:55:27 -05:00
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun org-koma-letter-export-to-pdf
|
2012-12-14 10:55:17 -05:00
|
|
|
|
(&optional async subtreep visible-only body-only ext-plist)
|
2012-11-26 02:55:27 -05:00
|
|
|
|
"Export current buffer as a KOMA Scrlttr2 letter (pdf).
|
|
|
|
|
|
|
|
|
|
If narrowing is active in the current buffer, only export its
|
|
|
|
|
narrowed part.
|
|
|
|
|
|
|
|
|
|
If a region is active, export that region.
|
|
|
|
|
|
2012-12-14 10:55:17 -05:00
|
|
|
|
A non-nil optional argument ASYNC means the process should happen
|
|
|
|
|
asynchronously. The resulting file should be accessible through
|
|
|
|
|
the `org-export-stack' interface.
|
|
|
|
|
|
2012-11-26 02:55:27 -05:00
|
|
|
|
When optional argument SUBTREEP is non-nil, export the sub-tree
|
|
|
|
|
at point, extracting information from the headline properties
|
|
|
|
|
first.
|
|
|
|
|
|
|
|
|
|
When optional argument VISIBLE-ONLY is non-nil, don't export
|
|
|
|
|
contents of hidden elements.
|
|
|
|
|
|
|
|
|
|
When optional argument BODY-ONLY is non-nil, only write code
|
|
|
|
|
between \"\\begin{letter}\" and \"\\end{letter}\".
|
|
|
|
|
|
|
|
|
|
EXT-PLIST, when provided, is a property list with external
|
|
|
|
|
parameters overriding Org default settings, but still inferior to
|
|
|
|
|
file-local settings.
|
|
|
|
|
|
|
|
|
|
Return PDF file's name."
|
|
|
|
|
(interactive)
|
2012-12-14 10:55:17 -05:00
|
|
|
|
(if async
|
|
|
|
|
(let ((outfile (org-export-output-file-name ".tex" subtreep)))
|
|
|
|
|
(org-export-async-start
|
|
|
|
|
(lambda (f) (org-export-add-to-stack f 'koma-letter))
|
|
|
|
|
`(expand-file-name
|
2013-02-08 16:59:47 -05:00
|
|
|
|
(org-latex-compile
|
2012-12-14 10:55:17 -05:00
|
|
|
|
(org-export-to-file
|
|
|
|
|
'koma-letter ,outfile ,subtreep ,visible-only ,body-only
|
|
|
|
|
',ext-plist)))))
|
2013-02-08 16:59:47 -05:00
|
|
|
|
(org-latex-compile
|
2012-12-14 10:55:17 -05:00
|
|
|
|
(org-koma-letter-export-to-latex
|
|
|
|
|
nil subtreep visible-only body-only ext-plist))))
|
|
|
|
|
|
2012-11-26 02:55:27 -05:00
|
|
|
|
|
2013-01-27 17:11:34 -05:00
|
|
|
|
(provide 'ox-koma-letter)
|
|
|
|
|
;;; ox-koma-letter.el ends here
|