emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH][ox-koma-letter] changed-in-buffer, subject, minor fixes
@ 2013-11-25  0:15 Rasmus
  2013-11-25  9:20 ` Michael Strey
       [not found] ` <m2zjop3cgt.fsf@polytechnique.org>
  0 siblings, 2 replies; 19+ messages in thread
From: Rasmus @ 2013-11-25  0:15 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: jamshark70

[-- Attachment #1: Type: text/plain, Size: 2076 bytes --]

Hi all,

Attached are a couple of changes to ox-koma-letter following a recent
bug report by James.

1. Minor fixes around.  The way subject-format was handled before was
   ugly.  Updated some docstrings etc.

2. better test of whether values have changed in the buffer.  I think
   Alan added this first, but the previous implementation.  I think
   it's more robust now, and it hopefully addresses James' problems
   (please test).  Basically and x-aux variable is added for all
   variables x in :option-alist with a default value "unset".  The
   value can then be tested.

   I'm still concerned about this whole in-buffer voodoo.  Not only do
   we test :email twice (sorry for keep bringing this up), but
   e.g. backaddress can only be set in buffer now:
   
      (when with-backaddress-set
	(format "\\KOMAoption{backaddress}{%s}\n" (if with-backaddress "true" "false")))

   Perhaps this is OK, but one might have to rely on LCO files rather
   than lisp to change defaults (which I don't like).

3. When studying the KOMA manual to answer James' second question I
   came across the komavar title which is currently not supported.  I
   have added support for a separate SUBJECT keyword.  The heuristic
   is something like this (i) if title and subject are be truthful to
   the name no matter what, (ii) if only title or subject is said let
   title be subject if org-koma-letter-title-is-subject-maybe is t
   otherwise be truthful to name.
 
I have of course tested the patches here, but I would appreciate
feedback before they are applied.  There's also a number of TODOs in
the code that I would appreciate feedback on.

In 3. I would personally like to set
org-koma-letter-title-is-subject-maybe to nil by defaults, but this
would break backwards comparability for title keywords.

–Rasmus

PS: We should add a banner to the Worg tutorial that not all info is
    up-to-date and that people one should as a minimum supplement it with
    reading the commentary section of the file (I'm not sure whether
    people do this).

-- 
Enough with the bla bla!

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Minor-fixes-for-ox-koma-script.el.patch --]
[-- Type: text/x-diff, Size: 3987 bytes --]

From f6767ff0900fa65096ca4591b71a60516c4e71c6 Mon Sep 17 00:00:00 2001
From: Rasmus <rasmus@gmx.us>
Date: Sun, 24 Nov 2013 17:57:37 +0100
Subject: [PATCH 1/3] Minor fixes for ox-koma-script.el

* ox-koma-letter.el (org-koma-letter-headline): Correct docstring.
(org-koma-letter-template): Insert subject before document start.
(org-koma-letter-headline): Fix spelling.
(org-koma-letter-template): Better subject handling.
---
 contrib/lisp/ox-koma-letter.el | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el
index 240de29..e4d6f7a 100644
--- a/contrib/lisp/ox-koma-letter.el
+++ b/contrib/lisp/ox-koma-letter.el
@@ -111,11 +111,15 @@
 ;;   \[EXTRA]"))
 ;;
 ;; Then, in your Org document, be sure to require the proper class
-;; with :
+;; with:
 ;;
 ;;    #+LATEX_CLASS: my-letter
 ;;
 ;; Or by setting `org-koma-letter-default-class'.
+;; You may possibly have to load (LaTeX) Babel as well e.g. by adding
+;; it to `org-latex-packages-alist',
+;;
+;;    (add-to-list 'org-latex-packages-alist '("AUTO" "babel" nil))

 ;;; Code:

@@ -211,7 +215,6 @@ At this time the following values are allowed:
  - titled: add title/description to subject.
  - underlined: set subject underlined.
  - untitled: do not add title/description to subject.
- - No-export: do no insert a subject even if present.

 Please refer to the KOMA-script manual (Table 4.16. in the
 English manual of 2012-07-22)."
@@ -516,7 +519,7 @@ appropriate place."
 CONTENTS is the transcoded contents string.  INFO is a plist
 holding export options."
   ;; FIXME: instead of setq'ing org-koma-letter-special-contents and
-  ;; callying varioues stuff it might be nice to put a big let* around the templace
+  ;; callying varioues stuff it might be nice to put a big let* around the template
   ;; as in org-groff...
   (concat
    ;; Time-stamp.
@@ -585,7 +588,7 @@ holding export options."
    (let ((with-backaddress (plist-get info :with-backaddress))
 	 (with-backaddress-set (plist-get info :with-backaddress-changed-in-buffer-p))
 	 (with-foldmarks (plist-get info :with-foldmarks))
-	 (with-foldmarks-set
+	 (with-foldmarks-set
 	  (not (string-equal (plist-get info :with-foldmarks-changed-in-buffer-p)
 			     "foldmarks-not-set")))
 	 (with-phone (plist-get info :with-phone))
@@ -601,28 +604,25 @@ holding export options."
 	(format "\\KOMAoption{fromphone}{%s}\n" (if with-phone "true" "false")))
       (when with-email-set
 	(format "\\KOMAoption{fromemail}{%s}\n" (if with-email "true" "false")))))
-   ;; Document start
-   "\\begin{document}\n\n"
    ;; Subject
    (let* ((with-subject (plist-get info :with-subject))
-	  (subject-format (cond ((member with-subject '("true" "t" t)) nil)
-				((stringp with-subject) (list with-subject))
-				((symbolp with-subject)
-				 (list (symbol-name with-subject)))
-				(t with-subject)))
-	  (subject (org-export-data (plist-get info :title) info))
-	  (l (length subject-format))
-	  (y ""))
+	  ;; TODO: this is a bit ugly and assumes that with-subject is
+	  ;; (a list of) symbol(s) or string(s)...
+	  (subject-format (mapcar
+			   (lambda (elt) (if (and elt (symbolp elt)) (symbol-name elt) elt))
+			   (cond ((member with-subject '("true" "t" t)) nil)
+				 ((listp with-subject) with-subject)
+				 (t (list with-subject)))))
+	  (subject (org-export-data (plist-get info :title) info)))
      (concat
       (when (and with-subject subject-format)
 	(concat
 	 "\\KOMAoption{subject}{"
-	 (apply 'format
-		(dotimes (x l y)
-		  (setq y (concat (if (> x 0) "%s," "%s") y)))
-		subject-format) "}\n"))
+	 (mapconcat 'identity subject-format ",") "}\n" ))
       (when (and subject with-subject)
 	(format "\\setkomavar{subject}{%s}\n\n" subject))))
+   ;; Document start
+   "\\begin{document}\n\n"
    ;; Letter start
    (format "\\begin{letter}{%%\n%s}\n\n"
 	   (org-koma-letter--determine-to-and-from info 'to))
--
1.8.4.2

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-ox-koma-letter-test-with-auxiliary-variables.patch --]
[-- Type: text/x-diff, Size: 8725 bytes --]

From 92d716b5e2adeaa01b8206c59b263512232119ba Mon Sep 17 00:00:00 2001
From: Rasmus <rasmus@gmx.us>
Date: Sun, 24 Nov 2013 19:23:02 +0100
Subject: [PATCH 2/3] ox-koma-letter: test with auxiliary variables

* ox-koma-letter.el (org-koma-letter-aux-suffix): New variable
(org-koma-letter-unset-string): New variable.
(koma-letter-option-alist): Removed x-changed-in-buffer-p variables.
(org-koma-letter--make-aux-variables): Function to add aux variables.
(org-koma-letter--aux-name): Function returns an aux name.
(org-koma-letter--set-in-buffer): Function returns t if
variable is changed in buffer.
(org-koma-letter-template): Use new test for changed in buffer.

An aux variable is used to test wheter a variable has been changed in
buffer.  This commits makes this work consistently.
---
 contrib/lisp/ox-koma-letter.el | 76 +++++++++++++++++++++++++++++++++---------
 1 file changed, 60 insertions(+), 16 deletions(-)

diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el
index e4d6f7a..2705d86 100644
--- a/contrib/lisp/ox-koma-letter.el
+++ b/contrib/lisp/ox-koma-letter.el
@@ -66,6 +66,10 @@
 ;;   - after-letter-order, as above, but after the end of the letter
 ;;     (see `org-koma-letter-special-tags-after-letter').
 ;;
+;; Note, some formatting depends on whether the variables has been set
+;; in the buffer.  For instance, the email is inserted after LCO
+;; files, if changed in the letter.
+;;
 ;; The following variables works differently from the main LaTeX class
 ;;   - "AUTHOR": default to user-full-name but may be disabled.  (see org-koma-letter-author),
 ;;   - "EMAIL": same as AUTHOR, (see org-koma-letter-email),
@@ -93,7 +97,7 @@
 ;;
 ;; to your init file.  This will add a sparse scrlttr2 class and
 ;; set it as the default `org-koma-latex-default-class'.  You can also
-;; add you own letter class.  For instace:
+;; add you own letter class.  For instance:
 ;;
 ;;   (add-to-list 'org-latex-classes
 ;;                '("my-letter"
@@ -179,6 +183,8 @@ function may be given.  Functions must return a string."
   :type 'string)

 (defcustom org-koma-letter-opening nil
+  ;; TODO: We should probably get rid of requirement (1) and just
+  ;; check if the value is set in the buffer.
   "Letter's opening, as a string.

 If (1) this value is nil; (2) the letter is started with a
@@ -291,6 +297,11 @@ A headline is only used if #+OPENING is not set.  See also
 (defvar org-koma-letter-special-contents nil
   "Holds special content temporarily.")

+(defconst org-koma-letter-unset-string "unset"
+  "Value for unset auxiliary variables in :option-alist.")
+
+(defconst org-koma-letter-aux-suffix "-aux"
+  "Suffix for auxiliary variables used to test whether a variable has been set.")

 \f
 ;;; Define Back-End
@@ -302,11 +313,9 @@ A headline is only used if #+OPENING is not set.  See also
 					org-koma-letter-default-class
 					org-latex-default-class) t)
     (:author "AUTHOR" nil (org-koma-letter--get-value org-koma-letter-author) t)
-    (:author-changed-in-buffer-p "AUTHOR" nil nil t)
     (:from-address "FROM_ADDRESS" nil nil newline)
     (:phone-number "PHONE_NUMBER" nil org-koma-letter-phone-number)
     (:email "EMAIL" nil (org-koma-letter--get-value org-koma-letter-email) t)
-    (:email-changed-in-buffer-p "EMAIL" nil nil t)
     (:to-address "TO_ADDRESS" nil nil newline)
     (:place "PLACE" nil org-koma-letter-place)
     (:opening "OPENING" nil org-koma-letter-opening)
@@ -322,14 +331,10 @@ A headline is only used if #+OPENING is not set.  See also
 			 org-koma-letter-special-tags-after-closing)
     (:with-after-letter nil "after-letter-order"
 			org-koma-letter-special-tags-after-letter)
-    (:with-backaddress nil "backaddress" org-koma-letter-use-backaddress)
-    (:with-backaddress-changed-in-buffer-p nil "backaddress" nil)
+    (:with-backaddress nil "backaddress" org-koma-letter-use-backaddress )
     (:with-foldmarks nil "foldmarks" org-koma-letter-use-foldmarks)
-    (:with-foldmarks-changed-in-buffer-p nil "foldmarks" "foldmarks-not-set")
     (:with-phone nil "phone" org-koma-letter-use-phone)
-    (:with-phone-changed-in-buffer-p nil "phone" nil)
     (:with-email nil "email" org-koma-letter-use-email)
-    (:with-email-changed-in-buffer-p nil "email" nil)
     (:with-place nil "place" org-koma-letter-use-place)
     (:with-subject nil "subject" org-koma-letter-subject-format))
   :translate-alist '((export-block . org-koma-letter-export-block)
@@ -347,6 +352,10 @@ A headline is only used if #+OPENING is not set.  See also
 	      (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))))))))

+
+;; Make auxiliary values to check whether variables have been set
+(org-koma-letter--make-aux-variables 'koma-letter)
+
 \f
 ;;; Initialize class function

@@ -362,6 +371,23 @@ A headline is only used if #+OPENING is not set.  See also

 ;;; Helper functions

+(defun org-koma-letter--make-aux-variables (class)
+  "Append the option list of CLASS with aux values that test
+  whether they have been set in buffer."
+  ;; TODO: Is this the proper way to archive this?
+  (let* ((options (org-export-backend-options (org-export-get-backend class)))
+	 (defined (mapcar 'first options))
+	 (aux (mapcar (lambda (l)
+			(let ((name (first l))
+			      (r1 (subseq l 1 3)))
+			  (unless  (member (org-koma-letter--aux-name name) defined)
+			    (append (list (org-koma-letter--aux-name name)) r1
+			     (list 'org-koma-letter-unset-string t)))))
+		      options)))
+    (setf (org-export-backend-options (org-export-get-backend class))
+	  (append options (delq nil aux)))))
+
+
 (defun org-koma-letter-email ()
   "Return the current `user-mail-address'."
   user-mail-address)
@@ -448,6 +474,21 @@ are present return the preferred one as determined by
      "\n" "\\\\\\\\\n"
      (org-koma-letter--normalize-string adr)))))

+(defun org-koma-letter--aux-name (option)
+  "Return the auxiliary name of OPTION"
+  (let ((aux org-koma-letter-aux-suffix))
+    (intern (concat (replace-regexp-in-string aux "" (symbol-name option)) "-aux"))))
+
+(defun org-koma-letter--set-in-buffer (info option)
+  "Test whether an :option-alist value is set.  Return t or nil
+
+Values are \"primary\" values such as :email."
+  (let* ((opt (org-koma-letter--aux-name option))
+	 (value (if (plist-member info opt) (plist-get info opt)
+		  (warn (format "Checked whether %s was set. But no auxiliary value exists.  Returning nil"
+				option)))))
+    (not (equal (org-export-data value info) org-koma-letter-unset-string))))
+
 ;;; Transcode Functions

 ;;;; Export Block
@@ -549,11 +590,11 @@ holding export options."
 	info)))
    (let ((lco (plist-get info :lco))
 	 (author (plist-get info :author))
-	 (author-set (plist-get info :author-changed-in-buffer-p))
+	 (author-set (org-koma-letter--set-in-buffer info :author))
 	 (from-address (org-koma-letter--determine-to-and-from info 'from))
 	 (phone-number (plist-get info :phone-number))
 	 (email (plist-get info :email))
-	 (email-set (plist-get info :email-changed-in-buffer-p))
+	 (email-set (org-koma-letter--set-in-buffer info :email))
 	 (signature (plist-get info :signature)))
      (concat
       ;; author or email not set in file: may be overridden by lco
@@ -586,16 +627,19 @@ holding export options."
        (format "\\setkomavar{place}{%s}\n" (if with-place place ""))))
    ;; KOMA options
    (let ((with-backaddress (plist-get info :with-backaddress))
-	 (with-backaddress-set (plist-get info :with-backaddress-changed-in-buffer-p))
+	 (with-backaddress-set (org-koma-letter--set-in-buffer info :with-backaddress))
 	 (with-foldmarks (plist-get info :with-foldmarks))
-	 (with-foldmarks-set
-	  (not (string-equal (plist-get info :with-foldmarks-changed-in-buffer-p)
-			     "foldmarks-not-set")))
+	 (with-foldmarks-set (org-koma-letter--set-in-buffer info :with-foldmarks))
 	 (with-phone (plist-get info :with-phone))
-	 (with-phone-set (plist-get info :with-phone-changed-in-buffer-p))
+	 (with-phone-set (org-koma-letter--set-in-buffer info :with-phone))
+	 ;; TODO: email can now be set in two different places.  This
+	 ;; is handled in an inelegant manner.
 	 (with-email (plist-get info :with-email))
-	 (with-email-set (plist-get info :with-email-changed-in-buffer-p)))
+	 (with-email-set (org-koma-letter--set-in-buffer info :with-email)))
      (concat
+      ;; TODO: with the (with . .)-clauses the default values are
+      ;; basically obsolete as these variables are only set when
+      ;; changed in buffer...
       (when with-backaddress-set
 	(format "\\KOMAoption{backaddress}{%s}\n" (if with-backaddress "true" "false")))
       (when with-foldmarks-set
--
1.8.4.2

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0003-Allow-separate-subject-and-title-in-ox-koma-letter.patch --]
[-- Type: text/x-diff, Size: 5434 bytes --]

From d743e01fe6cd8a17f40140b0f33e8550c37740a4 Mon Sep 17 00:00:00 2001
From: Rasmus <rasmus@gmx.us>
Date: Mon, 25 Nov 2013 00:23:09 +0100
Subject: [PATCH 3/3] Allow separate subject and title in ox-koma-letter

* ox-koma-letter.el (org-koma-letter-use-title): New variable.
(org-koma-letter-title-is-subject-maybe): New variable.
(koma-letter-template): Allow seperate subject and title.
(org-koma-letter-template): Allow seperate subject and title.

Depending on the variable `org-koma-letter-title-is-subject-maybe' the
komavar "subject" may be set either with the TITLE keyword or with the
SUBJECT keyword.  It is now possible to typeset komavar title.
---
 contrib/lisp/ox-koma-letter.el | 35 +++++++++++++++++++++++++++++++----
 1 file changed, 31 insertions(+), 4 deletions(-)

diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el
index 2705d86..d6a037b 100644
--- a/contrib/lisp/ox-koma-letter.el
+++ b/contrib/lisp/ox-koma-letter.el
@@ -36,12 +36,13 @@
 ;; keywords:
 ;;   - "CLOSING" (see `org-koma-letter-closing'),
 ;;   - "FROM_ADDRESS" (see `org-koma-letter-from-address'),
+;;   - "TO_ADDRESS".  If unspecified this is set to "\mbox{}".
 ;;   - "LCO" (see `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')
 ;;   - "PLACE" (see `org-koma-letter-place')
-;;   - and "TO_ADDRESS".  If unspecified this is set to "\mbox{}".
+;;   - "SUBJECT" (see `org-koma-letter-title-is-subject-maybe')
 ;;
 ;; TO_ADDRESS and FROM_ADDRESS can also be specified using heading
 ;; with the special tags specified in
@@ -50,6 +51,9 @@
 ;; both a headline and a keyword specify a to or from address the
 ;; value is determined in accordance with
 ;; `org-koma-letter-prefer-special-headings'.
+;; If `org-koma-letter-title-is-subject-maybe' is t both SUBJECT and
+;; TITLE can be used to set the subject.  If both are set they take
+;; the value as indicated by name.
 ;;
 ;; A number of OPTIONS settings can be set to change which contents is
 ;; exported.
@@ -60,6 +64,7 @@
 ;;   - place (see `org-koma-letter-use-place')
 ;;   - subject, a list of format options
 ;;     (see `org-koma-letter-subject-format')
+;;   - title (see `org-koma-letter-use-title')
 ;;   - after-closing-order, a list of the ordering of headings with
 ;;     special tags after closing (see
 ;;     `org-koma-letter-special-tags-after-closing')
@@ -271,6 +276,13 @@ Use `foldmarks:true' to activate default fold marks or
   :group 'org-export-koma-letter
   :type 'boolean)

+(defcustom org-koma-letter-use-title t
+  "Use a title in the letter.
+
+See also `org-koma-letter-title-is-subject-maybe'."
+  :group 'org-export-koma-letter
+  :type 'boolean)
+
 (defcustom org-koma-letter-default-class nil
   "Default class for `org-koma-letter'.

@@ -285,6 +297,12 @@ A headline is only used if #+OPENING is not set.  See also
   :group 'org-export-koma-letter
   :type 'boolean)

+(defcustom org-koma-letter-title-is-subject-maybe t
+  "Whether the TITLE keyword should be interpreted as subject
+when no subject is present."
+    :group 'org-export-koma-letter
+    :type 'boolean)
+
 (defconst org-koma-letter-special-tags-in-letter '(to from)
   "Header tags related to the letter itself.")

@@ -313,6 +331,7 @@ A headline is only used if #+OPENING is not set.  See also
 					org-koma-letter-default-class
 					org-latex-default-class) t)
     (:author "AUTHOR" nil (org-koma-letter--get-value org-koma-letter-author) t)
+    (:subject "SUBJECT" nil nil space)
     (:from-address "FROM_ADDRESS" nil nil newline)
     (:phone-number "PHONE_NUMBER" nil org-koma-letter-phone-number)
     (:email "EMAIL" nil (org-koma-letter--get-value org-koma-letter-email) t)
@@ -336,7 +355,9 @@ A headline is only used if #+OPENING is not set.  See also
     (: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-subject-format))
+    (:with-subject nil "subject" org-koma-letter-subject-format)
+    (:with-title nil "title" org-koma-letter-use-title)
+    )
   :translate-alist '((export-block . org-koma-letter-export-block)
 		     (export-snippet . org-koma-letter-export-snippet)
 		     (headline . org-koma-letter-headline)
@@ -657,14 +678,20 @@ holding export options."
 			   (cond ((member with-subject '("true" "t" t)) nil)
 				 ((listp with-subject) with-subject)
 				 (t (list with-subject)))))
-	  (subject (org-export-data (plist-get info :title) info)))
+	  (prefer-subject org-koma-letter-title-is-subject-maybe)
+	  (subject* (org-export-data (plist-get info :subject) info))
+	  (title* (org-export-data (plist-get info :title) info))
+	  (subject (if prefer-subject (or subject* title*) subject*))
+	  (title (if prefer-subject (and subject* title*) title*))
+	  )
      (concat
       (when (and with-subject subject-format)
 	(concat
 	 "\\KOMAoption{subject}{"
 	 (mapconcat 'identity subject-format ",") "}\n" ))
       (when (and subject with-subject)
-	(format "\\setkomavar{subject}{%s}\n\n" subject))))
+	(format "\\setkomavar{subject}{%s}\n\n" subject))
+      (when title (format "\\setkomavar{title}{%s}\n\n" title))))
    ;; Document start
    "\\begin{document}\n\n"
    ;; Letter start
--
1.8.4.2

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH][ox-koma-letter] changed-in-buffer, subject, minor fixes
  2013-11-25  0:15 [PATCH][ox-koma-letter] changed-in-buffer, subject, minor fixes Rasmus
@ 2013-11-25  9:20 ` Michael Strey
       [not found] ` <m2zjop3cgt.fsf@polytechnique.org>
  1 sibling, 0 replies; 19+ messages in thread
From: Michael Strey @ 2013-11-25  9:20 UTC (permalink / raw)
  To: Rasmus; +Cc: emacs-orgmode

Hi Rasmus,

rasmus@gmx.us writes:

[...]

> 3. When studying the KOMA manual to answer James' second question I
>    came across the komavar title which is currently not supported.  I
>    have added support for a separate SUBJECT keyword.  The heuristic
>    is something like this (i) if title and subject are be truthful to
>    the name no matter what, (ii) if only title or subject is said let
>    title be subject if org-koma-letter-title-is-subject-maybe is t
>    otherwise be truthful to name.

Thank you for implementing this feature.  I already missed it.

[...]

> In 3. I would personally like to set
> org-koma-letter-title-is-subject-maybe to nil by defaults, but this
> would break backwards comparability for title keywords.

I would like to encourage you to do so, even if it breaks backward
compatibility.  Since Koma Letter supports Title and Subject, Title
should be title and Subject should be subject by default.  Everything
else could drive users crazy.

I've been using Koma Letter for many years for various purposes.  Title
without subject makes sense, for instance, when writing press releases
and certificates.

Best regards
-- 
Michael Strey
http://www.strey.biz

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH][ox-koma-letter] changed-in-buffer, subject, minor fixes
       [not found] ` <m2zjop3cgt.fsf@polytechnique.org>
@ 2014-01-18 16:11   ` Rasmus
  2014-01-18 16:18     ` Nicolas Goaziou
  0 siblings, 1 reply; 19+ messages in thread
From: Rasmus @ 2014-01-18 16:11 UTC (permalink / raw)
  To: alan.schmitt; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 2378 bytes --]

Alan,

I finally had the time to fix these old patches.  Sorry about the
wait.

Alan Schmitt <alan.schmitt@polytechnique.org> writes:

> Hello,
>> Attached are a couple of changes to ox-koma-letter following a recent
>> bug report by James.
>>
>> 1. Minor fixes around.  The way subject-format was handled before was
>>    ugly.  Updated some docstrings etc.
>
> I'm afraid I'm not competent to talk about the subject handling (the
> elisp is beyond my level). I'm fine with the docstring update, with one
> nitpick: "e.g." should always be present as a parenthetical sentence:
> "..., e.g, ...".

Fixed.

>> 2. better test of whether values have changed in the buffer.  I think
>>    Alan added this first, but the previous implementation.  I think
>>    it's more robust now, and it hopefully addresses James' problems
>>    (please test).  Basically and x-aux variable is added for all
>>    variables x in :option-alist with a default value "unset".  The
>>    value can then be tested.
>
> Isn't "unset" a bit dangerous? Can we detect when we set something to
> "unset" (I don't know if it's a valid option for anything)? (By the way,
> the previous value of "nil", except for foldmarks, was much worse.) How
> about using "ox-koma-unset"?


Fixed.

>> 3. When studying the KOMA manual to answer James' second question I
>>    came across the komavar title which is currently not supported.  I
>>    have added support for a separate SUBJECT keyword.  The heuristic
>>    is something like this (i) if title and subject are be truthful to
>>    the name no matter what, (ii) if only title or subject is said let
>>    title be subject if org-koma-letter-title-is-subject-maybe is t
>>    otherwise be truthful to name.
>
> This sounds good. Once again, I'm not sure I'm competent enough to
> criticize the elisp code.

> [snip]


>> In 3. I would personally like to set
>> org-koma-letter-title-is-subject-maybe to nil by defaults, but this
>> would break backwards comparability for title keywords.
>
> I don't mind breaking backward compatibility at this point, if we make
> clear how to get back the previous output.

TITLE is now title and SUBJECT is now subject by default.

These new patches should apply against the master branch. 

–Rasmus

-- 
I almost cut my hair, it happened just the other day

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Minor-fixes-for-ox-koma-script.el.patch --]
[-- Type: text/x-diff, Size: 5838 bytes --]

From c4adcc44f08f4e92efba1b7aabb45807cffc5f1c Mon Sep 17 00:00:00 2001
From: Rasmus Pank Roulund <w530@pank.eu>
Date: Sun, 24 Nov 2013 17:57:37 +0100
Subject: [PATCH 1/3] Minor fixes for ox-koma-script.el

* ox-koma-letter.el (org-koma-letter-headline) (org-koma-letter-email)
(org-koma-letter-prefer-special-headings) (org-koma-letter-use-backaddress)
(org-koma-letter-headline-is-opening-maybe): Correct docstring.
(org-koma-letter-template): Insert subject before document start.
(org-koma-letter-headline): Fix spelling.
(org-koma-letter-template): Better subject handling.
---
 contrib/lisp/ox-koma-letter.el | 50 +++++++++++++++++++++++-------------------
 1 file changed, 27 insertions(+), 23 deletions(-)

diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el
index 240de29..3a0fa53 100644
--- a/contrib/lisp/ox-koma-letter.el
+++ b/contrib/lisp/ox-koma-letter.el
@@ -111,11 +111,15 @@
 ;;   \[EXTRA]"))
 ;;
 ;; Then, in your Org document, be sure to require the proper class
-;; with :
+;; with:
 ;;
 ;;    #+LATEX_CLASS: my-letter
 ;;
 ;; Or by setting `org-koma-letter-default-class'.
+;; You may possibly have to load (LaTeX) Babel as well e.g. by adding
+;; it to `org-latex-packages-alist',
+;;
+;;    (add-to-list 'org-latex-packages-alist '("AUTO" "babel" nil))
 
 ;;; Code:
 
@@ -148,7 +152,7 @@ string."
 		(const :tag "Do not export author" nil)))
 
 (defcustom org-koma-letter-email 'org-koma-letter-email
-  "The sender's email address.
+  "Sender's email address.
 
 This variable defaults to the value `org-koma-letter-email' which
 returns `user-mail-address'.  Alternatively a string, nil or a
@@ -189,7 +193,11 @@ t the value opening will be implicit set as the headline title."
   :type 'string)
 
 (defcustom org-koma-letter-prefer-special-headings nil
-  "If TO and/or FROM is specified using both a heading and a keyword the heading value will be preferred if the variable is t."
+  "Prefer special headings in letters.
+
+If TO and/or FROM is specified using both a heading and a keyword
+the heading value will be preferred if this variable is non-nil.
+"
   :group 'org-export-koma-letter
   :type 'boolean)
 
@@ -211,7 +219,6 @@ At this time the following values are allowed:
  - titled: add title/description to subject.
  - underlined: set subject underlined.
  - untitled: do not add title/description to subject.
- - No-export: do no insert a subject even if present.
 
 Please refer to the KOMA-script manual (Table 4.16. in the
 English manual of 2012-07-22)."
@@ -233,7 +240,7 @@ English manual of 2012-07-22)."
 
 
 (defcustom org-koma-letter-use-backaddress nil
-  "Print return address in small line above to address."
+  "Print return address above the address."
   :group 'org-export-koma-letter
   :type 'boolean)
 
@@ -270,7 +277,8 @@ The value must be a member of `org-latex-classes'."
   :type 'string)
 
 (defcustom org-koma-letter-headline-is-opening-maybe t
-  "Whether a headline may be used as an opening.
+  "Let headlines be used as an opening if non-nil.
+
 A headline is only used if #+OPENING is not set.  See also
 `org-koma-letter-opening'."
   :group 'org-export-koma-letter
@@ -288,7 +296,6 @@ A headline is only used if #+OPENING is not set.  See also
 (defvar org-koma-letter-special-contents nil
   "Holds special content temporarily.")
 
-
 \f
 ;;; Define Back-End
 
@@ -516,7 +523,7 @@ appropriate place."
 CONTENTS is the transcoded contents string.  INFO is a plist
 holding export options."
   ;; FIXME: instead of setq'ing org-koma-letter-special-contents and
-  ;; callying varioues stuff it might be nice to put a big let* around the templace
+  ;; callying varioues stuff it might be nice to put a big let* around the template
   ;; as in org-groff...
   (concat
    ;; Time-stamp.
@@ -585,7 +592,7 @@ holding export options."
    (let ((with-backaddress (plist-get info :with-backaddress))
 	 (with-backaddress-set (plist-get info :with-backaddress-changed-in-buffer-p))
 	 (with-foldmarks (plist-get info :with-foldmarks))
-	 (with-foldmarks-set 
+	 (with-foldmarks-set
 	  (not (string-equal (plist-get info :with-foldmarks-changed-in-buffer-p)
 			     "foldmarks-not-set")))
 	 (with-phone (plist-get info :with-phone))
@@ -601,28 +608,25 @@ holding export options."
 	(format "\\KOMAoption{fromphone}{%s}\n" (if with-phone "true" "false")))
       (when with-email-set
 	(format "\\KOMAoption{fromemail}{%s}\n" (if with-email "true" "false")))))
-   ;; Document start
-   "\\begin{document}\n\n"
    ;; Subject
    (let* ((with-subject (plist-get info :with-subject))
-	  (subject-format (cond ((member with-subject '("true" "t" t)) nil)
-				((stringp with-subject) (list with-subject))
-				((symbolp with-subject)
-				 (list (symbol-name with-subject)))
-				(t with-subject)))
-	  (subject (org-export-data (plist-get info :title) info))
-	  (l (length subject-format))
-	  (y ""))
+	  ;; TODO: this is a bit ugly and assumes that with-subject is
+	  ;; (a list of) symbol(s) or string(s)...
+	  (subject-format (mapcar
+			   (lambda (elt) (if (and elt (symbolp elt)) (symbol-name elt) elt))
+			   (cond ((member with-subject '("true" "t" t)) nil)
+				 ((listp with-subject) with-subject)
+				 (t (list with-subject)))))
+	  (subject (org-export-data (plist-get info :title) info)))
      (concat
       (when (and with-subject subject-format)
 	(concat
 	 "\\KOMAoption{subject}{"
-	 (apply 'format
-		(dotimes (x l y)
-		  (setq y (concat (if (> x 0) "%s," "%s") y)))
-		subject-format) "}\n"))
+	 (mapconcat 'identity subject-format ",") "}\n" ))
       (when (and subject with-subject)
 	(format "\\setkomavar{subject}{%s}\n\n" subject))))
+   ;; Document start
+   "\\begin{document}\n\n"
    ;; Letter start
    (format "\\begin{letter}{%%\n%s}\n\n"
 	   (org-koma-letter--determine-to-and-from info 'to))
-- 
1.8.5.3


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-ox-koma-letter-test-with-auxiliary-variables.patch --]
[-- Type: text/x-diff, Size: 9130 bytes --]

From 74b9c1e1f039fefeb293a675845e127a63fac202 Mon Sep 17 00:00:00 2001
From: Rasmus Pank Roulund <w530@pank.eu>
Date: Sun, 24 Nov 2013 19:23:02 +0100
Subject: [PATCH 2/3] ox-koma-letter: test with auxiliary variables

* ox-koma-letter.el (org-koma-letter-aux-suffix): New variable
(org-koma-letter-unset-string): New variable.
(koma-letter-option-alist): Removed x-changed-in-buffer-p variables.
(org-koma-letter--make-aux-variables): Function to add aux variables.
(org-koma-letter--aux-name): Function returns an aux name.
(org-koma-letter--set-in-buffer): Function returns t if
variable is changed in buffer.
(org-koma-letter-template): Use new test for changed in buffer.

An aux variable is used to test wheter a variable has been changed in
buffer.  This commits makes this work consistently.
---
 contrib/lisp/ox-koma-letter.el | 79 +++++++++++++++++++++++++++++++++---------
 1 file changed, 62 insertions(+), 17 deletions(-)

diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el
index 3a0fa53..ef9f624 100644
--- a/contrib/lisp/ox-koma-letter.el
+++ b/contrib/lisp/ox-koma-letter.el
@@ -66,6 +66,10 @@
 ;;   - after-letter-order, as above, but after the end of the letter
 ;;     (see `org-koma-letter-special-tags-after-letter').
 ;;
+;; Note, some formatting depends on whether the variables has been set
+;; in the buffer.  For instance, the email is inserted after LCO
+;; files, if changed in the letter.
+;;
 ;; The following variables works differently from the main LaTeX class
 ;;   - "AUTHOR": default to user-full-name but may be disabled.  (see org-koma-letter-author),
 ;;   - "EMAIL": same as AUTHOR, (see org-koma-letter-email),
@@ -93,7 +97,7 @@
 ;;
 ;; to your init file.  This will add a sparse scrlttr2 class and
 ;; set it as the default `org-koma-latex-default-class'.  You can also
-;; add you own letter class.  For instace:
+;; add you own letter class.  For instance:
 ;;
 ;;   (add-to-list 'org-latex-classes
 ;;                '("my-letter"
@@ -116,7 +120,7 @@
 ;;    #+LATEX_CLASS: my-letter
 ;;
 ;; Or by setting `org-koma-letter-default-class'.
-;; You may possibly have to load (LaTeX) Babel as well e.g. by adding
+;; You may possibly have to load (LaTeX) Babel as well, e.g., by adding
 ;; it to `org-latex-packages-alist',
 ;;
 ;;    (add-to-list 'org-latex-packages-alist '("AUTO" "babel" nil))
@@ -179,6 +183,8 @@ function may be given.  Functions must return a string."
   :type 'string)
 
 (defcustom org-koma-letter-opening nil
+  ;; TODO: We should probably get rid of requirement (1) and just
+  ;; check if the value is set in the buffer.
   "Letter's opening, as a string.
 
 If (1) this value is nil; (2) the letter is started with a
@@ -296,6 +302,12 @@ A headline is only used if #+OPENING is not set.  See also
 (defvar org-koma-letter-special-contents nil
   "Holds special content temporarily.")
 
+(defconst org-koma-letter-unset-string "*ox-koma-unset*"
+  "Value for unset auxiliary variables in :option-alist.")
+
+(defconst org-koma-letter-aux-suffix "ox-koma-aux"
+  "Suffix for auxiliary variables used to test whether a variable has been set.")
+
 \f
 ;;; Define Back-End
 
@@ -306,11 +318,9 @@ A headline is only used if #+OPENING is not set.  See also
 					org-koma-letter-default-class
 					org-latex-default-class) t)
     (:author "AUTHOR" nil (org-koma-letter--get-value org-koma-letter-author) t)
-    (:author-changed-in-buffer-p "AUTHOR" nil nil t)
     (:from-address "FROM_ADDRESS" nil nil newline)
     (:phone-number "PHONE_NUMBER" nil org-koma-letter-phone-number)
     (:email "EMAIL" nil (org-koma-letter--get-value org-koma-letter-email) t)
-    (:email-changed-in-buffer-p "EMAIL" nil nil t)
     (:to-address "TO_ADDRESS" nil nil newline)
     (:place "PLACE" nil org-koma-letter-place)
     (:opening "OPENING" nil org-koma-letter-opening)
@@ -326,14 +336,10 @@ A headline is only used if #+OPENING is not set.  See also
 			 org-koma-letter-special-tags-after-closing)
     (:with-after-letter nil "after-letter-order"
 			org-koma-letter-special-tags-after-letter)
-    (:with-backaddress nil "backaddress" org-koma-letter-use-backaddress)
-    (:with-backaddress-changed-in-buffer-p nil "backaddress" nil)
+    (:with-backaddress nil "backaddress" org-koma-letter-use-backaddress )
     (:with-foldmarks nil "foldmarks" org-koma-letter-use-foldmarks)
-    (:with-foldmarks-changed-in-buffer-p nil "foldmarks" "foldmarks-not-set")
     (:with-phone nil "phone" org-koma-letter-use-phone)
-    (:with-phone-changed-in-buffer-p nil "phone" nil)
     (:with-email nil "email" org-koma-letter-use-email)
-    (:with-email-changed-in-buffer-p nil "email" nil)
     (:with-place nil "place" org-koma-letter-use-place)
     (:with-subject nil "subject" org-koma-letter-subject-format))
   :translate-alist '((export-block . org-koma-letter-export-block)
@@ -351,6 +357,10 @@ A headline is only used if #+OPENING is not set.  See also
 	      (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))))))))
 
+
+;; Make auxiliary values to check whether variables have been set
+(org-koma-letter--make-aux-variables 'koma-letter)
+
 \f
 ;;; Initialize class function
 
@@ -366,6 +376,23 @@ A headline is only used if #+OPENING is not set.  See also
 
 ;;; Helper functions
 
+(defun org-koma-letter--make-aux-variables (class)
+  "Append the option list of CLASS with aux values that test
+  whether they have been set in buffer."
+  ;; TODO: Is this the proper way to archive this?
+  (let* ((options (org-export-backend-options (org-export-get-backend class)))
+	 (defined (mapcar 'first options))
+	 (aux (mapcar (lambda (l)
+			(let ((name (first l))
+			      (r1 (subseq l 1 3)))
+			  (unless  (member (org-koma-letter--aux-name name) defined)
+			    (append (list (org-koma-letter--aux-name name)) r1
+			     (list 'org-koma-letter-unset-string t)))))
+		      options)))
+    (setf (org-export-backend-options (org-export-get-backend class))
+	  (append options (delq nil aux)))))
+
+
 (defun org-koma-letter-email ()
   "Return the current `user-mail-address'."
   user-mail-address)
@@ -452,6 +479,21 @@ are present return the preferred one as determined by
      "\n" "\\\\\\\\\n"
      (org-koma-letter--normalize-string adr)))))
 
+(defun org-koma-letter--aux-name (option)
+  "Return the auxiliary name of OPTION"
+  (let ((aux org-koma-letter-aux-suffix))
+    (intern (concat (replace-regexp-in-string aux "" (symbol-name option)) "-aux"))))
+
+(defun org-koma-letter--set-in-buffer (info option)
+  "Test whether an :option-alist value is set.  Return t or nil
+
+Values are \"primary\" values such as :email."
+  (let* ((opt (org-koma-letter--aux-name option))
+	 (value (if (plist-member info opt) (plist-get info opt)
+		  (warn (format "Checked whether %s was set. But no auxiliary value exists.  Returning nil"
+				option)))))
+    (not (equal (org-export-data value info) org-koma-letter-unset-string))))
+
 ;;; Transcode Functions
 
 ;;;; Export Block
@@ -553,11 +595,11 @@ holding export options."
 	info)))
    (let ((lco (plist-get info :lco))
 	 (author (plist-get info :author))
-	 (author-set (plist-get info :author-changed-in-buffer-p))
+	 (author-set (org-koma-letter--set-in-buffer info :author))
 	 (from-address (org-koma-letter--determine-to-and-from info 'from))
 	 (phone-number (plist-get info :phone-number))
 	 (email (plist-get info :email))
-	 (email-set (plist-get info :email-changed-in-buffer-p))
+	 (email-set (org-koma-letter--set-in-buffer info :email))
 	 (signature (plist-get info :signature)))
      (concat
       ;; author or email not set in file: may be overridden by lco
@@ -590,16 +632,19 @@ holding export options."
        (format "\\setkomavar{place}{%s}\n" (if with-place place ""))))
    ;; KOMA options
    (let ((with-backaddress (plist-get info :with-backaddress))
-	 (with-backaddress-set (plist-get info :with-backaddress-changed-in-buffer-p))
+	 (with-backaddress-set (org-koma-letter--set-in-buffer info :with-backaddress))
 	 (with-foldmarks (plist-get info :with-foldmarks))
-	 (with-foldmarks-set
-	  (not (string-equal (plist-get info :with-foldmarks-changed-in-buffer-p)
-			     "foldmarks-not-set")))
+	 (with-foldmarks-set (org-koma-letter--set-in-buffer info :with-foldmarks))
 	 (with-phone (plist-get info :with-phone))
-	 (with-phone-set (plist-get info :with-phone-changed-in-buffer-p))
+	 (with-phone-set (org-koma-letter--set-in-buffer info :with-phone))
+	 ;; TODO: email can now be set in two different places.  This
+	 ;; is handled in an inelegant manner.
 	 (with-email (plist-get info :with-email))
-	 (with-email-set (plist-get info :with-email-changed-in-buffer-p)))
+	 (with-email-set (org-koma-letter--set-in-buffer info :with-email)))
      (concat
+      ;; TODO: with the (with . .)-clauses the default values are
+      ;; basically obsolete as these variables are only set when
+      ;; changed in buffer...
       (when with-backaddress-set
 	(format "\\KOMAoption{backaddress}{%s}\n" (if with-backaddress "true" "false")))
       (when with-foldmarks-set
-- 
1.8.5.3


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0003-Allow-separate-subject-and-title-in-ox-koma-letter.patch --]
[-- Type: text/x-diff, Size: 4001 bytes --]

From 16fe81deb90bd7eca503a94bc3cd53b366a3259a Mon Sep 17 00:00:00 2001
From: Rasmus Pank Roulund <w530@pank.eu>
Date: Mon, 25 Nov 2013 00:23:09 +0100
Subject: [PATCH 3/3] Allow separate subject and title in ox-koma-letter

* ox-koma-letter.el (org-koma-letter-use-title): New variable.
(org-koma-letter-title-is-subject-maybe): New variable.
(koma-letter-template): Allow seperate subject and title.
(org-koma-letter-template): Allow seperate subject and title.

Depending on the variable `org-koma-letter-title-is-subject-maybe' the
komavar "subject" may be set either with the TITLE keyword or with the
SUBJECT keyword.  It is now possible to typeset komavar title.
---
 contrib/lisp/ox-koma-letter.el | 30 +++++++++++++++++++++++++++---
 1 file changed, 27 insertions(+), 3 deletions(-)

diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el
index ef9f624..4f3fc57 100644
--- a/contrib/lisp/ox-koma-letter.el
+++ b/contrib/lisp/ox-koma-letter.el
@@ -275,6 +275,13 @@ Use `foldmarks:true' to activate default fold marks or
   :group 'org-export-koma-letter
   :type 'boolean)
 
+(defcustom org-koma-letter-use-title t
+  "Use a title in the letter.
+
+See also `org-koma-letter-title-is-subject-maybe'."
+  :group 'org-export-koma-letter
+  :type 'boolean)
+
 (defcustom org-koma-letter-default-class nil
   "Default class for `org-koma-letter'.
 
@@ -290,6 +297,14 @@ A headline is only used if #+OPENING is not set.  See also
   :group 'org-export-koma-letter
   :type 'boolean)
 
+(defcustom org-koma-letter-title-is-subject-maybe nil
+  "Let TITLE keyword be interpreted as subject when no subject is present if non-nil.
+
+This may be useful for older documents where the SUBJECT keyword
+was not present."
+    :group 'org-export-koma-letter
+    :type 'boolean)
+
 (defconst org-koma-letter-special-tags-in-letter '(to from)
   "Header tags related to the letter itself.")
 
@@ -318,6 +333,7 @@ A headline is only used if #+OPENING is not set.  See also
 					org-koma-letter-default-class
 					org-latex-default-class) t)
     (:author "AUTHOR" nil (org-koma-letter--get-value org-koma-letter-author) t)
+    (:subject "SUBJECT" nil nil space)
     (:from-address "FROM_ADDRESS" nil nil newline)
     (:phone-number "PHONE_NUMBER" nil org-koma-letter-phone-number)
     (:email "EMAIL" nil (org-koma-letter--get-value org-koma-letter-email) t)
@@ -341,7 +357,9 @@ A headline is only used if #+OPENING is not set.  See also
     (: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-subject-format))
+    (:with-subject nil "subject" org-koma-letter-subject-format)
+    (:with-title nil "title" org-koma-letter-use-title)
+    )
   :translate-alist '((export-block . org-koma-letter-export-block)
 		     (export-snippet . org-koma-letter-export-snippet)
 		     (headline . org-koma-letter-headline)
@@ -662,14 +680,20 @@ holding export options."
 			   (cond ((member with-subject '("true" "t" t)) nil)
 				 ((listp with-subject) with-subject)
 				 (t (list with-subject)))))
-	  (subject (org-export-data (plist-get info :title) info)))
+	  (prefer-subject org-koma-letter-title-is-subject-maybe)
+	  (subject* (org-export-data (plist-get info :subject) info))
+	  (title* (org-export-data (plist-get info :title) info))
+	  (subject (if prefer-subject (or subject* title*) subject*))
+	  (title (if prefer-subject (and subject* title*) title*))
+	  )
      (concat
       (when (and with-subject subject-format)
 	(concat
 	 "\\KOMAoption{subject}{"
 	 (mapconcat 'identity subject-format ",") "}\n" ))
       (when (and subject with-subject)
-	(format "\\setkomavar{subject}{%s}\n\n" subject))))
+	(format "\\setkomavar{subject}{%s}\n\n" subject))
+      (when title (format "\\setkomavar{title}{%s}\n\n" title))))
    ;; Document start
    "\\begin{document}\n\n"
    ;; Letter start
-- 
1.8.5.3


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH][ox-koma-letter] changed-in-buffer, subject, minor fixes
  2014-01-18 16:11   ` Rasmus
@ 2014-01-18 16:18     ` Nicolas Goaziou
  2014-01-18 19:27       ` Rasmus
  0 siblings, 1 reply; 19+ messages in thread
From: Nicolas Goaziou @ 2014-01-18 16:18 UTC (permalink / raw)
  To: Rasmus; +Cc: alan.schmitt, emacs-orgmode

Hello,

Rasmus <rasmus@gmx.us> writes:

> I finally had the time to fix these old patches.  Sorry about the
> wait.

You should update Org first. I modified large parts of ox-koma-letter.el
recently so your patches will probably not apply. Also, some parts are
not necessary anymore.


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH][ox-koma-letter] changed-in-buffer, subject, minor fixes
  2014-01-18 16:18     ` Nicolas Goaziou
@ 2014-01-18 19:27       ` Rasmus
  2014-01-18 20:05         ` Nicolas Goaziou
  0 siblings, 1 reply; 19+ messages in thread
From: Rasmus @ 2014-01-18 19:27 UTC (permalink / raw)
  To: emacs-orgmode

Nicolas Goaziou <n.goaziou@gmail.com> writes:

>> I finally had the time to fix these old patches.  Sorry about the
>> wait.
>
> You should update Org first. I modified large parts of ox-koma-letter.el
> recently so your patches will probably not apply. Also, some parts are
> not necessary anymore.

I did. . .  And I formatted the patch against origin/master.  I'll
look into it.  Thanks.

–Rasmus

-- 
Hooray!

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH][ox-koma-letter] changed-in-buffer, subject, minor fixes
  2014-01-18 19:27       ` Rasmus
@ 2014-01-18 20:05         ` Nicolas Goaziou
  2014-01-25 13:44           ` Rasmus
  0 siblings, 1 reply; 19+ messages in thread
From: Nicolas Goaziou @ 2014-01-18 20:05 UTC (permalink / raw)
  To: Rasmus; +Cc: emacs-orgmode

Rasmus <rasmus@gmx.us> writes:

> Nicolas Goaziou <n.goaziou@gmail.com> writes:
>
>>> I finally had the time to fix these old patches.  Sorry about the
>>> wait.
>>
>> You should update Org first. I modified large parts of ox-koma-letter.el
>> recently so your patches will probably not apply. Also, some parts are
>> not necessary anymore.
>
> I did. . .  And I formatted the patch against origin/master.  I'll
> look into it.  Thanks.

After a cursory look, it seems that patches 1 and 2 are not necessary
anymore. I didn't tackle down subject vs title issue, so patch 3 is
needed. Though, I think it needs some changes to be applied.


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH][ox-koma-letter] changed-in-buffer, subject, minor fixes
  2014-01-18 20:05         ` Nicolas Goaziou
@ 2014-01-25 13:44           ` Rasmus
  2014-01-25 22:18             ` Nicolas Goaziou
  0 siblings, 1 reply; 19+ messages in thread
From: Rasmus @ 2014-01-25 13:44 UTC (permalink / raw)
  To: n.goaziou; +Cc: alan.schmitt, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1187 bytes --]

Nicolas,

Nicolas Goaziou <n.goaziou@gmail.com> writes:

> Rasmus <rasmus@gmx.us> writes:
>
>> Nicolas Goaziou <n.goaziou@gmail.com> writes:
>>
>>>> I finally had the time to fix these old patches.  Sorry about the
>>>> wait.
>>>
>>> You should update Org first. I modified large parts of ox-koma-letter.el
>>> recently so your patches will probably not apply. Also, some parts are
>>> not necessary anymore.
>>
>> I did. . .  And I formatted the patch against origin/master.  I'll
>> look into it.  Thanks.
>
> After a cursory look, it seems that patches 1 and 2 are not necessary
> anymore. I didn't tackle down subject vs title issue, so patch 3 is
> needed. Though, I think it needs some changes to be applied.

Would you give the attached patches a spin?  I think they work nicely;
only the second patch is non-trivial.  Basically, one can ignore
subject and title differences as now by setting
org-koma-letter-prefer-subject to t and not use the SUBJECT keyword.

I have set the default of -prefer-subject to nil per the discussion
with Alan and Michael Strey.

It should apply against master.

–Rasmus

-- 
Dung makes an excellent fertilizer

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Documentation-fixes-for-ox-koma-script.el.patch --]
[-- Type: text/x-diff, Size: 1410 bytes --]

From 10d5518e9f48f18898de138b98b3be97b446dbe3 Mon Sep 17 00:00:00 2001
From: Rasmus <w530@pank.eu>
Date: Sat, 25 Jan 2014 14:08:15 +0100
Subject: [PATCH 1/2] Documentation fixes for ox-koma-script.el

* ox-koma-letter.el commentary (org-koma-letter-use-backaddress):
  Better documentation.
---
 contrib/lisp/ox-koma-letter.el | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el
index 7f2cd22..b1f37b8 100644
--- a/contrib/lisp/ox-koma-letter.el
+++ b/contrib/lisp/ox-koma-letter.el
@@ -105,11 +105,16 @@
 ;;   \[EXTRA]"))
 ;;
 ;; Then, in your Org document, be sure to require the proper class
-;; with :
+;; with:
 ;;
 ;;    #+LATEX_CLASS: my-letter
 ;;
 ;; Or by setting `org-koma-letter-default-class'.
+;;
+;; You may have to load (LaTeX) Babel as well, e.g., by adding
+;; it to `org-latex-packages-alist',
+;;
+;;    (add-to-list 'org-latex-packages-alist '("AUTO" "babel" nil))
 
 ;;; Code:
 
@@ -252,7 +257,7 @@ This option can also be set with the OPTIONS keyword, e.g.:
   :group 'org-export-koma-letter)
 
 (defcustom org-koma-letter-use-backaddress nil
-  "Non-nil prints return address in small line above to address.
+  "Non-nil prints return address in line above to address.
 This option can also be set with the OPTIONS keyword, e.g.:
 \"backaddress:t\"."
   :group 'org-export-koma-letter
-- 
1.8.5.3


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-Allow-separate-subject-and-title-in-ox-koma-letter.patch --]
[-- Type: text/x-diff, Size: 4198 bytes --]

From 99cffa500dc86482bf217d725224cbbf19687711 Mon Sep 17 00:00:00 2001
From: Rasmus <w530@pank.eu>
Date: Sat, 25 Jan 2014 14:15:03 +0100
Subject: [PATCH 2/2] Allow separate subject and title in ox-koma-letter

* ox-koma-letter.el (org-koma-letter-use-title): New variable.
(org-koma-letter-prefer-subject): New variable.
(org-koma-letter-template): Allow separate subject and title.
---
 contrib/lisp/ox-koma-letter.el | 37 ++++++++++++++++++++++++++++++++-----
 1 file changed, 32 insertions(+), 5 deletions(-)

diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el
index b1f37b8..d5ee1de 100644
--- a/contrib/lisp/ox-koma-letter.el
+++ b/contrib/lisp/ox-koma-letter.el
@@ -335,6 +335,14 @@ This option can also be set with the OPTIONS keyword, e.g.:
   :group 'org-export-koma-letter
   :type 'boolean)
 
+(defcustom org-koma-letter-use-title t
+  "Non-nil means use a title in the letter if present.
+
+See also `org-koma-letter-prefer-subject' for the handling of
+title versus subject."
+  :group 'org-export-koma-letter
+  :type 'boolean)
+
 (defcustom org-koma-letter-default-class "default-koma-letter"
   "Default class for `org-koma-letter'.
 The value must be a member of `org-latex-classes'."
@@ -348,6 +356,14 @@ A headline is only used if #+OPENING is not set.  See also
   :group 'org-export-koma-letter
   :type 'boolean)
 
+(defcustom org-koma-letter-prefer-subject nil
+  "Non-nil means title should be interpret as subject if subject is missing.
+
+This may be useful for older documents where the SUBJECT keyword
+was not present."
+    :group 'org-export-koma-letter
+    :type 'boolean)
+
 (defconst org-koma-letter-special-tags-in-letter '(to from)
   "Header tags related to the letter itself.")
 
@@ -377,6 +393,7 @@ A headline is only used if #+OPENING is not set.  See also
     (:opening "OPENING" nil org-koma-letter-opening)
     (:closing "CLOSING" nil org-koma-letter-closing)
     (:signature "SIGNATURE" nil org-koma-letter-signature newline)
+    (:subject "SUBJECT" nil nil space)
     (:special-headings nil "special-headings"
 		       org-koma-letter-prefer-special-headings)
     (:special-tags nil nil (append
@@ -393,6 +410,8 @@ A headline is only used if #+OPENING is not set.  See also
     (:with-phone nil "phone" org-koma-letter-use-phone)
     (:with-place nil "place" org-koma-letter-use-place)
     (:with-subject nil "subject" org-koma-letter-subject-format)
+    (:with-title nil "title" org-koma-letter-use-title)
+    (:with-title-as-subject nil "title-subject" org-koma-letter-prefer-subject)
     ;; Special properties non-nil when a setting happened in buffer.
     ;; They are used to prioritize in-buffer settings over "lco"
     ;; files.  See `org-koma-letter-template'.
@@ -598,17 +617,25 @@ holding export options."
    (format "\\date{%s}\n" (org-export-data (org-export-get-date info) info))
    ;; Document start
    "\\begin{document}\n\n"
-   ;; Subject
-   (let ((with-subject (plist-get info :with-subject)))
+   ;; Subject and title
+   (let ((with-subject (plist-get info :with-subject))
+	 (title-as-subject (plist-get info :with-title-as-subject))
+	 (subject (org-string-nw-p (org-export-data (plist-get info :subject) info)))
+	 (title (org-string-nw-p (org-export-data (plist-get info :title) info))))
      (when with-subject
        (concat
 	(unless (eq with-subject t)
 	  (format "\\KOMAoption{subject}{%s}\n"
 		  (if (symbolp with-subject) with-subject
 		    (mapconcat #'symbol-name with-subject ","))))
-	(let ((subject (org-export-data (plist-get info :title) info)))
-	  (and (org-string-nw-p subject)
-	       (format "\\setkomavar{subject}{%s}\n\n" subject))))))
+	(let ((subject (if title-as-subject (or subject title) subject))
+	      (title (if title-as-subject (and subject title) title)))
+	  (concat
+	   (and (org-string-nw-p subject)
+		(format "\\setkomavar{subject}{%s}\n" subject))
+	   (and (org-string-nw-p title)
+		(format "\\setkomavar{title}{%s}\n" title))
+	   (when (or (org-string-nw-p title) (org-string-nw-p subject)) "\n"))))))
    ;; Letter start.
    (format "\\begin{letter}{%%\n%s}\n\n"
 	   (org-koma-letter--determine-to-and-from info 'to))
-- 
1.8.5.3


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH][ox-koma-letter] changed-in-buffer, subject, minor fixes
  2014-01-25 13:44           ` Rasmus
@ 2014-01-25 22:18             ` Nicolas Goaziou
  2014-02-04 13:23               ` Alan Schmitt
  0 siblings, 1 reply; 19+ messages in thread
From: Nicolas Goaziou @ 2014-01-25 22:18 UTC (permalink / raw)
  To: Rasmus; +Cc: alan.schmitt, emacs-orgmode

Hello,

Rasmus <rasmus@gmx.us> writes:

> Would you give the attached patches a spin?  I think they work nicely;
> only the second patch is non-trivial.  Basically, one can ignore
> subject and title differences as now by setting
> org-koma-letter-prefer-subject to t and not use the SUBJECT keyword.
>
> I have set the default of -prefer-subject to nil per the discussion
> with Alan and Michael Strey.
>
> It should apply against master.

It looks good. Thank you.

A few minor remarks below.

> +(defcustom org-koma-letter-use-title t
> +  "Non-nil means use a title in the letter if present.
> +
> +See also `org-koma-letter-prefer-subject' for the handling of
> +title versus subject."
> +  :group 'org-export-koma-letter
> +  :type 'boolean)

You should also talk about the OPTIONS item, i.e., "title:nil", as in
other defcustoms.

> +(defcustom org-koma-letter-prefer-subject nil
> +  "Non-nil means title should be interpret as subject if subject is missing.
> +
> +This may be useful for older documents where the SUBJECT keyword
> +was not present."
> +    :group 'org-export-koma-letter
> +    :type 'boolean)

Ditto.

> -   ;; Subject
> -   (let ((with-subject (plist-get info :with-subject)))
> +   ;; Subject and title
> +   (let ((with-subject (plist-get info :with-subject))
> +	 (title-as-subject (plist-get info :with-title-as-subject))
> +	 (subject (org-string-nw-p (org-export-data (plist-get info :subject) info)))
> +	 (title (org-string-nw-p (org-export-data (plist-get info :title) info))))

`title-as-subject', `subject' and `title' belong to the `let' below, not
this one.

>       (when with-subject
>         (concat
>  	(unless (eq with-subject t)
>  	  (format "\\KOMAoption{subject}{%s}\n"
>  		  (if (symbolp with-subject) with-subject
>  		    (mapconcat #'symbol-name with-subject ","))))
> -	(let ((subject (org-export-data (plist-get info :title) info)))
> -	  (and (org-string-nw-p subject)
> -	       (format "\\setkomavar{subject}{%s}\n\n" subject))))))
> +	(let ((subject (if title-as-subject (or subject title) subject))
> +	      (title (if title-as-subject (and subject title) title)))
> +	  (concat
> +	   (and (org-string-nw-p subject)
> +		(format "\\setkomavar{subject}{%s}\n" subject))
> +	   (and (org-string-nw-p title)
> +		(format "\\setkomavar{title}{%s}\n" title))
> +	   (when (or (org-string-nw-p title) (org-string-nw-p subject)) "\n"))))))


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH][ox-koma-letter] changed-in-buffer, subject, minor fixes
  2014-01-25 22:18             ` Nicolas Goaziou
@ 2014-02-04 13:23               ` Alan Schmitt
  2014-02-04 17:21                 ` Rasmus Pank Roulund
                                   ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: Alan Schmitt @ 2014-02-04 13:23 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode, Rasmus

Hello,

Sorry for not replying earlier, I've been swamped by traveling and work.

Nicolas Goaziou <n.goaziou@gmail.com> writes:

> Hello,
>
> Rasmus <rasmus@gmx.us> writes:
>
>> Would you give the attached patches a spin?  I think they work nicely;
>> only the second patch is non-trivial.  Basically, one can ignore
>> subject and title differences as now by setting
>> org-koma-letter-prefer-subject to t and not use the SUBJECT keyword.
>>
>> I have set the default of -prefer-subject to nil per the discussion
>> with Alan and Michael Strey.
>>
>> It should apply against master.
>
> It looks good. Thank you.
>
> A few minor remarks below.
>
>> +(defcustom org-koma-letter-use-title t
>> +  "Non-nil means use a title in the letter if present.
>> +
>> +See also `org-koma-letter-prefer-subject' for the handling of
>> +title versus subject."
>> +  :group 'org-export-koma-letter
>> +  :type 'boolean)
>
> You should also talk about the OPTIONS item, i.e., "title:nil", as in
> other defcustoms.
>
>> +(defcustom org-koma-letter-prefer-subject nil
>> +  "Non-nil means title should be interpret as subject if subject is missing.
>> +
>> +This may be useful for older documents where the SUBJECT keyword
>> +was not present."
>> +    :group 'org-export-koma-letter
>> +    :type 'boolean)
>
> Ditto.
>
>> -   ;; Subject
>> -   (let ((with-subject (plist-get info :with-subject)))
>> +   ;; Subject and title
>> +   (let ((with-subject (plist-get info :with-subject))
>> +	 (title-as-subject (plist-get info :with-title-as-subject))
>> +	 (subject (org-string-nw-p (org-export-data (plist-get info :subject) info)))
>> +	 (title (org-string-nw-p (org-export-data (plist-get info :title) info))))
>
> `title-as-subject', `subject' and `title' belong to the `let' below, not
> this one.
>
>>       (when with-subject
>>         (concat
>>  	(unless (eq with-subject t)
>>  	  (format "\\KOMAoption{subject}{%s}\n"
>>  		  (if (symbolp with-subject) with-subject
>>  		    (mapconcat #'symbol-name with-subject ","))))
>> -	(let ((subject (org-export-data (plist-get info :title) info)))
>> -	  (and (org-string-nw-p subject)
>> -	       (format "\\setkomavar{subject}{%s}\n\n" subject))))))
>> +	(let ((subject (if title-as-subject (or subject title) subject))
>> +	      (title (if title-as-subject (and subject title) title)))
>> +	  (concat
>> +	   (and (org-string-nw-p subject)
>> +		(format "\\setkomavar{subject}{%s}\n" subject))
>> +	   (and (org-string-nw-p title)
>> +		(format "\\setkomavar{title}{%s}\n" title))
>> +	   (when (or (org-string-nw-p title) (org-string-nw-p subject)) "\n"))))))

Rasmus: do you want to change these, or should I do it and apply the
patch? (The former would be simpler, I have to say.)

Thanks,

Alan

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH][ox-koma-letter] changed-in-buffer, subject, minor fixes
  2014-02-04 13:23               ` Alan Schmitt
@ 2014-02-04 17:21                 ` Rasmus Pank Roulund
  2014-02-05  1:12                 ` Rasmus
  2014-02-05  2:02                 ` Rasmus
  2 siblings, 0 replies; 19+ messages in thread
From: Rasmus Pank Roulund @ 2014-02-04 17:21 UTC (permalink / raw)
  To: alan.schmitt; +Cc: emacs-orgmode, n.goaziou

>>> Would you give the attached patches a spin?  I think they work nicely;
>>> only the second patch is non-trivial.  Basically, one can ignore
>>> subject and title differences as now by setting
>>> org-koma-letter-prefer-subject to t and not use the SUBJECT keyword.
>>>
>>> I have set the default of -prefer-subject to nil per the discussion
>>> with Alan and Michael Strey.
>>>
>>> It should apply against master.
>>
>> It looks good. Thank you.
>>
>> A few minor remarks below.
>>
>>> +(defcustom org-koma-letter-use-title t
>>> +  "Non-nil means use a title in the letter if present.
>>> +
>>> +See also `org-koma-letter-prefer-subject' for the handling of
>>> +title versus subject."
>>> +  :group 'org-export-koma-letter
>>> +  :type 'boolean)
>>
>> You should also talk about the OPTIONS item, i.e., "title:nil", as in
>> other defcustoms.
>>
>>> +(defcustom org-koma-letter-prefer-subject nil
>>> +  "Non-nil means title should be interpret as subject if subject is missing.
>>> +
>>> +This may be useful for older documents where the SUBJECT keyword
>>> +was not present."
>>> +    :group 'org-export-koma-letter
>>> +    :type 'boolean)
>>
>> Ditto.
>>
>>> -   ;; Subject
>>> -   (let ((with-subject (plist-get info :with-subject)))
>>> +   ;; Subject and title
>>> +   (let ((with-subject (plist-get info :with-subject))
>>> +	 (title-as-subject (plist-get info :with-title-as-subject))
>>> +	 (subject (org-string-nw-p (org-export-data (plist-get info :subject) info)))
>>> +	 (title (org-string-nw-p (org-export-data (plist-get info :title) info))))
>>
>> `title-as-subject', `subject' and `title' belong to the `let' below, not
>> this one.
>>
>>>       (when with-subject
>>>         (concat
>>>  	(unless (eq with-subject t)
>>>  	  (format "\\KOMAoption{subject}{%s}\n"
>>>  		  (if (symbolp with-subject) with-subject
>>>  		    (mapconcat #'symbol-name with-subject ","))))
>>> -	(let ((subject (org-export-data (plist-get info :title) info)))
>>> -	  (and (org-string-nw-p subject)
>>> -	       (format "\\setkomavar{subject}{%s}\n\n" subject))))))
>>> +	(let ((subject (if title-as-subject (or subject title) subject))
>>> +	      (title (if title-as-subject (and subject title) title)))
>>> +	  (concat
>>> +	   (and (org-string-nw-p subject)
>>> +		(format "\\setkomavar{subject}{%s}\n" subject))
>>> +	   (and (org-string-nw-p title)
>>> +		(format "\\setkomavar{title}{%s}\n" title))
>>> +	   (when (or (org-string-nw-p title) (org-string-nw-p subject)) "\n"))))))
>
> Rasmus: do you want to change these, or should I do it and apply the
> patch? (The former would be simpler, I have to say.)

Yes, but I didn't manged to do it in the weekend.  I'll try to find
time during the week.  My apology. 

–Rasmus

-- 
When the facts change, I change my mind. What do you do, sir?

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH][ox-koma-letter] changed-in-buffer, subject, minor fixes
  2014-02-04 13:23               ` Alan Schmitt
  2014-02-04 17:21                 ` Rasmus Pank Roulund
@ 2014-02-05  1:12                 ` Rasmus
  2014-02-05 12:40                   ` Alan Schmitt
  2014-02-05 12:48                   ` Alan Schmitt
  2014-02-05  2:02                 ` Rasmus
  2 siblings, 2 replies; 19+ messages in thread
From: Rasmus @ 2014-02-05  1:12 UTC (permalink / raw)
  To: alan.schmitt; +Cc: emacs-orgmode, n.goaziou

[-- Attachment #1: Type: text/plain, Size: 310 bytes --]

Alan Schmitt <alan.schmitt@polytechnique.org> writes:

> Rasmus: do you want to change these, or should I do it and apply the
> patch? (The former would be simpler, I have to say.)

Attached.  Sorry about the delay.  They should fix Nicholas'
'concerns'.

–Rasmus

-- 
Vote for proprietary math!

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Documentation-fixes-for-ox-koma-script.el.patch --]
[-- Type: text/x-diff, Size: 3215 bytes --]

From 8f3e69f5ca3d0153b6f4c80b74c7aa6f422c86e5 Mon Sep 17 00:00:00 2001
From: Rasmus <w530@pank.eu>
Date: Sat, 25 Jan 2014 14:08:15 +0100
Subject: [PATCH 1/2] Documentation fixes for ox-koma-script.el

* ox-koma-letter.el commentary (org-koma-letter-use-backaddress):
  Better documentation.
---
 contrib/lisp/ox-koma-letter.el | 30 ++++++++++++++++++------------
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el
index 7f2cd22..0d15956 100644
--- a/contrib/lisp/ox-koma-letter.el
+++ b/contrib/lisp/ox-koma-letter.el
@@ -34,14 +34,14 @@
 ;; On top of buffer keywords supported by `latex' back-end (see
 ;; `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 `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')
-;;   - "PLACE" (see `org-koma-letter-place')
-;;   - and "TO_ADDRESS".  If unspecified this is set to "\mbox{}".
+;;   - CLOSING: see `org-koma-letter-closing',
+;;   - FROM_ADDRESS: see `org-koma-letter-from-address',
+;;   - LCO: see `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',
+;;   - PLACE: see `org-koma-letter-place',
+;;   - TO_ADDRESS:  If unspecified this is set to "\mbox{}".
 ;;
 ;; TO_ADDRESS and FROM_ADDRESS can also be specified using heading
 ;; with the special tags specified in
@@ -67,8 +67,9 @@
 ;;     (see `org-koma-letter-special-tags-after-letter').
 ;;
 ;; The following variables works differently from the main LaTeX class
-;;   - "AUTHOR": default to user-full-name but may be disabled.  (see org-koma-letter-author),
-;;   - "EMAIL": same as AUTHOR, (see org-koma-letter-email),
+;;   - AUTHOR: Default to user-full-name but may be disabled.
+;;     (See also `org-koma-letter-author'),
+;;   - EMAIL: Same as AUTHOR. (see also `org-koma-letter-email'),
 ;;
 ;; Headlines are in general ignored.  However, headlines with special
 ;; tags can be used for specified contents like postscript (ps),
@@ -105,11 +106,16 @@
 ;;   \[EXTRA]"))
 ;;
 ;; Then, in your Org document, be sure to require the proper class
-;; with :
+;; with:
 ;;
 ;;    #+LATEX_CLASS: my-letter
 ;;
 ;; Or by setting `org-koma-letter-default-class'.
+;;
+;; You may have to load (LaTeX) Babel as well, e.g., by adding
+;; it to `org-latex-packages-alist',
+;;
+;;    (add-to-list 'org-latex-packages-alist '("AUTO" "babel" nil))
 
 ;;; Code:
 
@@ -252,7 +258,7 @@ This option can also be set with the OPTIONS keyword, e.g.:
   :group 'org-export-koma-letter)
 
 (defcustom org-koma-letter-use-backaddress nil
-  "Non-nil prints return address in small line above to address.
+  "Non-nil prints return address in line above to address.
 This option can also be set with the OPTIONS keyword, e.g.:
 \"backaddress:t\"."
   :group 'org-export-koma-letter
-- 
1.8.5.3


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-Allow-separate-subject-and-title-in-ox-koma-letter.patch --]
[-- Type: text/x-diff, Size: 4789 bytes --]

From a55d3611d5ae6b04c64513490d68a9959672c86f Mon Sep 17 00:00:00 2001
From: Rasmus <w530@pank.eu>
Date: Sat, 25 Jan 2014 14:15:03 +0100
Subject: [PATCH 2/2] Allow separate subject and title in ox-koma-letter

* ox-koma-letter.el (org-koma-letter-use-title): New variable.
(org-koma-letter-prefer-subject): New variable.
(org-koma-letter-template): Allow separate subject and title.
---
 contrib/lisp/ox-koma-letter.el | 41 +++++++++++++++++++++++++++++++++++++----
 1 file changed, 37 insertions(+), 4 deletions(-)

diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el
index 0d15956..8a3054b 100644
--- a/contrib/lisp/ox-koma-letter.el
+++ b/contrib/lisp/ox-koma-letter.el
@@ -70,6 +70,8 @@
 ;;   - AUTHOR: Default to user-full-name but may be disabled.
 ;;     (See also `org-koma-letter-author'),
 ;;   - EMAIL: Same as AUTHOR. (see also `org-koma-letter-email'),
+;;   - TITLE: May be the letter title or subject depending on
+;;     `org-koma-letter-prefer-subject'.
 ;;
 ;; Headlines are in general ignored.  However, headlines with special
 ;; tags can be used for specified contents like postscript (ps),
@@ -336,6 +338,16 @@ This option can also be set with the OPTIONS keyword, e.g.:
   :group 'org-export-koma-letter
   :type 'boolean)
 
+(defcustom org-koma-letter-use-title t
+  "Non-nil means use a title in the letter if present.
+This option can also be set with the OPTIONS keyword,
+e.g. \"with-title:nil\".
+
+See also `org-koma-letter-prefer-subject' for the handling of
+title versus subject."
+  :group 'org-export-koma-letter
+  :type 'boolean)
+
 (defcustom org-koma-letter-default-class "default-koma-letter"
   "Default class for `org-koma-letter'.
 The value must be a member of `org-latex-classes'."
@@ -349,6 +361,16 @@ A headline is only used if #+OPENING is not set.  See also
   :group 'org-export-koma-letter
   :type 'boolean)
 
+(defcustom org-koma-letter-prefer-subject nil
+  "Non-nil means title should be interpret as subject if subject is missing.
+This option can also be set with the OPTIONS keyword,
+e.g. \"title-subject:t\".
+
+This may be useful for older documents where the SUBJECT keyword
+was not present."
+    :group 'org-export-koma-letter
+    :type 'boolean)
+
 (defconst org-koma-letter-special-tags-in-letter '(to from)
   "Header tags related to the letter itself.")
 
@@ -378,6 +400,7 @@ A headline is only used if #+OPENING is not set.  See also
     (:opening "OPENING" nil org-koma-letter-opening)
     (:closing "CLOSING" nil org-koma-letter-closing)
     (:signature "SIGNATURE" nil org-koma-letter-signature newline)
+    (:subject "SUBJECT" nil nil space)
     (:special-headings nil "special-headings"
 		       org-koma-letter-prefer-special-headings)
     (:special-tags nil nil (append
@@ -394,6 +417,8 @@ A headline is only used if #+OPENING is not set.  See also
     (:with-phone nil "phone" org-koma-letter-use-phone)
     (:with-place nil "place" org-koma-letter-use-place)
     (:with-subject nil "subject" org-koma-letter-subject-format)
+    (:with-title nil "title" org-koma-letter-use-title)
+    (:with-title-as-subject nil "title-subject" org-koma-letter-prefer-subject)
     ;; Special properties non-nil when a setting happened in buffer.
     ;; They are used to prioritize in-buffer settings over "lco"
     ;; files.  See `org-koma-letter-template'.
@@ -599,7 +624,7 @@ holding export options."
    (format "\\date{%s}\n" (org-export-data (org-export-get-date info) info))
    ;; Document start
    "\\begin{document}\n\n"
-   ;; Subject
+   ;; Subject and title
    (let ((with-subject (plist-get info :with-subject)))
      (when with-subject
        (concat
@@ -607,9 +632,17 @@ holding export options."
 	  (format "\\KOMAoption{subject}{%s}\n"
 		  (if (symbolp with-subject) with-subject
 		    (mapconcat #'symbol-name with-subject ","))))
-	(let ((subject (org-export-data (plist-get info :title) info)))
-	  (and (org-string-nw-p subject)
-	       (format "\\setkomavar{subject}{%s}\n\n" subject))))))
+	(let* ((title-as-subject (plist-get info :with-title-as-subject))
+	       (subject* (org-string-nw-p (org-export-data (plist-get info :subject) info)))
+	       (title* (org-string-nw-p (org-export-data (plist-get info :title) info)))
+	       (subject (if title-as-subject (or subject* title*) subject*))
+	       (title (if title-as-subject (and subject* title*) title*)))
+	  (concat
+	   (and (org-string-nw-p subject)
+		(format "\\setkomavar{subject}{%s}\n" subject))
+	   (and (org-string-nw-p title)
+		(format "\\setkomavar{title}{%s}\n" title))
+	   (when (or (org-string-nw-p title) (org-string-nw-p subject)) "\n"))))))
    ;; Letter start.
    (format "\\begin{letter}{%%\n%s}\n\n"
 	   (org-koma-letter--determine-to-and-from info 'to))
-- 
1.8.5.3


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH][ox-koma-letter] changed-in-buffer, subject, minor fixes
  2014-02-04 13:23               ` Alan Schmitt
  2014-02-04 17:21                 ` Rasmus Pank Roulund
  2014-02-05  1:12                 ` Rasmus
@ 2014-02-05  2:02                 ` Rasmus
  2014-02-05  7:46                   ` Nicolas Goaziou
                                     ` (2 more replies)
  2 siblings, 3 replies; 19+ messages in thread
From: Rasmus @ 2014-02-05  2:02 UTC (permalink / raw)
  To: alan.schmitt; +Cc: emacs-orgmode, n.goaziou


Quick but unrelated question.  I'm updating the Worg page and I
noticed that the customize-group for ox-koma-letter is
org-export-koma-letter.  Given that other groups are org-latex and
org-html etc., should the group not be called org-koma-letter?

–Rasmus

PS: Sorry for not starting a new thread.

-- 
Dung makes an excellent fertilizer

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH][ox-koma-letter] changed-in-buffer, subject, minor fixes
  2014-02-05  2:02                 ` Rasmus
@ 2014-02-05  7:46                   ` Nicolas Goaziou
  2014-02-05  9:55                     ` Rasmus
  2014-02-05  7:48                   ` Bastien
  2014-02-05  7:59                   ` Alan Schmitt
  2 siblings, 1 reply; 19+ messages in thread
From: Nicolas Goaziou @ 2014-02-05  7:46 UTC (permalink / raw)
  To: Rasmus; +Cc: alan.schmitt, emacs-orgmode

Hello,

Rasmus <rasmus@gmx.us> writes:

> Given that other groups are org-latex and
> org-html etc., should the group not be called org-koma-letter?

No. Other groups are `org-export-latex', `org-export-html'...


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH][ox-koma-letter] changed-in-buffer, subject, minor fixes
  2014-02-05  2:02                 ` Rasmus
  2014-02-05  7:46                   ` Nicolas Goaziou
@ 2014-02-05  7:48                   ` Bastien
  2014-02-05  7:59                   ` Alan Schmitt
  2 siblings, 0 replies; 19+ messages in thread
From: Bastien @ 2014-02-05  7:48 UTC (permalink / raw)
  To: Rasmus; +Cc: n.goaziou, alan.schmitt, emacs-orgmode

Hi Rasmus,

Rasmus <rasmus@gmx.us> writes:

> Quick but unrelated question.  I'm updating the Worg page and I
> noticed that the customize-group for ox-koma-letter is
> org-export-koma-letter.  Given that other groups are org-latex and
> org-html etc., should the group not be called org-koma-letter?

Unless I miss something, other groups are

org-export-html
org-export-latex

etc.

so org-export-koma-letter seems right.

-- 
 Bastien

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH][ox-koma-letter] changed-in-buffer, subject, minor fixes
  2014-02-05  2:02                 ` Rasmus
  2014-02-05  7:46                   ` Nicolas Goaziou
  2014-02-05  7:48                   ` Bastien
@ 2014-02-05  7:59                   ` Alan Schmitt
  2 siblings, 0 replies; 19+ messages in thread
From: Alan Schmitt @ 2014-02-05  7:59 UTC (permalink / raw)
  To: Rasmus; +Cc: emacs-orgmode, n.goaziou

Rasmus <rasmus@gmx.us> writes:

> Quick but unrelated question.  I'm updating the Worg page and I
> noticed that the customize-group for ox-koma-letter is
> org-export-koma-letter.  Given that other groups are org-latex and
> org-html etc., should the group not be called org-koma-letter?

Yes, org-koma-letter sounds better.

Alan

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH][ox-koma-letter] changed-in-buffer, subject, minor fixes
  2014-02-05  7:46                   ` Nicolas Goaziou
@ 2014-02-05  9:55                     ` Rasmus
  0 siblings, 0 replies; 19+ messages in thread
From: Rasmus @ 2014-02-05  9:55 UTC (permalink / raw)
  To: n.goaziou; +Cc: alan.schmitt, emacs-orgmode

Nicolas Goaziou <n.goaziou@gmail.com> writes:

> No. Other groups are `org-export-latex', `org-export-html'...

Bastien <bzg@gnu.org> writes:

> Unless I miss something, other groups are
>
> org-export-html
> org-export-latex
>
> etc.
>
> so org-export-koma-letter seems right.

Right.  That's a late night blunder on my part!

Thanks for pointing me in the right direction.


-- 
Er du tosset for noge' lårt!

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH][ox-koma-letter] changed-in-buffer, subject, minor fixes
  2014-02-05  1:12                 ` Rasmus
@ 2014-02-05 12:40                   ` Alan Schmitt
  2014-02-05 12:42                     ` Alan Schmitt
  2014-02-05 12:48                   ` Alan Schmitt
  1 sibling, 1 reply; 19+ messages in thread
From: Alan Schmitt @ 2014-02-05 12:40 UTC (permalink / raw)
  To: Rasmus; +Cc: emacs-orgmode, n.goaziou

Hello Rasmus,

I applied the first patch, with the following small changes.

This part would not apply:

--8<---------------cut here---------------start------------->8---
@@ -252,7 +258,7 @@ This option can also be set with the OPTIONS keyword, e.g.:
   :group 'org-export-koma-letter)
 
 (defcustom org-koma-letter-use-backaddress nil
-  "Non-nil prints return address in small line above to address.
+  "Non-nil prints return address in line above to address.
 This option can also be set with the OPTIONS keyword, e.g.:
 \"backaddress:t\"."
   :group 'org-export-koma-letter
--8<---------------cut here---------------end--------------->8---

(because the string starts with "Print" now.) I just removed the "small"
from the sentence, and some spurious white lines. Here is what I got:

--8<---------------cut here---------------start------------->8---
@@ -230,10 +236,8 @@ English manual of 2012-07-22)."
 	  (string))
   :group 'org-export-koma-letter)
 
-
-
 (defcustom org-koma-letter-use-backaddress nil
-  "Print return address in small line above to address."
+  "Print return address in line above to address."
   :group 'org-export-koma-letter
   :type 'boolean)
--8<---------------cut here---------------end--------------->8---

(The line numbers are quite different ... there may be some edits on
your side that have not made it to the patch.)

I could not apply the second patch because the line numbers are too
different. For instance, this chunk is supposed to start on line 266,
not 336 here.

--8<---------------cut here---------------start------------->8---
@@ -336,6 +338,16 @@ This option can also be set with the OPTIONS keyword, e.g.:
   :group 'org-export-koma-letter
   :type 'boolean)
 
+(defcustom org-koma-letter-use-title t
+  "Non-nil means use a title in the letter if present.
+This option can also be set with the OPTIONS keyword,
+e.g. \"with-title:nil\".
+
+See also `org-koma-letter-prefer-subject' for the handling of
+title versus subject."
+  :group 'org-export-koma-letter
+  :type 'boolean)
+
 (defcustom org-koma-letter-default-class "default-koma-letter"
   "Default class for `org-koma-letter'.
 The value must be a member of `org-latex-classes'."
--8<---------------cut here---------------end--------------->8---

Also, what is the text after the "@@" in the first line?

I can manually apply the patch (it's not that big), or you can
regenerate it. Please let me know what you prefer.

Best,

Alan

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH][ox-koma-letter] changed-in-buffer, subject, minor fixes
  2014-02-05 12:40                   ` Alan Schmitt
@ 2014-02-05 12:42                     ` Alan Schmitt
  0 siblings, 0 replies; 19+ messages in thread
From: Alan Schmitt @ 2014-02-05 12:42 UTC (permalink / raw)
  To: Rasmus; +Cc: emacs-orgmode, n.goaziou

Alan Schmitt <alan.schmitt@polytechnique.org> writes:

> Hello Rasmus,
>
> I applied the first patch, with the following small changes.

Please ignore this email, there was something wrong in my setup (I was
in the maint branch ...). Sorry for the noise.

Alan

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH][ox-koma-letter] changed-in-buffer, subject, minor fixes
  2014-02-05  1:12                 ` Rasmus
  2014-02-05 12:40                   ` Alan Schmitt
@ 2014-02-05 12:48                   ` Alan Schmitt
  1 sibling, 0 replies; 19+ messages in thread
From: Alan Schmitt @ 2014-02-05 12:48 UTC (permalink / raw)
  To: Rasmus; +Cc: emacs-orgmode, n.goaziou

Rasmus <rasmus@gmx.us> writes:

> Alan Schmitt <alan.schmitt@polytechnique.org> writes:
>
>> Rasmus: do you want to change these, or should I do it and apply the
>> patch? (The former would be simpler, I have to say.)
>
> Attached.  Sorry about the delay.  They should fix Nicholas'
> 'concerns'.

Applied and pushed, thanks.

Alan

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2014-02-05 12:49 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-25  0:15 [PATCH][ox-koma-letter] changed-in-buffer, subject, minor fixes Rasmus
2013-11-25  9:20 ` Michael Strey
     [not found] ` <m2zjop3cgt.fsf@polytechnique.org>
2014-01-18 16:11   ` Rasmus
2014-01-18 16:18     ` Nicolas Goaziou
2014-01-18 19:27       ` Rasmus
2014-01-18 20:05         ` Nicolas Goaziou
2014-01-25 13:44           ` Rasmus
2014-01-25 22:18             ` Nicolas Goaziou
2014-02-04 13:23               ` Alan Schmitt
2014-02-04 17:21                 ` Rasmus Pank Roulund
2014-02-05  1:12                 ` Rasmus
2014-02-05 12:40                   ` Alan Schmitt
2014-02-05 12:42                     ` Alan Schmitt
2014-02-05 12:48                   ` Alan Schmitt
2014-02-05  2:02                 ` Rasmus
2014-02-05  7:46                   ` Nicolas Goaziou
2014-02-05  9:55                     ` Rasmus
2014-02-05  7:48                   ` Bastien
2014-02-05  7:59                   ` Alan Schmitt

Code repositories for project(s) associated with this 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).