emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Jambunathan K <kjambunathan@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Composing letters using org-mode and scrlttr2
Date: Mon, 26 Jul 2010 02:47:44 +0530	[thread overview]
Message-ID: <4C4CA9F8.7010006@gmail.com> (raw)

#+TITLE: 
#+AUTHOR:
#+EMAIL:
#+LANGUAGE:
#+TEXT:
#+DATE:

#+LaTeX_CLASS_OPTIONS: [a4paper,parskip=full,backaddress=off,foldmarks=off,jambu]

#+OPTIONS: toc:nil 
#+LaTeX_CLASS: scrlttr2

* letter
  Org Mode User Group \\
  World Wide Web
  
* subject
  Composing letters using org-mode and scrlttr2
  
* opening
  Dear Org-Mode Users

* body
  Lately, I have been composing formal letters using KOMA script's
  scrlttr2. I find it convenient to have them composed auto-magically
  from within org-mode.
  
  I am enclosing the initial set of changes needed to compose some
  simple letters as this one.
  
  The only change that is too 'intrusive' seems to be an extra newline
  which gets added immediately after the emission of labels. These
  extra newlines trigger syntax errors in the closing{} and encl{}
  directives.
  
  I think rest of the changes could be squeeed in through existing
  hooks.

#+BEGIN_EXAMPLE
-	  (insert (mapconcat (lambda (l) (format "\\label{%s}" l))
-			     label-list "\n") "\n"))
+	    (insert (mapconcat (lambda (l) (format "\\label{%s}" l))
+			       label-list "\n")))
#+END_EXAMPLE 
  
  If there is some general interest, I could work on making a formal
  patch available.

* closing
  Yours Truly

* encl
  Patch from my work-area.

Jambunathan K.
  
diff --git a/lisp/org-latex.el b/lisp/org-latex.el
old mode 100644
new mode 100755
index f3a55ee..6a86c35
--- a/lisp/org-latex.el
+++ b/lisp/org-latex.el
@@ -113,8 +113,10 @@
      ("\\subsubsection{%s}" . "\\subsubsection*{%s}"))
     ("beamer"
      "\\documentclass{beamer}"
-     org-beamer-sectioning
-     ))
+     org-beamer-sectioning)
+    ("scrlttr2"
+     "\\documentclass{scrlttr2}"
+     org-scrlttr2-sectioning))
   "Alist of LaTeX classes and associated header and structure.
 If #+LaTeX_CLASS is set in the buffer, use its value and the
 associated information.  Here is the structure of each cell:
@@ -776,6 +778,9 @@ when PUB-DIR is set, use this as the publishing directory."
 	   (org-export-latex-parse-global level odd)))))
 
     ;; finalization
+    (when (string-equal org-export-latex-class "scrlttr2")
+      (insert "\n\\end{letter}"))
+    
     (unless body-only (insert "\n\\end{document}"))
 
     ;; Attach description terms to the \item macro
@@ -1016,8 +1021,8 @@ If NUM, export sections as numerical sections."
 			(or sub-heading "")))
 	(insert	"\n")
 	(when label
-	  (insert (mapconcat (lambda (l) (format "\\label{%s}" l))
-			     label-list "\n") "\n"))
+	    (insert (mapconcat (lambda (l) (format "\\label{%s}" l))
+			       label-list "\n")))
 	(insert (org-export-latex-content content))
 	(cond ((stringp subcontent) (insert subcontent))
 	      ((listp subcontent)
diff --git a/lisp/org-scrlttr2.el b/lisp/org-scrlttr2.el
new file mode 100755
index 0000000..c2b3764
--- /dev/null
+++ b/lisp/org-scrlttr2.el
@@ -0,0 +1,20 @@
+(defun org-scrlttr2-sectioning (level heading) 
+  (let ((open "\n\\%s {")
+	(close "}"))
+
+    (setq heading (replace-regexp-in-string "\\s-+" "" heading))
+    (cond 
+     ((string-equal heading "subject")
+      (setq open "\n\\setkomavar{%s} {")
+      )
+     ((string-equal heading "letter")
+      (setq open "\n\\begin{%s} {")
+      )
+     ((string-equal heading "body")
+      (setq open "\n")
+      (setq close "\n")
+      )
+     (t 'ignore))
+    
+    (list heading open close open close))
+  )
diff --git a/lisp/org.el b/lisp/org.el
index abc57a6..6e2b4a1 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -3677,7 +3677,8 @@ If TABLE-TYPE is non-nil, also check for table.el-type tables."
 		  org-export-icalendar-all-agenda-files
 		  org-export-icalendar-combine-agenda-files))
   (org-autoload "org-xoxo" '(org-export-as-xoxo))
-  (org-autoload "org-beamer" '(org-beamer-mode org-beamer-sectioning)))
+  (org-autoload "org-beamer" '(org-beamer-mode org-beamer-sectioning))
+  (org-autoload "org-scrlttr2" '(org-scrlttr2-sectioning)))
 
 ;; Declare and autoload functions from org-agenda.el

             reply	other threads:[~2010-07-25 21:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-25 21:17 Jambunathan K [this message]
2010-07-26 15:21 ` Composing letters using org-mode and scrlttr2 Srinivas
2010-07-26 15:54 ` Bernt Hansen
2010-07-26 16:03   ` John Hendy
2010-07-26 18:47 ` Jambunathan K
2010-07-28 14:23   ` Eric Schulte
2010-08-21  4:52     ` Carsten Dominik
2010-08-21  8:56       ` Jambunathan K

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

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C4CA9F8.7010006@gmail.com \
    --to=kjambunathan@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 public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).