1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-11-22 07:09:47 +00:00

ox-koma-letter.el: Set LCO option before other KOMA variables

* ox-koma-letter.el (org-koma-letter-closing): More
  business-like closing.
  (org-koma-letter-from-address): Do not set default personal
  information.
  (org-koma-letter-opening): Gendered opening.
  (org-koma-letter-phone-number): Do not set default personal
  information.
  (org-koma-letter-sender): Use `#+SENDER:' instead of
  `#+AUTHOR:' because the latter is always set by the LaTeX
  exporter.
  (org-koma-letter-email): Duplicte `#+EMAIL:' in this exporter
  because it is always set by the LaTeX exporter.
  (koma-letter): Add additional `#+SENDER:' and `#+EMAIL:' to
  exporter (see above).
  (org-koma-letter-template): Set LCO before evaluating other
  KOMA variables if they are set; add `#+SENDER:' and `#+EMAIL:'
  to template (see above).

The LCO file is set loaded first and KOMA variables are only set if
their value is not `nil'.

Example:

  #+LCO: Default
  #+SIGNATURE: A friend

will result in the following LaTeX code:

  #+BEGIN_SRC latex
  \LoadLetterOption{Default}        % LCO file, with default signature
  \setkomavar{signature}{A friend}  % Overwrite signature
  #+END_SRC

Other KOMA variables defined in the LCO file, e.g., `fromaddress', will
not be overwritten.

Signed-off-by: Alan Schmitt <alan.schmitt@polytechnique.org>
This commit is contained in:
Viktor Rosenfeld 2013-04-21 13:41:22 +02:00 committed by Alan Schmitt
parent 155deedb4d
commit cab6718d4b

View File

@ -80,22 +80,22 @@
:group 'org-export-koma-letter
:type 'string)
(defcustom org-koma-letter-closing "See you soon,"
(defcustom org-koma-letter-closing "Sincerely yours,"
"Koma-Letter's closing, as a string."
:group 'org-export-koma-letter
:type 'string)
(defcustom org-koma-letter-from-address "Somewhere \\ Over the rainbow."
(defcustom org-koma-letter-from-address nil
"Sender's address, as a string."
:group 'org-export-koma-letter
:type 'string)
(defcustom org-koma-letter-opening "Dear Sir,"
(defcustom org-koma-letter-opening "Dear Madam or Sir,"
"Letter's opening, as a string."
:group 'org-export-koma-letter
:type 'string)
(defcustom org-koma-letter-phone-number "00-00-00-00"
(defcustom org-koma-letter-phone-number nil
"Sender's phone number, as a string."
:group 'org-export-koma-letter
:type 'string)
@ -105,18 +105,30 @@
:group 'org-export-koma-letter
:type 'string)
(defcustom org-koma-letter-sender nil
"Sender's name, as a string."
:group 'org-export-koma-letter
:type 'string)
(defcustom org-koma-letter-email nil
"Sender's email, as a string."
:group 'org-export-koma-letter
:type 'string)
;;; Define Back-End
(org-export-define-derived-backend 'koma-letter 'latex
:options-alist
'((:closing "CLOSING" nil org-koma-letter-closing)
'((:lco "LCO" nil org-koma-letter-class-option-file)
(:sender "SENDER" nil org-koma-letter-sender newline)
(:from-address "FROM_ADDRESS" nil org-koma-letter-from-address newline)
(:lco "LCO" nil org-koma-letter-class-option-file)
(:opening "OPENING" nil org-koma-letter-opening)
(:phone-number "PHONE_NUMBER" nil org-koma-letter-phone-number)
(:signature "SIGNATURE" nil nil newline)
(:to-address "TO_ADDRESS" nil nil newline))
(:email "EMAIL" nil org-koma-letter-email)
(:to-address "TO_ADDRESS" nil nil newline)
(:opening "OPENING" nil org-koma-letter-opening)
(:closing "CLOSING" nil org-koma-letter-closing)
(:signature "SIGNATURE" nil org-koma-letter-signature newline))
:translate-alist '((export-block . org-koma-letter-export-block)
(export-snippet . org-koma-letter-export-snippet)
(keyword . org-koma-letter-keyword)
@ -197,18 +209,23 @@ holding export options."
(concat (plist-get info :latex-header)
(plist-get info :latex-header-extra))))
info)))))
;; Define "From" data.
(format "\\setkomavar{fromname}{%s}\n"
(org-export-data (plist-get info :author) info))
(format "\\setkomavar{fromaddress}{%s}\n" (plist-get info :from-address))
(format "\\setkomavar{signature}{%s}\n" (plist-get info :signature))
(format "\\setkomavar{fromemail}{%s}\n"
(org-export-data (plist-get info :email) info))
(format "\\setkomavar{fromphone}{%s}\n" (plist-get info :phone-number))
(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
(when lco (format "\\LoadLetterOption{%s}\n" lco))
;; Define "From" data.
(when sender (format "\\setkomavar{fromname}{%s}\n" sender))
(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))))
;; Date.
(format "\\date{%s}\n" (org-export-data (org-export-get-date info) info))
;; Letter Class Option File
(format "\\LoadLetterOption{%s}\n" (plist-get info :lco))
;; Letter start.
"\\begin{document}\n\n"
(format "\\setkomavar{subject}{%s}\n\n"