From: Viktor Rosenfeld <listuser36@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] Improve configurability of ox-koma-letter
Date: Sun, 21 Apr 2013 19:59:57 +0200 [thread overview]
Message-ID: <20130421175957.GA7821@cartman> (raw)
[-- Attachment #1: Type: text/plain, Size: 390 bytes --]
Hi,
I've hacked the ox-koma-letter exporter to make it more configurable.
See the Changelog of the attached patch, hopefully I've followed the
Changelog guidelines propertly.
Also, I could not find an ox-koma-letter tutorial on Worg. I would be
willing to create such a tutorial, maybe next weekend. Can anybody edit
the contents on Worg or do I need special priviledges?
Cheers, Viktor
[-- Attachment #2: ox-koma-letter.patch --]
[-- Type: text/x-diff, Size: 11197 bytes --]
KOMA scrlttr2 export: Improve export configuration options.
* ox-koma-letter.el (org-koma-letter-sender): New option for
the letter's author.
(org-koma-letter-from-address): Do not set default personal information.
(org-koma-letter-phone-number): Do not set default personal information.
(org-koma-letter-email): New option for the sender's email.
(org-koma-letter-place): Specify the letter's place.
(org-koma-letter-opening): Gendered opening.
(org-koma-letter-closing): More business-like closing
(org-koma-letter-use-subject): Configure the appearance of the
subject line.
(org-koma-letter-use-backaddress): Configure the presence of
the backaddress.
(org-koma-letter-use-foldmarks): Configure the presence of foldmarks.
(org-koma-letter-use-phone): Configure the presence of the
sender's phone number.
(org-koma-letter-use-email): Configure the presence of the
sender's email address.
(org-koma-letter-use-place): Configure the presence of the
letter's place.
(koma-letter): Add new options to koma-letter export backend
(org-koma-letter-template): Better KOMA configuration; support for
multiple LCO files.
This patch changes the KOMA-letter exporter in four ways:
* Same hotkeys as the LaTeX exporter
Use =L= (instead of =K=) to export to a buffer, =l= (instead of =k=)
to export to a file, and =O= (instead of =o=) to open the PDF file.
This was already suggested by Rasmus
(http://thread.gmane.org/gmane.emacs.orgmode/67026).
* Setting of KOMA variables
LCO files are loaded first and KOMA variables are only set in the
LaTeX output if their value is not nil. This way most configuration
options can be set once in an LCO file and overwritten if needed.
Consider for example an LCO file =DefaultAddress.lco= in
=~/texmf/tex/latex=.
#+BEGIN_SRC latex
\ProvidesFile{DefaultAddress.lco}
\setkomavar{fromname}{Max Mustermann}
\setkomavar{fromaddress}{Musterstraße 1\\12345 Musterstadt}
#+END_SRC
The default address can then be overwritten in the actual letter. Note
the additional country in the address below.
#+LCO: DefaultAddress
#+FROM_ADDRESS: Musterstraße 1\\12345 Musterstadt\\Germany
* Setting of KOMA options
The presence of the sender's phone and email, the letter's place and
subject, as well as foldmarks and the backaddress are
configurable. Consider:
#+OPTIONS: subject:titled place:nil phone:t email:t foldmarks:nil backaddress:nil
Note, that except for =subject=, all options are boolean, e.g., they
accept the values =t= and =nil=. Subject can also be nil to surpress
printing, or otherwise any possible value for the KOMA option subject,
i.e., afteropening, beforeopening, centered, left, right, titled,
underlined, or untitled.
* Multiple LCO files
Multiple LCO files, separated by spaces, can be specified. This way
one can add optional behavior to the letter export. Consider, e.g., an
LCO file with a default address and a simple textual signature:
#+BEGIN_SRC latex
\ProvidesFile{Default.lco}
% default address
\setkomavar{fromname}{Max Mustermann}
\setkomavar{fromaddress}{Musterstraße 1\\12345 Musterstadt}
% default signature
\renewcommand*{\raggedsignature}{\raggedright}
\setkomavar{signature}{\usekomavar{fromname}}
#+END_SRC
And a second LCO file defining a signature graphic:
#+BEGIN_SRC latex
\ProvidesFile{Signed.lco}
% use signature graphic
\usepackage{graphicx}
\setkomavar{signature}{\\[-2.5\baselineskip]\includegraphics{/home/he-sk/org/data/12/441E34-D2DE-4207-9B4A-23A4DA7AF870/Unterschrift.png}\\[-0.9\baselineskip]\usekomavar{fromname}}
#+END_SRC
Then, a signed letter can be created as follows:
#+LCO: Default Signed
diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el
index 1ffb455..31ccd89 100644
--- a/contrib/lisp/ox-koma-letter.el
+++ b/contrib/lisp/ox-koma-letter.el
@@ -80,23 +80,38 @@
:group 'org-export-koma-letter
:type 'string)
-(defcustom org-koma-letter-closing "See you soon,"
- "Koma-Letter's closing, as a string."
+(defcustom org-koma-letter-sender nil
+ "Sender's name, 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-phone-number nil
+ "Sender's phone number, 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)
+
+(defcustom org-koma-letter-place nil
+ "Place from which the letter is sent."
+ :group 'org-export-koma-letter
+ :type 'string)
+
+(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"
- "Sender's phone number, as a string."
+(defcustom org-koma-letter-closing "Sincerely yours,"
+ "Koma-Letter's closing, as a string."
:group 'org-export-koma-letter
:type 'string)
@@ -105,28 +120,68 @@
:group 'org-export-koma-letter
:type 'string)
+(defcustom org-koma-letter-use-subject "untitled"
+ "Use the title as the letter's subject."
+ :group 'org-export-koma-letter
+ :type 'string)
+
+(defcustom org-koma-letter-use-backaddress t
+ "Print return address in small line above to address."
+ :group 'org-export-koma-letter
+ :type 'boolean)
+
+(defcustom org-koma-letter-use-foldmarks t
+ "Print foldmarks."
+ :group 'org-export-koma-letter
+ :type 'boolean)
+
+(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)
+
\f
;;; 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)
+ (:place "PLACE" nil org-koma-letter-place)
+ (:opening "OPENING" nil org-koma-letter-opening)
+ (:closing "CLOSING" nil org-koma-letter-closing)
+ (: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))
: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))
:menu-entry
'(?k "Export with KOMA Scrlttr2"
- ((?K "As LaTeX buffer" org-koma-letter-export-as-latex)
- (?k "As LaTeX file" org-koma-letter-export-to-latex)
+ ((?L "As LaTeX buffer" org-koma-letter-export-as-latex)
+ (?l "As LaTeX file" org-koma-letter-export-to-latex)
(?p "As PDF file" org-koma-letter-export-to-pdf)
- (?O "As PDF file and open"
+ (?o "As PDF file and open"
(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))))))))
@@ -197,22 +252,53 @@ 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
+ (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))
+ ;; 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.
+ ;; 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"))
+ (format "\\KOMAoption{foldmarks}{%s}\n" (if with-foldmarks "true" "false"))
+ (format "\\KOMAoption{fromphone}{%s}\n" (if with-phone "true" "false"))
+ (format "\\KOMAoption{fromemail}{%s}\n" (if with-email "true" "false"))))
+ ;; Document start
"\\begin{document}\n\n"
- (format "\\setkomavar{subject}{%s}\n\n"
- (org-export-data (plist-get info :title) info))
+ ;; 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
(format "\\begin{letter}{%%\n%s}\n\n"
(or (plist-get info :to-address) "no address given"))
;; Opening.
next reply other threads:[~2013-04-21 18:00 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-21 17:59 Viktor Rosenfeld [this message]
2013-04-22 8:24 ` [PATCH] Improve configurability of ox-koma-letter Alan Schmitt
2013-04-22 8:47 ` Nicolas Goaziou
2013-04-22 9:31 ` Alan Schmitt
2013-04-22 10:57 ` Viktor Rosenfeld
2013-04-22 12:06 ` Alan Schmitt
2013-04-22 19:14 ` Viktor Rosenfeld
2013-04-23 6:40 ` Alan Schmitt
2013-04-23 9:50 ` Viktor Rosenfeld
2013-04-23 9:54 ` Alan Schmitt
2013-05-05 13:25 ` Viktor Rosenfeld
2013-05-05 16:24 ` Alan Schmitt
2013-04-23 7:28 ` Alan Schmitt
2013-04-23 10:09 ` Viktor Rosenfeld
2013-04-23 11:11 ` Alan Schmitt
2013-04-22 10:49 ` Viktor Rosenfeld
2013-05-05 13:35 ` Viktor Rosenfeld
2013-05-05 17:07 ` Alan Schmitt
2013-05-14 16:09 ` Viktor Rosenfeld
2013-05-14 21:20 ` Rasmus
2013-05-16 18:35 ` Viktor Rosenfeld
2013-05-14 23:56 ` Thomas S. Dye
2013-05-16 18:35 ` Viktor Rosenfeld
2013-05-15 6:38 ` Alan Schmitt
2013-05-14 22:29 ` Suvayu Ali
2013-05-16 18:35 ` Viktor Rosenfeld
2013-04-22 9:57 ` Rasmus
2013-04-22 11:27 ` Viktor Rosenfeld
2013-04-22 12:09 ` Rasmus
2013-04-22 19:22 ` Viktor Rosenfeld
2013-04-23 23:46 ` Rasmus
2013-05-05 13:27 ` Viktor Rosenfeld
2013-05-05 16:33 ` Alan Schmitt
2013-05-05 16:44 ` Viktor Rosenfeld
2013-05-05 17:06 ` Alan Schmitt
2013-04-24 0:05 ` Rasmus
2013-05-05 13:30 ` Viktor Rosenfeld
2013-04-22 17:13 ` Bastien
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130421175957.GA7821@cartman \
--to=listuser36@gmail.com \
--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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.