* [patch] ox-koma-letter.el: credit [1/4] @ 2013-05-20 0:28 Rasmus 2013-05-20 0:40 ` [patch] ox-koma-letter.el: subject changes [2/4] Rasmus ` (4 more replies) 0 siblings, 5 replies; 48+ messages in thread From: Rasmus @ 2013-05-20 0:28 UTC (permalink / raw) To: emacs-orgmode; +Cc: alan.schmitt, n.goaziou With this and the following patches I have tried to add some functionality to the ox-koma-letter.el-file. I'll try to summarize in each email. This one just updates the credit: most importantly with Viktor. As neither git, changelongs nor lisp are incorporated as a natural element of my native tongue I'd very much appreciate any criticisms and test reports. My lisp skills are very basic. I haven't signed any FSF papers, but I'm happy to do so if the patches are of interest. Probably it isn't really that important with the file only living in contrib. –Rasmus Two bonus question: - In this patch I tried to get git remove the second part where it adds and removes the "lco" part. But with two rebase goes I did not succeed. Is it safe to hand edit git-produced patches? - Is it me or is there no option to have git send-email just fix a the subject and heads and let the email program do the rest?! The manual and various blog post did not reveal how on earth to get it to just use Gnus for sending. . . The program seems not really to follow the Unix principle. . . -- Dung makes an excellent fertilizer ^ permalink raw reply [flat|nested] 48+ messages in thread
* [patch] ox-koma-letter.el: subject changes [2/4] 2013-05-20 0:28 [patch] ox-koma-letter.el: credit [1/4] Rasmus @ 2013-05-20 0:40 ` Rasmus 2013-05-20 15:49 ` Alan Schmitt 2013-05-20 0:51 ` [patch] ox-koma-letter.el: credit [3/4] Rasmus ` (3 subsequent siblings) 4 siblings, 1 reply; 48+ messages in thread From: Rasmus @ 2013-05-20 0:40 UTC (permalink / raw) To: emacs-orgmode; +Cc: alan.schmitt, n.goaziou [-- Attachment #1: Type: text/plain, Size: 823 bytes --] This could be a problematic change. It changes the way :with-subject works. I've added changes to allow the subject style to be choose as a radio list with customize. The reason is that LaTeX becomes unhappy if it is not a supported value. If #+OPTIONS subject:t the default is used. If #+OPTIONS subject:my-crazy-string it tries that and most likely hell will break loose. Viktor, you're usage of ox-koma-letter.el is quite different from mine in that you rely (heavily?) on LCO files. If you could test this and see what you think of it it would be great. On my system it doesn't break anything vital but I might have missed something. I have probably overlooked some important case in which case I can try to fix the patch or drop it. –Rasmus -- El Rey ha muerto. ¡Larga vida al Rey! [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0002-ox-koma-letter-changed-handling-of-subject.patch --] [-- Type: text/x-patch, Size: 4166 bytes --] From 3847d0074c23d782abb1756a35b2cf44175f8684 Mon Sep 17 00:00:00 2001 From: "rasmus.pank" <rasmus.pank@gmail.com> Date: Sun, 19 May 2013 17:32:44 +0200 Subject: [PATCH 2/4] ox-koma-letter: changed handling of subject * ox-koma-letter.el: org-koma-letter-subject-format is now a radio list. If nil neither subject format nor type is exported. * ox-koma-letter.el: allow for t value of #+OPTIONS: subject:VALUE * ox-koma-letter.el: export of subject format is independent of title, but title is not independent of :with-subject. The issue is that I could select #+OPTIONS: subject:t and this would give a wrong value. Hopefully this bevaior is better. --- contrib/lisp/ox-koma-letter.el | 55 +++++++++++++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 12 deletions(-) diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el index 2389025..77d21c7 100644 --- a/contrib/lisp/ox-koma-letter.el +++ b/contrib/lisp/ox-koma-letter.el @@ -6,7 +6,6 @@ ;; Alan Schmitt <alan.schmitt AT polytechnique DOT org> ;; Viktor Rosenfeld <listuser36 AT gmail DOT com> ;; Rasmus Pank Roulund <emacs AT pank DOT eu> - ;; Keywords: org, wp, tex ;; This program is free software: you can redistribute it and/or modify @@ -123,10 +122,36 @@ :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-subject-format "left" + "Use the title as the letter's subject. At the time of writing +the following values are allowed: + + - fteropening: subject after opening + - beforeopening: subject before opening + - centered: subject centered + - left:subject left-justified + - right: subject right-justified + - titled: add title/description to subject + - underlined: set subject underlined (see note in text please) + - untitled: do not add title/description to subject. + - No-export: like untitled but the title is not inserted into + the exported document. + +Please refer to the KOMA-script manual (Table 4.16. in the +English manual of 2012-07-22)" + :type '(radio (const "fteropening") + (const "beforeopening") + (const "centered") + (const "left") + (const "right") + (const "titled") + (const "underlined") + (const "untitled") + (const :tag "No-export" nil) + (string)) + :group 'org-export-koma-letter) + + (defcustom org-koma-letter-use-backaddress t "Print return address in small line above to address." @@ -179,7 +204,7 @@ Use `foldmarks:true' to activate default fold marks or (: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)) + (:with-subject nil "subject" org-koma-letter-subject-format)) :translate-alist '((export-block . org-koma-letter-export-block) (export-snippet . org-koma-letter-export-snippet) (keyword . org-koma-letter-keyword) @@ -300,12 +325,18 @@ holding export options." ;; Document start "\\begin{document}\n\n" ;; 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))))) + (let* ((with-subject (plist-get info :with-subject)) + (subject-format (if (member with-subject '("True" t "true" "TRUE")) + ;; FIXME: could this be done more elegantly? + ;; I.e. force lower face of with-subject if string. + org-koma-letter-subject-format + with-subject)) + (subject (org-export-data (plist-get info :title) info))) + (concat + (when with-subject + (format "\\KOMAoption{subject}{%s}\n\n" subject-format)) + (when (and subject with-subject) + (format "\\setkomavar{subject}{%s}\n\n" subject)))) ;; Letter start (format "\\begin{letter}{%%\n%s}\n\n" (or (plist-get info :to-address) "no address given")) -- 1.8.2.3 ^ permalink raw reply related [flat|nested] 48+ messages in thread
* Re: [patch] ox-koma-letter.el: subject changes [2/4] 2013-05-20 0:40 ` [patch] ox-koma-letter.el: subject changes [2/4] Rasmus @ 2013-05-20 15:49 ` Alan Schmitt 2013-05-20 18:23 ` Rasmus 0 siblings, 1 reply; 48+ messages in thread From: Alan Schmitt @ 2013-05-20 15:49 UTC (permalink / raw) To: Rasmus; +Cc: n.goaziou, emacs-orgmode Hello Rasmus, Rasmus writes: > This could be a problematic change. It changes the way :with-subject > works. I've added changes to allow the subject style to be choose as > a radio list with customize. The reason is that LaTeX becomes unhappy > if it is not a supported value. If #+OPTIONS subject:t the default is > used. If #+OPTIONS subject:my-crazy-string it tries that and most > likely hell will break loose. > > Viktor, you're usage of ox-koma-letter.el is quite different from mine > in that you rely (heavily?) on LCO files. If you could test this and > see what you think of it it would be great. On my system it doesn't > break anything vital but I might have missed something. According to my very limited emacs-lisp knowledge, this looks fine. I would suggest a couple renamings: beavior -> behavior fteropening -> afteropening No-export -> noexport (so that it looks like the other ones). Best, Alan ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: [patch] ox-koma-letter.el: subject changes [2/4] 2013-05-20 15:49 ` Alan Schmitt @ 2013-05-20 18:23 ` Rasmus 2013-05-21 7:24 ` Alan Schmitt 0 siblings, 1 reply; 48+ messages in thread From: Rasmus @ 2013-05-20 18:23 UTC (permalink / raw) To: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 1502 bytes --] >> This could be a problematic change. It changes the way :with-subject >> works. I've added changes to allow the subject style to be choose as >> a radio list with customize. The reason is that LaTeX becomes unhappy >> if it is not a supported value. If #+OPTIONS subject:t the default is >> used. If #+OPTIONS subject:my-crazy-string it tries that and most >> likely hell will break loose. >> >> Viktor, you're usage of ox-koma-letter.el is quite different from mine >> in that you rely (heavily?) on LCO files. If you could test this and >> see what you think of it it would be great. On my system it doesn't >> break anything vital but I might have missed something. > > According to my very limited emacs-lisp knowledge, this looks fine. I found a "bug" in that the subject variable should be a list cf. the KOMA manual. This patch fixes this. It's pretty complex for something so simple, and I might be inclined to admit to the "put it in a LCO"-file approach might be better. From the commit message: If =#+OPTIONS:subject:nil= neither =\setkomavar{subject}{.}= nor =\KOMAoption{subject}{.}= are exported. If =#+OPTIONS:subject:t= =`org-koma-letter-subject-format'= is used for =\KOMAoption{subject}{.}=. If =#+OPTIONS:subject:(x y z)= then =\KOMAoption{subject}{x,y,z}=. > beavior -> behavior > fteropening -> afteropening > No-export -> noexport (so that it looks like the other ones). Thanks! I should run wcheck when coding . . . –Rasmus -- Powered by magic pixies! [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0002-ox-koma-letter-changed-handling-of-subject.patch --] [-- Type: text/x-patch, Size: 4627 bytes --] From d11e4fd682ac593da04c3e4c8edf5eb84c9d0c59 Mon Sep 17 00:00:00 2001 From: "rasmus.pank" <rasmus.pank@gmail.com> Date: Sun, 19 May 2013 17:32:44 +0200 Subject: [PATCH 2/4] ox-koma-letter: changed handling of subject * ox-koma-letter.el: =`org-koma-letter-subject-format'= is now a set list. If nil neither subject format nor type is exported. * ox-koma-letter.el: allow for t value of =#+OPTIONS: subject:VALUE= * ox-koma-letter.el: export of subject format is independent of title, but title is not independent of =:with-subject=. The issue was with =#+OPTIONS: subject:t= one would get a LaTeX. New behavior: If =#+OPTIONS:subject:nil= neither =\setkomavar{subject}{.}= nor =\KOMAoption{subject}{.}= are exported. If =#+OPTIONS:subject:t= =`org-koma-letter-subject-format'= is used for =\KOMAoption{subject}{.}=. If =#+OPTIONS:subject:(x y z)= then \KOMAoption{subject}{x,y,z}. --- contrib/lisp/ox-koma-letter.el | 65 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 53 insertions(+), 12 deletions(-) diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el index 2389025..6a3811f 100644 --- a/contrib/lisp/ox-koma-letter.el +++ b/contrib/lisp/ox-koma-letter.el @@ -6,7 +6,6 @@ ;; Alan Schmitt <alan.schmitt AT polytechnique DOT org> ;; Viktor Rosenfeld <listuser36 AT gmail DOT com> ;; Rasmus Pank Roulund <emacs AT pank DOT eu> - ;; Keywords: org, wp, tex ;; This program is free software: you can redistribute it and/or modify @@ -123,10 +122,35 @@ :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-subject-format '("beforeopening" "left" "untitled") + "Use the title as the subject of the letter. At the time of +writing the following values are allowed: + + - afteropening: subject after opening + - beforeopening: subject before opening + - centered: subject centered + - left:subject left-justified + - right: subject right-justified + - titled: add title/description to subject + - underlined: set subject underlined (see note in text please) + - 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)" + :type '(set (const "afteropening") + (const "beforeopening") + (const "centered") + (const "left") + (const "right") + (const "underlined") + (const "titled") + (const "untitled") + (const :tag "No export" nil) + (string)) + :group 'org-export-koma-letter) + + (defcustom org-koma-letter-use-backaddress t "Print return address in small line above to address." @@ -179,7 +203,7 @@ Use `foldmarks:true' to activate default fold marks or (: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)) + (:with-subject nil "subject" org-koma-letter-subject-format)) :translate-alist '((export-block . org-koma-letter-export-block) (export-snippet . org-koma-letter-export-snippet) (keyword . org-koma-letter-keyword) @@ -300,12 +324,29 @@ holding export options." ;; Document start "\\begin{document}\n\n" ;; 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))))) + (let* ((with-subject (plist-get info :with-subject)) + (subject-format + (if (member + ;; test if subject-format is t + (cond ((symbolp with-subject) (downcase (symbol-name with-subject))) + ((stringp with-subject) (downcase with-subject)) + (t nil)) + '("true" "t")) + org-koma-letter-subject-format + with-subject)) + (subject (org-export-data (plist-get info :title) info)) + (l (if (stringp subject-format) 1 (length subject-format))) + (y "")) + (concat + (when with-subject + (concat + "\\KOMAoption{subject}{" + (apply 'format + (dotimes (x l y) + (setq y (concat (if (> x 0) "%s," "%s") y))) + subject-format) "}\n")) + (when (and subject with-subject) + (format "\\setkomavar{subject}{%s}\n\n" subject)))) ;; Letter start (format "\\begin{letter}{%%\n%s}\n\n" (or (plist-get info :to-address) "no address given")) -- 1.8.2.3 ^ permalink raw reply related [flat|nested] 48+ messages in thread
* Re: [patch] ox-koma-letter.el: subject changes [2/4] 2013-05-20 18:23 ` Rasmus @ 2013-05-21 7:24 ` Alan Schmitt 2013-05-21 15:52 ` Viktor Rosenfeld 0 siblings, 1 reply; 48+ messages in thread From: Alan Schmitt @ 2013-05-21 7:24 UTC (permalink / raw) To: Rasmus; +Cc: emacs-orgmode Rasmus writes: > I found a "bug" in that the subject variable should be a list cf. the > KOMA manual. This patch fixes this. > > It's pretty complex for something so simple, and I might be inclined > to admit to the "put it in a LCO"-file approach might be better. I'd really like to have a second opinion on this. Viktor? Best, Alan ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: [patch] ox-koma-letter.el: subject changes [2/4] 2013-05-21 7:24 ` Alan Schmitt @ 2013-05-21 15:52 ` Viktor Rosenfeld 2013-05-21 17:48 ` Rasmus 0 siblings, 1 reply; 48+ messages in thread From: Viktor Rosenfeld @ 2013-05-21 15:52 UTC (permalink / raw) To: Alan Schmitt; +Cc: emacs-orgmode, Rasmus Hi, Alan Schmitt wrote: > Rasmus writes: > > > I found a "bug" in that the subject variable should be a list cf. the > > KOMA manual. This patch fixes this. > > > > It's pretty complex for something so simple, and I might be inclined > > to admit to the "put it in a LCO"-file approach might be better. > > I'd really like to have a second opinion on this. Viktor? I think this patch is great simply from the usability standpoint of being able to configure the behavior through customize (which I don't generally use, but admit that it's a good thing). I found a few issues though: 1. Choosing `No export' in customize results `\KOMAoption{subject}{nil}'. 2. It is not possible to set a subject format in the LCO file because if `org-koma-letter-subject-format' is set, the KOMA option will be overwritten explicitly, and if it is set to `nil' then the subject is inhibited altogether. This is actually a problem with the old code as well. One way out of this is to only print the subject line (i.e., `\setkomavar{subject}{.}' if `org-koma-letter-subject-format' is nil and and fix `noexport' to hide the subject (i.e., inhibit `\setkomavar{subject}{.}'). Is this the entended behaviour? I'll try to post a patch for this later tonight. 3. I'm not a big fan of the parentheses in the subject:(.) syntax, but if that's required to use an option list with multiple values I think it's okay. It would be nice to be able to specify a single value without the parens, but it's not a high priority (and I don't know how to do that). Cheers, Viktor > > Best, > > Alan > ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: [patch] ox-koma-letter.el: subject changes [2/4] 2013-05-21 15:52 ` Viktor Rosenfeld @ 2013-05-21 17:48 ` Rasmus 0 siblings, 0 replies; 48+ messages in thread From: Rasmus @ 2013-05-21 17:48 UTC (permalink / raw) To: alan.schmitt; +Cc: emacs-orgmode Viktor Rosenfeld <listuser36@gmail.com> writes: >> > I found a "bug" in that the subject variable should be a list >> > cf. the >> > KOMA manual. This patch fixes this. >> > >> > It's pretty complex for something so simple, and I might be >> > inclined >> > to admit to the "put it in a LCO"-file approach might be better. >> >> I'd really like to have a second opinion on this. Viktor? > > I think this patch is great simply from the usability standpoint of > being able to configure the behavior through customize (which I don't > generally use, but admit that it's a good thing). > > I found a few issues though: > > 1. Choosing `No export' in customize results > `\KOMAoption{subject}{nil}'. Thanks, that's a bug. I'll look into it ASAP. > 2. It is not possible to set a subject format in the LCO file because > if > `org-koma-letter-subject-format' is set, the KOMA option will be > overwritten explicitly, and if it is set to `nil' then the subject is > inhibited altogether. This is actually a problem with the old code as > well. One way out of this is to only print the subject line (i.e., > `\setkomavar{subject}{.}' if `org-koma-letter-subject-format' is nil > and > and fix `noexport' to hide the subject (i.e., inhibit > `\setkomavar{subject}{.}'). Perhaps the ox-latex.el way is the way to go: #+TITLE: # i.e. nothing The difference would be that here would have not to format subject komavar at all. > Is this the entended behaviour? I'll try to post a patch for this > later tonight. Yeah, let's think about it. From my point of view, basically never using LCO files, I think 1. it should be possible to not post a subject. I tried to implement this via #+OPTIONS: subject:nil. 2. But perhaps I'm trying to be too clever. I might have defined komavar-subject in an LCO file, but still changing subject formating on the go. This is not possible. 3. If letting subject be disabled by an empty title 2. won't break it. So how about the condition (pseudo lisp): (or (title is nil) (subject is nil))? It should be pretty simple to get to that state I think. > 3. I'm not a big fan of the parentheses in the subject:(.) syntax, but > if that's required to use an option list with multiple values I think > it's okay. OK, perhaps there's a clever way to get it to accept several keywords without a parenthese. I'm not sure. > It would be nice to be able to specify a single value without the > parens, but it's not a high priority (and I don't know how to do > that). That should be possible. I thought I'd tested it. Note though, that giving a single value overwrites the default. I'm not sure whether it should extend upon the default. Cheers, Rasmus -- C is for Cookie ^ permalink raw reply [flat|nested] 48+ messages in thread
* [patch] ox-koma-letter.el: credit [3/4] 2013-05-20 0:28 [patch] ox-koma-letter.el: credit [1/4] Rasmus 2013-05-20 0:40 ` [patch] ox-koma-letter.el: subject changes [2/4] Rasmus @ 2013-05-20 0:51 ` Rasmus 2013-05-20 15:52 ` Alan Schmitt 2013-05-21 16:56 ` Viktor Rosenfeld 2013-05-20 0:54 ` [patch] ox-koma-letter.el: clean-up/semantic bug [4/4] Rasmus ` (2 subsequent siblings) 4 siblings, 2 replies; 48+ messages in thread From: Rasmus @ 2013-05-20 0:51 UTC (permalink / raw) To: emacs-orgmode; +Cc: alan.schmitt, n.goaziou, papoanaya [-- Attachment #1: Type: text/plain, Size: 1005 bytes --] This is probably the most fun change. It adds special tags PS, ENCL, CC, AFTER_CLOSING as in my last patch set, but it uses heading this time. E.g. ENCLs are under the heading * ENCL :ENCL:. This was suggested by Nicolas, and it's nicer. The ideas comes from ox-groff.el file ¹. Thanks Luis! One thing I'd like to discuss is whether to adopt headings for TO and FROM also. The Groff exporter already does so for it's letters. The main benefit is that it allows for org-syntax. IMO it's a lot nicer to look at as well. Check the org-groff site in the footnote for an example. I'd be happy to look into this the next time I have a free day for programming if you guys (also) find in a more appealing. (One additional benefit would be that for simple documents it wouldn't matter whether groff or scrlttr2 was used as backend). –Rasmus Footnotes: ¹ http://orgmode.org/worg/org-tutorials/org-e-groff-documentation.html#sec-1-5 -- Powered by magic pixies! [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0003-Added-support-for-after-closing-and-after-document-e.patch --] [-- Type: text/x-patch, Size: 7222 bytes --] From eeaa129b6807465566be881b96a94e14706c9a28 Mon Sep 17 00:00:00 2001 From: "rasmus.pank" <rasmus.pank@gmail.com> Date: Sun, 19 May 2013 21:50:14 +0200 Subject: [PATCH 3/4] Added support for after closing and after document entities in ox-koma-letter. * ox-koma-letter.el (org-koma-letter-special-tags-after-closing): specials tags inserted after =\end{closing}= * ox-koma-letter.el (org-koma-letter-special-tags-other): other special tags * ox-koma-letter.el (org-koma-letter-special-tags): collect the two previoues lists (this might be done in a wrong way). * ox-koma-letter.el (org-koma-letter-ps-prefix): a prefix for PS since scrlttr does not provide it. * ox-koma-letter.el (org-koma-letter-headline): stores content in a special list if it is =`org-koma-letter-special-tags'= as in ox-groff. Only returns contents if not tags not in special tags. * ox-koma-letter.el (org-koma-letter-special-content): holds special content temporarily. * ox-koma-letter.el (org-koma-letter-template): added support for the headings with special tags. The following example will now export a sensible manner. * my letter here's a letter * PS :PS: it's requires this patch * CC :CC: Nicolas, Viktor and Alan * ENCL :ENCL: many patches 1. this patch 2. another patch. * include patches :AFTER_LETTER: \myspecial macro Namely, content of PS, ENCL and CC headings will be exported after \closing{.} in the order prescribed by =`org-koma-letter-special-tags-after-closing'=. The concent of the =AFTER_LETTER= heading will be inserted after =\end{letter}=, ideal for e.g. =pdfpages= commands. --- contrib/lisp/ox-koma-letter.el | 86 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 81 insertions(+), 5 deletions(-) diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el index 77d21c7..8ae9fc5 100644 --- a/contrib/lisp/ox-koma-letter.el +++ b/contrib/lisp/ox-koma-letter.el @@ -183,6 +183,29 @@ Use `foldmarks:true' to activate default fold marks or :group 'org-export-koma-letter :type 'boolean) +(defcustom org-koma-letter-ps-prefix "\\textsc{ps}: " + "The prefix of PS. Used to construct PS as \"PS-SUFFIX PS\"" + :group 'org-export-koma-letter + :type 'string) + + +(defconst org-koma-letter-special-tags-after-closing + '("PS" "ENCL" "CC") + "Headers tags to be inserted after closing") + +(defconst org-koma-letter-special-tags-other + '("FROM" "AFTER_LETTER") + "Headers tags to be inserted after closing") + +(defconst org-koma-letter-special-tags + (append org-koma-letter-special-tags-other + org-koma-letter-special-tags-after-closing) + "Header tags with special meaning") + +(defvar org-koma-letter-special-content nil "holds special +content temporarily.") + + \f ;;; Define Back-End @@ -198,15 +221,18 @@ Use `foldmarks:true' to activate default fold marks or (:opening "OPENING" nil org-koma-letter-opening) (:closing "CLOSING" nil org-koma-letter-closing) (:signature "SIGNATURE" nil org-koma-letter-signature newline) + (:ps-prefix nil "ps-prefix" org-koma-letter-ps-prefix) (: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-after-closing nil "after-closing-order" org-koma-letter-special-tags-after-closing) (:with-subject nil "subject" org-koma-letter-subject-format)) :translate-alist '((export-block . org-koma-letter-export-block) (export-snippet . org-koma-letter-export-snippet) + (headline . org-koma-letter-headline) (keyword . org-koma-letter-keyword) (template . org-koma-letter-template)) :menu-entry @@ -253,12 +279,47 @@ channel." (if (equal key "KOMA-LETTER") value (org-export-with-backend 'latex keyword contents info)))) + +;; The following is taken from/inspired by ox-grof.el +;; Thanks, Luis! + +(defun org-koma-letter--get-tagged-content (tag info) + (cdr (assoc tag org-koma-letter-special-content))) + + +(defun org-koma-letter-headline (headline conents info) + "Transcode a HEADLINE element from Org to LaTeX. +CONTENTS holds the contents of the headline. INFO is a plist +holding contextual informatio.n + +Note that if a headline is tagged with a tag from +`org-koma-letter-special-tags' it will not be exported, but +stored in `org-koma-letter-special-content' and included at the +appropriate place." + (let* + ((tags (and (plist-get info :with-tags) + (org-export-get-tags headline info)))) + (if (member (car tags) org-koma-letter-special-tags) + (cond ((member (car tags) '("PS" "ps")) + (progn + (push (cons (car tags) (concat (plist-get info :ps-prefix) contents)) + org-koma-letter-special-content) nil)) + (t (progn + (push (cons (car tags) contents) + org-koma-letter-special-content) nil))) + contents))) + + ;;;; Template (defun org-koma-letter-template (contents info) "Return complete document string after KOMA Scrlttr2 conversion. CONTENTS is the transcoded contents string. INFO is a plist holding export options." + ;; FIXME: instead of setq'ing org-koma-letter-special-content and + ;; callying varioues stuff it might be nice to put a big let* around the templace + ;; as in org-groff... + (setq org-koma-letter-special-content nil) (concat ;; Time-stamp. (and (plist-get info :time-stamp-file) @@ -327,14 +388,14 @@ holding export options." ;; Subject (let* ((with-subject (plist-get info :with-subject)) (subject-format (if (member with-subject '("True" t "true" "TRUE")) - ;; FIXME: could this be done more elegantly? - ;; I.e. force lower face of with-subject if string. + ;; FIXME: could this be done more elegantly? + ;; I.e. force lower face of with-subject if string. org-koma-letter-subject-format with-subject)) (subject (org-export-data (plist-get info :title) info))) (concat (when with-subject - (format "\\KOMAoption{subject}{%s}\n\n" subject-format)) + (format "\\KOMAoption{subject}{%s}\n" subject-format)) (when (and subject with-subject) (format "\\setkomavar{subject}{%s}\n\n" subject)))) ;; Letter start @@ -346,9 +407,24 @@ holding export options." contents ;; Closing. (format "\n\\closing{%s}\n\n" (plist-get info :closing)) + (let (after-closing) + (dolist (ac org-koma-letter-special-tags-after-closing after-closing) + (let ((x (org-koma-letter--get-tagged-content ac info))) + (when x (setq after-closing + (concat after-closing + ;; sometimes LaTeX complains about newlines + ;; at the end of macros. Remove them. + (replace-regexp-in-string + "\n+$" "" + (format "\\%s{%s}" (downcase ac) x))))) + ))) ;; Letter end. - "\\end{letter}\n\\end{document}")) - + "\\end{letter}\n" + (let ((x (org-koma-letter--get-tagged-content "AFTER_LETTER" info))) + (when x (format x))) + ;; Document end. + "\\end{document}" + )) \f ;;; Commands -- 1.8.2.3 ^ permalink raw reply related [flat|nested] 48+ messages in thread
* Re: [patch] ox-koma-letter.el: credit [3/4] 2013-05-20 0:51 ` [patch] ox-koma-letter.el: credit [3/4] Rasmus @ 2013-05-20 15:52 ` Alan Schmitt 2013-05-21 16:56 ` Viktor Rosenfeld 1 sibling, 0 replies; 48+ messages in thread From: Alan Schmitt @ 2013-05-20 15:52 UTC (permalink / raw) To: Rasmus; +Cc: n.goaziou, emacs-orgmode, papoanaya Hello again, Rasmus writes: > This is probably the most fun change. It adds special tags PS, ENCL, > CC, AFTER_CLOSING as in my last patch set, but it uses heading this > time. E.g. ENCLs are under the heading * ENCL :ENCL:. This was > suggested by Nicolas, and it's nicer. The ideas comes from > ox-groff.el file¹. Thanks Luis! This is great, thanks. I'd like to have the opinion of others on the code, but I very much welcome this change. > One thing I'd like to discuss is whether to adopt headings for TO and > FROM also. The Groff exporter already does so for it's letters. The > main benefit is that it allows for org-syntax. IMO it's a lot nicer > to look at as well. Check the org-groff site in the footnote for an > example. > > I'd be happy to look into this the next time I have a free day for > programming if you guys (also) find in a more appealing. (One > additional benefit would be that for simple documents it wouldn't > matter whether groff or scrlttr2 was used as backend). This would be very helpful indeed. Alan ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: [patch] ox-koma-letter.el: credit [3/4] 2013-05-20 0:51 ` [patch] ox-koma-letter.el: credit [3/4] Rasmus 2013-05-20 15:52 ` Alan Schmitt @ 2013-05-21 16:56 ` Viktor Rosenfeld 2013-05-21 17:35 ` Rasmus 1 sibling, 1 reply; 48+ messages in thread From: Viktor Rosenfeld @ 2013-05-21 16:56 UTC (permalink / raw) To: Rasmus; +Cc: n.goaziou, alan.schmitt, emacs-orgmode, papoanaya Hi, Rasmus wrote: > This is probably the most fun change. It adds special tags PS, ENCL, > CC, AFTER_CLOSING as in my last patch set, but it uses heading this > time. E.g. ENCLs are under the heading * ENCL :ENCL:. This was > suggested by Nicolas, and it's nicer. The ideas comes from > ox-groff.el file ¹. Thanks Luis! This is great! A few things: - It doesn't work because `org-koma-letter-special-content' is set to nil at the beginning of `org-koma-letter-template'. Why is that? If I comment it out everything works. - The function `org-koma-letter--get-tagged-content' does not use the `info' argument. Also, the function is not documented. - The second argument of `org-koma-letter-headline' is misspelled (`conents'). - I would remove the formatting from org-koma-letter-ps-prefix and put it in the docstring, simply because the separators for \encl and \cc are also not formatted in the KOMA-Script defaults. > One thing I'd like to discuss is whether to adopt headings for TO and > FROM also. The Groff exporter already does so for it's letters. The > main benefit is that it allows for org-syntax. IMO it's a lot nicer > to look at as well. Check the org-groff site in the footnote for an > example. I am not sure about this. I often write a letter below a task in my Org files so I rely on exporting the subtree only. So I would have to put the TO address below the letter text which looks weird, but is doable. On the other hand, being able to use Org syntax and not have to escape linebreaks with `\\' is a big plus. > I'd be happy to look into this the next time I have a free day for > programming if you guys (also) find in a more appealing. (One > additional benefit would be that for simple documents it wouldn't > matter whether groff or scrlttr2 was used as backend). This would be a nice advantage. Maybe both options could be supported. I.e., use a FROM headline if available, but fall back on option lines if not? Or is this too confusing for users? Cheers, Viktor > > –Rasmus > > > Footnotes: > ¹ http://orgmode.org/worg/org-tutorials/org-e-groff-documentation.html#sec-1-5 > > -- > Powered by magic pixies! > >From eeaa129b6807465566be881b96a94e14706c9a28 Mon Sep 17 00:00:00 2001 > From: "rasmus.pank" <rasmus.pank@gmail.com> > Date: Sun, 19 May 2013 21:50:14 +0200 > Subject: [PATCH 3/4] Added support for after closing and after document > entities in ox-koma-letter. > > * ox-koma-letter.el (org-koma-letter-special-tags-after-closing): specials tags inserted after =\end{closing}= > * ox-koma-letter.el (org-koma-letter-special-tags-other): other special tags > * ox-koma-letter.el (org-koma-letter-special-tags): collect > the two previoues lists (this might be done in a wrong way). > * ox-koma-letter.el (org-koma-letter-ps-prefix): a prefix for > PS since scrlttr does not provide it. > * ox-koma-letter.el (org-koma-letter-headline): stores content > in a special list if it is =`org-koma-letter-special-tags'= as > in ox-groff. Only returns contents if not tags not in special > tags. > * ox-koma-letter.el (org-koma-letter-special-content): holds special > content temporarily. > * ox-koma-letter.el (org-koma-letter-template): added support > for the headings with special tags. > > The following example will now export a sensible manner. > > * my letter > here's a letter > * PS :PS: > it's requires this patch > * CC :CC: > Nicolas, Viktor and Alan > * ENCL :ENCL: > many patches > 1. this patch > 2. another patch. > * include patches :AFTER_LETTER: > \myspecial macro > > Namely, content of PS, ENCL and CC headings will be exported after > \closing{.} in the order prescribed by > =`org-koma-letter-special-tags-after-closing'=. The concent > of the =AFTER_LETTER= heading will be inserted after > =\end{letter}=, ideal for e.g. =pdfpages= commands. > --- > contrib/lisp/ox-koma-letter.el | 86 +++++++++++++++++++++++++++++++++++++++--- > 1 file changed, 81 insertions(+), 5 deletions(-) > > diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el > index 77d21c7..8ae9fc5 100644 > --- a/contrib/lisp/ox-koma-letter.el > +++ b/contrib/lisp/ox-koma-letter.el > @@ -183,6 +183,29 @@ Use `foldmarks:true' to activate default fold marks or > :group 'org-export-koma-letter > :type 'boolean) > > +(defcustom org-koma-letter-ps-prefix "\\textsc{ps}: " > + "The prefix of PS. Used to construct PS as \"PS-SUFFIX PS\"" > + :group 'org-export-koma-letter > + :type 'string) > + > + > +(defconst org-koma-letter-special-tags-after-closing > + '("PS" "ENCL" "CC") > + "Headers tags to be inserted after closing") > + > +(defconst org-koma-letter-special-tags-other > + '("FROM" "AFTER_LETTER") > + "Headers tags to be inserted after closing") > + > +(defconst org-koma-letter-special-tags > + (append org-koma-letter-special-tags-other > + org-koma-letter-special-tags-after-closing) > + "Header tags with special meaning") > + > +(defvar org-koma-letter-special-content nil "holds special > +content temporarily.") > + > + > \f > ;;; Define Back-End > > @@ -198,15 +221,18 @@ Use `foldmarks:true' to activate default fold marks or > (:opening "OPENING" nil org-koma-letter-opening) > (:closing "CLOSING" nil org-koma-letter-closing) > (:signature "SIGNATURE" nil org-koma-letter-signature newline) > + (:ps-prefix nil "ps-prefix" org-koma-letter-ps-prefix) > > (: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-after-closing nil "after-closing-order" org-koma-letter-special-tags-after-closing) > (:with-subject nil "subject" org-koma-letter-subject-format)) > :translate-alist '((export-block . org-koma-letter-export-block) > (export-snippet . org-koma-letter-export-snippet) > + (headline . org-koma-letter-headline) > (keyword . org-koma-letter-keyword) > (template . org-koma-letter-template)) > :menu-entry > @@ -253,12 +279,47 @@ channel." > (if (equal key "KOMA-LETTER") value > (org-export-with-backend 'latex keyword contents info)))) > > + > +;; The following is taken from/inspired by ox-grof.el > +;; Thanks, Luis! > + > +(defun org-koma-letter--get-tagged-content (tag info) > + (cdr (assoc tag org-koma-letter-special-content))) > + > + > +(defun org-koma-letter-headline (headline conents info) > + "Transcode a HEADLINE element from Org to LaTeX. > +CONTENTS holds the contents of the headline. INFO is a plist > +holding contextual informatio.n > + > +Note that if a headline is tagged with a tag from > +`org-koma-letter-special-tags' it will not be exported, but > +stored in `org-koma-letter-special-content' and included at the > +appropriate place." > + (let* > + ((tags (and (plist-get info :with-tags) > + (org-export-get-tags headline info)))) > + (if (member (car tags) org-koma-letter-special-tags) > + (cond ((member (car tags) '("PS" "ps")) > + (progn > + (push (cons (car tags) (concat (plist-get info :ps-prefix) contents)) > + org-koma-letter-special-content) nil)) > + (t (progn > + (push (cons (car tags) contents) > + org-koma-letter-special-content) nil))) > + contents))) > + > + > ;;;; Template > > (defun org-koma-letter-template (contents info) > "Return complete document string after KOMA Scrlttr2 conversion. > CONTENTS is the transcoded contents string. INFO is a plist > holding export options." > + ;; FIXME: instead of setq'ing org-koma-letter-special-content and > + ;; callying varioues stuff it might be nice to put a big let* around the templace > + ;; as in org-groff... > + (setq org-koma-letter-special-content nil) > (concat > ;; Time-stamp. > (and (plist-get info :time-stamp-file) > @@ -327,14 +388,14 @@ holding export options." > ;; Subject > (let* ((with-subject (plist-get info :with-subject)) > (subject-format (if (member with-subject '("True" t "true" "TRUE")) > - ;; FIXME: could this be done more elegantly? > - ;; I.e. force lower face of with-subject if string. > + ;; FIXME: could this be done more elegantly? > + ;; I.e. force lower face of with-subject if string. > org-koma-letter-subject-format > with-subject)) > (subject (org-export-data (plist-get info :title) info))) > (concat > (when with-subject > - (format "\\KOMAoption{subject}{%s}\n\n" subject-format)) > + (format "\\KOMAoption{subject}{%s}\n" subject-format)) > (when (and subject with-subject) > (format "\\setkomavar{subject}{%s}\n\n" subject)))) > ;; Letter start > @@ -346,9 +407,24 @@ holding export options." > contents > ;; Closing. > (format "\n\\closing{%s}\n\n" (plist-get info :closing)) > + (let (after-closing) > + (dolist (ac org-koma-letter-special-tags-after-closing after-closing) > + (let ((x (org-koma-letter--get-tagged-content ac info))) > + (when x (setq after-closing > + (concat after-closing > + ;; sometimes LaTeX complains about newlines > + ;; at the end of macros. Remove them. > + (replace-regexp-in-string > + "\n+$" "" > + (format "\\%s{%s}" (downcase ac) x))))) > + ))) > ;; Letter end. > - "\\end{letter}\n\\end{document}")) > - > + "\\end{letter}\n" > + (let ((x (org-koma-letter--get-tagged-content "AFTER_LETTER" info))) > + (when x (format x))) > + ;; Document end. > + "\\end{document}" > + )) > > \f > ;;; Commands > -- > 1.8.2.3 > ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: [patch] ox-koma-letter.el: credit [3/4] 2013-05-21 16:56 ` Viktor Rosenfeld @ 2013-05-21 17:35 ` Rasmus 2013-05-21 20:06 ` Viktor Rosenfeld 0 siblings, 1 reply; 48+ messages in thread From: Rasmus @ 2013-05-21 17:35 UTC (permalink / raw) To: listuser36; +Cc: emacs-orgmode, alan.schmitt, n.goaziou Viktor, Good to hear from you! >> This is probably the most fun change. It adds special tags PS, ENCL, >> CC, AFTER_CLOSING as in my last patch set, but it uses heading this >> time. E.g. ENCLs are under the heading * ENCL :ENCL:. This was >> suggested by Nicolas, and it's nicer. The ideas comes from >> ox-groff.el file ¹. Thanks Luis! > > This is great! A few things: > > - It doesn't work because `org-koma-letter-special-content' is set to > nil at the beginning of `org-koma-letter-template'. Why is that? If I > comment it out everything works. Hmm, it should be populated by the headline function each time. . . That is at least the idea. I.e. - When exporting `org-koma-letter-special-content' gets populated and is available until next export. - When exports run again stuff might have changed so I want to repopulate the variable. Perhaps I had loaded some magic in Emacs when I tested it that wasn't preserved in the patch. I'll test it again ASAP. > - The function `org-koma-letter--get-tagged-content' does not use the > `info' argument. Also, the function is not documented. No it doesn't use info. I guess it's just for consistency. It's more or less taken from ox-groff. I don't mind removing it. > - The second argument of `org-koma-letter-headline' is misspelled > (`conents'). Thanks! > - I would remove the formatting from org-koma-letter-ps-prefix and put > it in the docstring, simply because the separators for \encl and \cc > are also not formatted in the KOMA-Script defaults. So you'd set org-koma-letter-ps-prefix to nil or ""? The thing is, in scrlttr2 does not add a ps-prefix by itself, which seems inconsistent. So with your suggesting we'd get a more vanilla feel, which I guess would normally be nice, but here somehow feel inconsistent to me. I'm happy to oblige on this issue. >> One thing I'd like to discuss is whether to adopt headings for TO and >> FROM also. The Groff exporter already does so for it's letters. The >> main benefit is that it allows for org-syntax. IMO it's a lot nicer >> to look at as well. Check the org-groff site in the footnote for an >> example. > > I am not sure about this. I often write a letter below a task in my > Org files so I rely on exporting the subtree only. So I would have to > put the TO address below the letter text which looks weird, but is > doable. On the other hand, being able to use Org syntax and not have to > escape linebreaks with `\\' is a big plus. > Maybe both options could be supported. I.e., use a FROM headline if > available, but fall back on option lines if not? Or is this too > confusing for users? The reason why I didn't add it as this point is that I'd want to keep it 'backward compatible' and I had to think about it. I was toying with introducing a =:with-legacy= variable that would govern which of =* TO :TO:= and =#+TO_ADDRESS= would be printed if both are present. What do you think? Thanks for your comments. –Rasmus -- The Kids call him Billy the Saint ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: [patch] ox-koma-letter.el: credit [3/4] 2013-05-21 17:35 ` Rasmus @ 2013-05-21 20:06 ` Viktor Rosenfeld [not found] ` <87zjvo7xkl.fsf@pank.eu> 0 siblings, 1 reply; 48+ messages in thread From: Viktor Rosenfeld @ 2013-05-21 20:06 UTC (permalink / raw) To: Rasmus; +Cc: emacs-orgmode, alan.schmitt, n.goaziou Hi, Rasmus wrote: > > - It doesn't work because `org-koma-letter-special-content' is set to > > nil at the beginning of `org-koma-letter-template'. Why is that? If I > > comment it out everything works. > > Hmm, it should be populated by the headline function each time. . . > That is at least the idea. I.e. > - When exporting `org-koma-letter-special-content' gets populated > and is available until next export. > - When exports run again stuff might have changed so I want to > repopulate the variable. Why not clear `org-koma-letter-special-content' at the start of `org-koma-letter-headline'? > > - I would remove the formatting from org-koma-letter-ps-prefix and put > > it in the docstring, simply because the separators for \encl and \cc > > are also not formatted in the KOMA-Script defaults. > > So you'd set org-koma-letter-ps-prefix to nil or ""? The thing is, in > scrlttr2 does not add a ps-prefix by itself, which seems inconsistent. > So with your suggesting we'd get a more vanilla feel, which I guess > would normally be nice, but here somehow feel inconsistent to me. I'm > happy to oblige on this issue. Either nil or "" or even "PS". I guess there is no default because people write things like PPS and PPPS and so on. Anyway, in my view having \ps specially formatted is inconsistent because \encl and \cc are not per default. > >> One thing I'd like to discuss is whether to adopt headings for TO and > >> FROM also. The Groff exporter already does so for it's letters. The > >> main benefit is that it allows for org-syntax. IMO it's a lot nicer > >> to look at as well. Check the org-groff site in the footnote for an > >> example. > > > > I am not sure about this. I often write a letter below a task in my > > Org files so I rely on exporting the subtree only. So I would have to > > put the TO address below the letter text which looks weird, but is > > doable. On the other hand, being able to use Org syntax and not have to > > escape linebreaks with `\\' is a big plus. > > > Maybe both options could be supported. I.e., use a FROM headline if > > available, but fall back on option lines if not? Or is this too > > confusing for users? > > The reason why I didn't add it as this point is that I'd want to keep > it 'backward compatible' and I had to think about it. I was toying > with introducing a =:with-legacy= variable that would govern which of > =* TO :TO:= and =#+TO_ADDRESS= would be printed if both are present. I would definitely like to keep the old functionality. I like how your patch uses headlines to add additional information to the letter. But in the letters I wrote I would only need a FROM headline and having this single headline below the letter text seems strange. However, I realize that my preferences are very much tied to my workflow and being able to specify an address below FROM or TO headlines is very useful because it is so powerful (and probably easier to new users). If a letter uses both a headline and an option line to set an address I would think the headline should take precedence, because it is more powerful. A `:with-legacy' variable doesn't really solve anything because what does the exporter do if the variable is missing but there are two addresses set? Maybe the exporter could simply emit a warning in that case. Cheers, Viktor > > What do you think? > > Thanks for your comments. > –Rasmus > > -- > The Kids call him Billy the Saint > ^ permalink raw reply [flat|nested] 48+ messages in thread
[parent not found: <87zjvo7xkl.fsf@pank.eu>]
[parent not found: <20130522145312.GB61443@kenny.local>]
* Re: [patch] ox-koma-letter.el: credit [3/4] [not found] ` <20130522145312.GB61443@kenny.local> @ 2013-05-22 17:16 ` Rasmus 2013-05-22 17:38 ` Viktor Rosenfeld 0 siblings, 1 reply; 48+ messages in thread From: Rasmus @ 2013-05-22 17:16 UTC (permalink / raw) To: listuser36; +Cc: emacs-orgmode Viktor Rosenfeld <listuser36@gmail.com> writes: >> Ah, you mean the textsc? Perhaps it is a bit eccentric. But you're >> bringing up a good point. It should recognize [p]+s and perhaps even >> order them. . . > > If there is no PS prefix set, users could simply write these out > themselves. I don't think it is much of a burden. Recognizing multiple > :P[+]S: tags in code seems like overkill to me. The all go into the same > \ps, don't they? No, you'd want have \ps{ps:one} \ps{pps:two} \ps{pps:three}. Either they could be different subtrees * ps :ps: ** ps-one ps:one ** ps-two ps:two [...] or they could just be ordered the way they were in the buffer. Probably that's easier. > The latter example does not really work for me because I often write > letters below a TODO headline (as opposed to a dedicated file). So I > restrict export to a subtree which would not work if I'm below the > letter headline. In my case I would use something like this: > > #+BEGIN_EXAMPLE > * TODO write letter > :PROPERTIES: > :EXPORT_OPENING: ... > ... > :END: > > The letter goes here. > > ** TO :TO: > ... > #+END_EXAMPLE > I have a capture template setup for letters, so I don't normally have to > add the address information manually. I would probably stick to the old > format and use headlines if I have a PS and so on. Cool, you should write an article about! -- Don't panic!!! ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: [patch] ox-koma-letter.el: credit [3/4] 2013-05-22 17:16 ` Rasmus @ 2013-05-22 17:38 ` Viktor Rosenfeld 0 siblings, 0 replies; 48+ messages in thread From: Viktor Rosenfeld @ 2013-05-22 17:38 UTC (permalink / raw) To: Rasmus; +Cc: emacs-orgmode Hi, Rasmus wrote: > Viktor Rosenfeld <listuser36@gmail.com> writes: > > >> Ah, you mean the textsc? Perhaps it is a bit eccentric. But you're > >> bringing up a good point. It should recognize [p]+s and perhaps even > >> order them. . . > > > > If there is no PS prefix set, users could simply write these out > > themselves. I don't think it is much of a burden. Recognizing multiple > > :P[+]S: tags in code seems like overkill to me. The all go into the same > > \ps, don't they? > > No, you'd want have > \ps{ps:one} > \ps{pps:two} > \ps{pps:three}. Okay, I didn't know this. But what's the advantage over \ps{ ps:one ps:two ps:three} > > The latter example does not really work for me because I often write > > letters below a TODO headline (as opposed to a dedicated file). So I > > restrict export to a subtree which would not work if I'm below the > > letter headline. In my case I would use something like this: > > > > #+BEGIN_EXAMPLE > > * TODO write letter > > :PROPERTIES: > > :EXPORT_OPENING: ... > > ... > > :END: > > > > The letter goes here. > > > > ** TO :TO: > > ... > > #+END_EXAMPLE > > I have a capture template setup for letters, so I don't normally have to > > add the address information manually. I would probably stick to the old > > format and use headlines if I have a PS and so on. > > Cool, you should write an article about! Do you mean the capture template? I might put it in the tutorial. I planned to have a tips and tricks section there anyway. Cheers, Viktor > > -- > Don't panic!!! > ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: [patch] ox-koma-letter.el: clean-up/semantic bug [4/4] 2013-05-20 0:28 [patch] ox-koma-letter.el: credit [1/4] Rasmus 2013-05-20 0:40 ` [patch] ox-koma-letter.el: subject changes [2/4] Rasmus 2013-05-20 0:51 ` [patch] ox-koma-letter.el: credit [3/4] Rasmus @ 2013-05-20 0:54 ` Rasmus [not found] ` <m2ehd1tziq.fsf@polytechnique.org> 2013-05-20 15:44 ` [patch] ox-koma-letter.el: credit [1/4] Alan Schmitt 2013-05-21 17:06 ` Viktor Rosenfeld 4 siblings, 1 reply; 48+ messages in thread From: Rasmus @ 2013-05-20 0:54 UTC (permalink / raw) To: emacs-orgmode; +Cc: alan.schmitt, n.goaziou [-- Attachment #1: Type: text/plain, Size: 363 bytes --] It seems there are some semantic bugs in ox-koma-letter.el in that new variables are introduces for SENDER (as opposed to AUTHOR) and a separate email variable as well. This seems like a semantic bug IMO. This patch fixes these issues if they in fact are issues. –Rasmus -- And let me remind you also that moderation in the pursuit of justice is no virtue [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0004-Changed-SENDER-to-AUTHOR-and-removed-duplicated-emai.patch --] [-- Type: text/x-patch, Size: 2595 bytes --] From 0cb47f73c2e3579a78c2ae7e7d9777012f142f20 Mon Sep 17 00:00:00 2001 From: "rasmus.pank" <rasmus.pank@gmail.com> Date: Sun, 19 May 2013 22:14:54 +0200 Subject: [PATCH 4/4] Changed =#+SENDER= to =#+AUTHOR= and removed duplicated email and author variables in =ox-koma-letter.el=. * ox-koma-letter.el: changed the unorthodox =SENDER= keyword to the ordinary =AUTHOR= keyword. * ox-koma-letter.el: changed email to work as in standard latex exporter and dropped dedicated ox-koma-letter variable. --- contrib/lisp/ox-koma-letter.el | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el index 8ae9fc5..16bcb86 100644 --- a/contrib/lisp/ox-koma-letter.el +++ b/contrib/lisp/ox-koma-letter.el @@ -82,10 +82,6 @@ :group 'org-export-koma-letter :type 'string) -(defcustom org-koma-letter-sender nil - "Sender's name, as a string." - :group 'org-export-koma-letter - :type 'string) (defcustom org-koma-letter-from-address nil "Sender's address, as a string." @@ -97,10 +93,6 @@ :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." @@ -212,10 +204,10 @@ content temporarily.") (org-export-define-derived-backend 'koma-letter 'latex :options-alist '((:lco "LCO" nil org-koma-letter-class-option-file) - (:sender "SENDER" nil org-koma-letter-sender newline) + (:sender "AUTHOR" nil user-full-name t) (:from-address "FROM_ADDRESS" nil org-koma-letter-from-address newline) (:phone-number "PHONE_NUMBER" nil org-koma-letter-phone-number) - (:email "EMAIL" nil org-koma-letter-email) + (:email "EMAIL" nil user-mail-address t) (:to-address "TO_ADDRESS" nil nil newline) (:place "PLACE" nil org-koma-letter-place) (:opening "OPENING" nil org-koma-letter-opening) @@ -361,7 +353,8 @@ holding export options." (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 sender (format "\\setkomavar{fromname}{%s}\n" + (org-export-data sender info))) (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)) -- 1.8.2.3 ^ permalink raw reply related [flat|nested] 48+ messages in thread
[parent not found: <m2ehd1tziq.fsf@polytechnique.org>]
* Re: [patch] ox-koma-letter.el: clean-up/semantic bug [4/4] [not found] ` <m2ehd1tziq.fsf@polytechnique.org> @ 2013-05-21 9:05 ` Rasmus 2013-05-21 11:32 ` Alan Schmitt 0 siblings, 1 reply; 48+ messages in thread From: Rasmus @ 2013-05-21 9:05 UTC (permalink / raw) To: alan.schmitt; +Cc: emacs-orgmode Alan Schmitt <alan.schmitt@polytechnique.org> writes: >> It seems there are some semantic bugs in ox-koma-letter.el in that new >> variables are introduces for SENDER (as opposed to AUTHOR) and a >> separate email variable as well. This seems like a semantic bug IMO. >> This patch fixes these issues if they in fact are issues. > > Can we still use an lco file to set these after this change? (I'll also post this on the list). You can't set #+SENDER: Which seems to be how it was set up before. You can use #+AUTHOR So if you decide to convert your document from something you'd export with the normal LaTeX exporter it would be smoother this way. Author now works the same way that it does in the LaTeX exporter (come to think of it, we probably shouldn't need to mention anything as it build on top of the LaTeX exporter anyway). Thus, unless you disable export of author it wouldn't work with a LCO file. But then we could make export of author conditional on :with-author as in ox-latex.el and you could use LCO files. The gain is that in the (for me) 99.9% of the cases where I want to send a letter in my own name the exporter just figures it out without be having to specify anything (like in the normal exporter). –Rasmus -- In theory, practice and theory are the same. In practice they are not ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: [patch] ox-koma-letter.el: clean-up/semantic bug [4/4] 2013-05-21 9:05 ` Rasmus @ 2013-05-21 11:32 ` Alan Schmitt 2013-05-21 12:22 ` Rasmus 0 siblings, 1 reply; 48+ messages in thread From: Alan Schmitt @ 2013-05-21 11:32 UTC (permalink / raw) To: Rasmus; +Cc: emacs-orgmode Rasmus writes: > Alan Schmitt <alan.schmitt@polytechnique.org> writes: > >>> It seems there are some semantic bugs in ox-koma-letter.el in that new >>> variables are introduces for SENDER (as opposed to AUTHOR) and a >>> separate email variable as well. This seems like a semantic bug IMO. >>> This patch fixes these issues if they in fact are issues. >> >> Can we still use an lco file to set these after this change? > > (I'll also post this on the list). > > You can't set > > #+SENDER: > > Which seems to be how it was set up before. You can use > > #+AUTHOR > > So if you decide to convert your document from something you'd export > with the normal LaTeX exporter it would be smoother this way. Author > now works the same way that it does in the LaTeX exporter (come to > think of it, we probably shouldn't need to mention anything as it > build on top of the LaTeX exporter anyway). > > Thus, unless you disable export of author it wouldn't work with a LCO > file. But then we could make export of author conditional on > :with-author as in ox-latex.el and you could use LCO files. > > The gain is that in the (for me) 99.9% of the cases where I want to > send a letter in my own name the exporter just figures it out without > be having to specify anything (like in the normal exporter). OK, sounds good, I've applied it. Thanks, Alan ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: [patch] ox-koma-letter.el: clean-up/semantic bug [4/4] 2013-05-21 11:32 ` Alan Schmitt @ 2013-05-21 12:22 ` Rasmus 2013-05-21 17:02 ` Viktor Rosenfeld 0 siblings, 1 reply; 48+ messages in thread From: Rasmus @ 2013-05-21 12:22 UTC (permalink / raw) To: emacs-orgmode Alan Schmitt <alan.schmitt@polytechnique.org> writes: > OK, sounds good, I've applied it. Thanks. Let's wait with the rest till Vicktor's had a chance to look over it. –Rasmus -- Summon the Mothership! ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: [patch] ox-koma-letter.el: clean-up/semantic bug [4/4] 2013-05-21 12:22 ` Rasmus @ 2013-05-21 17:02 ` Viktor Rosenfeld 2013-05-21 18:13 ` Rasmus 0 siblings, 1 reply; 48+ messages in thread From: Viktor Rosenfeld @ 2013-05-21 17:02 UTC (permalink / raw) To: Rasmus; +Cc: Alan Schmitt, emacs-orgmode Hi, Rasmus wrote: > Alan Schmitt <alan.schmitt@polytechnique.org> writes: > > > OK, sounds good, I've applied it. Actually, this patch does break LCO files. Now, if you don't set AUTHOR or EMAIL in the letter the default options from the LaTeX exporter always overwrite the settings defined in LCO files. Rasmus, couldn't you just set the old `org-koma-letter-sender' option if you don't use LCO files? Also, I agree that SENDER should have been called AUTHOR. It was a workaround because the LaTeX backend would ignore nil values for AUTHOR in derived backends (but not for EMAIL, so I kept this). This should now have been fixed. > Let's wait with the rest till Vicktor's had a chance to look over it. Hmm, not fast enough. :-) Cheers, Viktor > > –Rasmus > > -- > Summon the Mothership! > > ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: [patch] ox-koma-letter.el: clean-up/semantic bug [4/4] 2013-05-21 17:02 ` Viktor Rosenfeld @ 2013-05-21 18:13 ` Rasmus 2013-05-21 19:54 ` Viktor Rosenfeld 0 siblings, 1 reply; 48+ messages in thread From: Rasmus @ 2013-05-21 18:13 UTC (permalink / raw) To: emacs-orgmode; +Cc: alan.schmitt Viktor Rosenfeld <listuser36@gmail.com> writes: > Actually, this patch does break LCO files. Now, if you don't set > AUTHOR or EMAIL in the letter the default options from the LaTeX > exporter always overwrite the settings defined in LCO files. This one is tough. . . One could #+INCLUDE an org-file but that's not really a fair comment. I'm not really sure how to progress. 1. One way would be do do a grep on the LCO files, but they might be in the TeX PATH which would vary over TeX systems and OSes. 2. Have people have empty AUTHOR and EMAIL if they've got the info in an LCO file, but this is not desirable. - Supply an optional filter to remove this info ex-post, but how would it know when to run? 3. Define some function to intelligently guess values based on content. 1. Perhaps a TYPE variable. So if TYPE is "business" or "causal" and I select business a list with business-defaults would be applied. OTOH this might be too complicated to just writing a LCO files. . . 4. Revert the path. What should be the standard? I'm compelled to go with "work as the LaTeX-backend", but it may not be optimal here if there's a need for chaining email and name regularly. > Rasmus, couldn't you just set the old `org-koma-letter-sender' > option if you don't use LCO files? Sure, I just thought it was inconsistent that the framework didn't use the same keywords as other backends. But consistent might lack for good reasons. For me the previous behavior was annoying since I usually don't set AUTHOR and this didn't work nicely. > Also, I agree that SENDER should have been called AUTHOR. It was a > workaround because the LaTeX backend would ignore nil values for > AUTHOR in derived backends (but not for EMAIL, so I kept this). This > should now have been fixed. OK. So it's OK to switch to the AUTHOR keyword and just the default is what we need to settle on? –Rasmus -- . . . Stallman was indeed the tallest possible mountain and by standing on his shoulders you could see forever. . . ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: [patch] ox-koma-letter.el: clean-up/semantic bug [4/4] 2013-05-21 18:13 ` Rasmus @ 2013-05-21 19:54 ` Viktor Rosenfeld 2013-05-21 23:23 ` Rasmus 0 siblings, 1 reply; 48+ messages in thread From: Viktor Rosenfeld @ 2013-05-21 19:54 UTC (permalink / raw) To: Rasmus; +Cc: alan.schmitt, emacs-orgmode Hi, Rasmus wrote: > Viktor Rosenfeld <listuser36@gmail.com> writes: > > > Actually, this patch does break LCO files. Now, if you don't set > > AUTHOR or EMAIL in the letter the default options from the LaTeX > > exporter always overwrite the settings defined in LCO files. > > This one is tough. . . > > One could #+INCLUDE an org-file but that's not really a fair comment. > > I'm not really sure how to progress. > > 1. One way would be do do a grep on the LCO files, but they might be > in the TeX PATH which would vary over TeX systems and OSes. Way too complicated and brittle, IMHO. > 2. Have people have empty AUTHOR and EMAIL if they've got the info in > an LCO file, but this is not desirable. > - Supply an optional filter to remove this info ex-post, but how > would it know when to run? Empty AUTHOR and EMAIL lines are not user-friendly. However, another option is to set `user-mail-address' and `user-full-name' to nil, but then this would also affect other areas of Emacs beside the LaTeX expoerter (which I currently no use so I can't speak to side-effects). > 3. Define some function to intelligently guess values based on > content. > 1. Perhaps a TYPE variable. So if TYPE is "business" or "causal" > and I select business a list with business-defaults would be > applied. OTOH this might be too complicated to just writing a > LCO files. . . Basically duplicates LCO files but will never achieve the same functionality. > 4. Revert the path. Or 5, keep the change from SENDER to AUTHOR but revert the default values to `org-koma-letter-*' variables. (Right now the AUTHOR and EMAIL lines could be removed because they duplicate the derived latex backend.) > What should be the standard? I'm compelled to go with "work as the > LaTeX-backend", but it may not be optimal here if there's a need for > chaining email and name regularly. I prefer 5. :-) > > Rasmus, couldn't you just set the old `org-koma-letter-sender' > > option if you don't use LCO files? > > Sure, I just thought it was inconsistent that the framework didn't use > the same keywords as other backends. But consistent might lack for > good reasons. The default LaTeX exporter does not have LCO files. Sure you can simply \input a latex file but there is no dedicated support for this in Org mode, is there? The LaTeX exporter also assumes that every LaTeX file needs a title, a date, and an author, but this is not always true as the scrlttr2 class shows (title, or subject, is definitely optional). Also, LaTeX blocks which are evaluated separately don't need these values either. So I understand striving for consistency, but I think that the use case here is different enough to break it. > For me the previous behavior was annoying since I usually don't set > AUTHOR and this didn't work nicely. > > > Also, I agree that SENDER should have been called AUTHOR. It was a > > workaround because the LaTeX backend would ignore nil values for > > AUTHOR in derived backends (but not for EMAIL, so I kept this). This > > should now have been fixed. > > OK. So it's OK to switch to the AUTHOR keyword and just the default > is what we need to settle on? I think that switching from SENDER to AUTHOR, keeping the `org-koma-letter-{author,email}' variables in the KOMA backend, but setting them per default to `user-full-name' and `user-mail-address', would solve both your problems and let me keep LCO files. I would then simply set these `org-koma-letter-*' variables to `nil' and document this setup in the docstring. I'll see tomorrow if this is feasable. Cheers, Viktor > > –Rasmus > > -- > . . . Stallman was indeed the tallest possible mountain and by > standing on his shoulders you could see forever. . . > ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: [patch] ox-koma-letter.el: clean-up/semantic bug [4/4] 2013-05-21 19:54 ` Viktor Rosenfeld @ 2013-05-21 23:23 ` Rasmus 2013-05-22 14:39 ` Viktor Rosenfeld 0 siblings, 1 reply; 48+ messages in thread From: Rasmus @ 2013-05-21 23:23 UTC (permalink / raw) To: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 1331 bytes --] Viktor Rosenfeld <listuser36@gmail.com> writes: > Or 5, keep the change from SENDER to AUTHOR but revert the default > values to `org-koma-letter-*' variables. (Right now the AUTHOR and EMAIL > lines could be removed because they duplicate the derived latex > backend.) I once had a teacher who talked about the optimal degree of conservatism (as well speaking positively about being in the infamoues ivory tower). 5. is fine with me. So I guess the deal is 1. default value is the same as in ox-latex. 2. . . . but it's kept in a seperete variable ox-kl variable. > The default LaTeX exporter does not have LCO files. Sure you can simply > \input a latex file but there is no dedicated support for this in Org > mode, is there? only through #+LATEX: \input{.} I guess (or something similar). > I think that switching from SENDER to AUTHOR, keeping the > `org-koma-letter-{author,email}' variables in the KOMA backend, but > setting them per default to `user-full-name' and `user-mail-address', > would solve both your problems and let me keep LCO files. I would then > simply set these `org-koma-letter-*' variables to `nil' and document > this setup in the docstring. I'll see tomorrow if this is feasable. Does the attached patch work for you (also with ps tags?) –Rasmus -- Dung makes an excellent fertilizer [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0005-Variables-for-author-and-email-for-ox-koma-letter-an.patch --] [-- Type: text/x-patch, Size: 6291 bytes --] From 92b07bac2d707f01e48796778453b67a9ecd1daa Mon Sep 17 00:00:00 2001 From: "rasmus.pank" <rasmus.pank@gmail.com> Date: Wed, 22 May 2013 01:16:54 +0200 Subject: [PATCH 5/5] Variables for author and email for ox-koma-letter and a bug fix. * ox-koma-letter.el (koma-letter): reintroduced koma-letter specif author and email. * ox-koma-letter.el (koma-letter): set org-koma-special-content to nil when exporting The former is needed so that author/email can be set in a LCO file. TINYCHANGE --- contrib/lisp/ox-koma-letter.el | 49 +++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el index 020df52..92cf13a 100644 --- a/contrib/lisp/ox-koma-letter.el +++ b/contrib/lisp/ox-koma-letter.el @@ -109,6 +109,12 @@ :group 'org-export-koma-letter :type 'string) +(defcustom org-koma-letter-email user-mail-address + "The default email address stored in the letter." ) + +(defcustom org-koma-letter-author user-full-name + "The default name of the sender." ) + (defcustom org-koma-letter-signature "\\usekomavar{fromname}" "String used as the signature." :group 'org-export-koma-letter @@ -143,7 +149,6 @@ English manual of 2012-07-22)" :group 'org-export-koma-letter) - (defcustom org-koma-letter-use-backaddress t "Print return address in small line above to address." :group 'org-export-koma-letter @@ -179,7 +184,6 @@ Use `foldmarks:true' to activate default fold marks or :group 'org-export-koma-letter :type 'string) - (defconst org-koma-letter-special-tags-after-closing '("PS" "ENCL" "CC") "Headers tags to be inserted after closing") @@ -193,7 +197,7 @@ Use `foldmarks:true' to activate default fold marks or org-koma-letter-special-tags-after-closing) "Header tags with special meaning") -(defvar org-koma-letter-special-content nil "holds special +(defvar org-koma-letter-special-contents nil "holds special content temporarily.") @@ -203,10 +207,10 @@ content temporarily.") (org-export-define-derived-backend 'koma-letter 'latex :options-alist '((:lco "LCO" nil org-koma-letter-class-option-file) - (:sender "AUTHOR" nil user-full-name t) + (:sender "AUTHOR" nil org-koma-letter-author) (:from-address "FROM_ADDRESS" nil org-koma-letter-from-address newline) (:phone-number "PHONE_NUMBER" nil org-koma-letter-phone-number) - (:email "EMAIL" nil user-mail-address t) + (: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) @@ -275,29 +279,31 @@ channel." ;; Thanks, Luis! (defun org-koma-letter--get-tagged-content (tag info) - (cdr (assoc tag org-koma-letter-special-content))) + (cdr (assoc tag org-koma-letter-special-contents))) -(defun org-koma-letter-headline (headline conents info) +(defun org-koma-letter-headline (headline contents info) "Transcode a HEADLINE element from Org to LaTeX. CONTENTS holds the contents of the headline. INFO is a plist holding contextual informatio.n Note that if a headline is tagged with a tag from `org-koma-letter-special-tags' it will not be exported, but -stored in `org-koma-letter-special-content' and included at the +stored in `org-koma-letter-special-contents' and included at the appropriate place." (let* ((tags (and (plist-get info :with-tags) (org-export-get-tags headline info)))) - (if (member (car tags) org-koma-letter-special-tags) - (cond ((member (car tags) '("PS" "ps")) - (progn - (push (cons (car tags) (concat (plist-get info :ps-prefix) contents)) - org-koma-letter-special-content) nil)) - (t (progn - (push (cons (car tags) contents) - org-koma-letter-special-content) nil))) + (if (member (upcase (car tags)) + org-koma-letter-special-tags) + ;; (cond ((member (car tags) '("PS" "ps")) + ;; (progn + ;; (push (cons (car tags) (concat (plist-get info :ps-prefix) contents)) + ;; org-koma-letter-special-contents) nil)) + (progn + (push (cons (upcase (car tags)) contents) + org-koma-letter-special-contents) + nil) contents))) @@ -307,10 +313,9 @@ appropriate place." "Return complete document string after KOMA Scrlttr2 conversion. CONTENTS is the transcoded contents string. INFO is a plist holding export options." - ;; FIXME: instead of setq'ing org-koma-letter-special-content and + ;; 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 ;; as in org-groff... - (setq org-koma-letter-special-content nil) (concat ;; Time-stamp. (and (plist-get info :time-stamp-file) @@ -412,15 +417,14 @@ holding export options." (format "\n\\closing{%s}\n\n" (plist-get info :closing)) (let (after-closing) (dolist (ac org-koma-letter-special-tags-after-closing after-closing) - (let ((x (org-koma-letter--get-tagged-content ac info))) + (let ((x (org-koma-letter--get-tagged-content (upcase ac) info))) (when x (setq after-closing (concat after-closing ;; sometimes LaTeX complains about newlines ;; at the end of macros. Remove them. (replace-regexp-in-string "\n+$" "" - (format "\\%s{%s}" (downcase ac) x))))) - ))) + (format "\\%s{%s}" (downcase ac) x)))))))) ;; Letter end. "\\end{letter}\n" (let ((x (org-koma-letter--get-tagged-content "AFTER_LETTER" info))) @@ -464,6 +468,7 @@ Export is done in a buffer named \"*Org KOMA-LETTER Export*\". It will be displayed if `org-export-show-temporary-export-buffer' is non-nil." (interactive) + (let (org-koma-letter-special-contents) (if async (org-export-async-start (lambda (output) @@ -480,7 +485,7 @@ non-nil." subtreep visible-only body-only ext-plist))) (with-current-buffer outbuf (LaTeX-mode)) (when org-export-show-temporary-export-buffer - (switch-to-buffer-other-window outbuf))))) + (switch-to-buffer-other-window outbuf)))))) ;;;###autoload (defun org-koma-letter-export-to-latex -- 1.8.2.3 ^ permalink raw reply related [flat|nested] 48+ messages in thread
* Re: [patch] ox-koma-letter.el: clean-up/semantic bug [4/4] 2013-05-21 23:23 ` Rasmus @ 2013-05-22 14:39 ` Viktor Rosenfeld 2013-05-22 22:06 ` [PATCH] ox-koma-letter.el: Reintroduce variables removed in commit 832c6fd with proper defaults (was Re: [patch] ox-koma-letter.el: clean-up/semantic bug [4/4]) Viktor Rosenfeld 0 siblings, 1 reply; 48+ messages in thread From: Viktor Rosenfeld @ 2013-05-22 14:39 UTC (permalink / raw) To: Rasmus; +Cc: emacs-orgmode Hi Rasmus, Rasmus wrote: > Viktor Rosenfeld <listuser36@gmail.com> writes: > > > Or 5, keep the change from SENDER to AUTHOR but revert the default > > values to `org-koma-letter-*' variables. (Right now the AUTHOR and EMAIL > > lines could be removed because they duplicate the derived latex > > backend.) > > I once had a teacher who talked about the optimal degree of > conservatism (as well speaking positively about being in the infamoues > ivory tower). 5. is fine with me. So I guess the deal is > 1. default value is the same as in ox-latex. > 2. . . . but it's kept in a seperete variable ox-kl variable. > > > I think that switching from SENDER to AUTHOR, keeping the > > `org-koma-letter-{author,email}' variables in the KOMA backend, but > > setting them per default to `user-full-name' and `user-mail-address', > > would solve both your problems and let me keep LCO files. I would then > > simply set these `org-koma-letter-*' variables to `nil' and document > > this setup in the docstring. I'll see tomorrow if this is feasable. > > Does the attached patch work for you (also with ps tags?) It works, but I noticed the following problem: According to the Emacs documentation `user-mail-address' is only set by Emacs after the initialization process has completed and if it is not explicitly set during initialization [1]. So, the defcustom of org-koma-letter-email does not work as expected if the user has not set `user-mail-address' before. Instead it is set to the empty string, which according to the code setting `user-mail-address' means "not set yet." This can be taking care of by using `after-init-hook' as in the example below. It has the added advantage that the value of `user-mail-address' will be picked up regardless of whether it is set before or after require'ing ox-koma-letter. Note that this creates a slight inconsistency with regard to `user-full-name' which is only picked up correctly if it is set before require'ing ox-koma-letter. I've fixed this by a slightly complicated defcustom definition of `org-koma-letter-author' and another after-init-hook. I've also changed the docstring to indicate what are the default values and added the :group and :type flags again. #+BEGIN_SRC (defcustom org-koma-letter-email user-mail-address "The sender's email address. This variable defaults to the value of `user-mail-address'." :group 'org-export-koma-letter :type 'string) (add-hook 'after-init-hook (lambda () (if (string= org-koma-letter-email "") (setq org-koma-letter-email user-mail-address)))) (defcustom org-koma-letter-author (if (boundp 'org-koma-letter-author) user-full-name ;; Empty string means "not set yet." "") "The sender's name. This variable defaults to the value of `user-full-name'." :group 'org-export-koma-letter :type 'string) (add-hook 'after-init-hook (lambda () (if (string= org-koma-letter-author "") (setq org-koma-letter-author user-full-name)))) #+END_SRC Cheers, Viktor [1] http://www.gnu.org/software/emacs/manual/html_node/elisp/User-Identification.html#User-Identification > > –Rasmus > > -- > Dung makes an excellent fertilizer > >From 92b07bac2d707f01e48796778453b67a9ecd1daa Mon Sep 17 00:00:00 2001 > From: "rasmus.pank" <rasmus.pank@gmail.com> > Date: Wed, 22 May 2013 01:16:54 +0200 > Subject: [PATCH 5/5] Variables for author and email for ox-koma-letter and a > bug fix. > > * ox-koma-letter.el (koma-letter): reintroduced koma-letter > specif author and email. > * ox-koma-letter.el (koma-letter): set > org-koma-special-content to nil when exporting > > The former is needed so that author/email can be set in a LCO file. > > TINYCHANGE > --- > contrib/lisp/ox-koma-letter.el | 49 +++++++++++++++++++++++------------------- > 1 file changed, 27 insertions(+), 22 deletions(-) > > diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el > index 020df52..92cf13a 100644 > --- a/contrib/lisp/ox-koma-letter.el > +++ b/contrib/lisp/ox-koma-letter.el > @@ -109,6 +109,12 @@ > :group 'org-export-koma-letter > :type 'string) > > +(defcustom org-koma-letter-email user-mail-address > + "The default email address stored in the letter." ) > + > +(defcustom org-koma-letter-author user-full-name > + "The default name of the sender." ) > + > (defcustom org-koma-letter-signature "\\usekomavar{fromname}" > "String used as the signature." > :group 'org-export-koma-letter > @@ -143,7 +149,6 @@ English manual of 2012-07-22)" > :group 'org-export-koma-letter) > > > - > (defcustom org-koma-letter-use-backaddress t > "Print return address in small line above to address." > :group 'org-export-koma-letter > @@ -179,7 +184,6 @@ Use `foldmarks:true' to activate default fold marks or > :group 'org-export-koma-letter > :type 'string) > > - > (defconst org-koma-letter-special-tags-after-closing > '("PS" "ENCL" "CC") > "Headers tags to be inserted after closing") > @@ -193,7 +197,7 @@ Use `foldmarks:true' to activate default fold marks or > org-koma-letter-special-tags-after-closing) > "Header tags with special meaning") > > -(defvar org-koma-letter-special-content nil "holds special > +(defvar org-koma-letter-special-contents nil "holds special > content temporarily.") > > > @@ -203,10 +207,10 @@ content temporarily.") > (org-export-define-derived-backend 'koma-letter 'latex > :options-alist > '((:lco "LCO" nil org-koma-letter-class-option-file) > - (:sender "AUTHOR" nil user-full-name t) > + (:sender "AUTHOR" nil org-koma-letter-author) > (:from-address "FROM_ADDRESS" nil org-koma-letter-from-address newline) > (:phone-number "PHONE_NUMBER" nil org-koma-letter-phone-number) > - (:email "EMAIL" nil user-mail-address t) > + (: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) > @@ -275,29 +279,31 @@ channel." > ;; Thanks, Luis! > > (defun org-koma-letter--get-tagged-content (tag info) > - (cdr (assoc tag org-koma-letter-special-content))) > + (cdr (assoc tag org-koma-letter-special-contents))) > > > -(defun org-koma-letter-headline (headline conents info) > +(defun org-koma-letter-headline (headline contents info) > "Transcode a HEADLINE element from Org to LaTeX. > CONTENTS holds the contents of the headline. INFO is a plist > holding contextual informatio.n > > Note that if a headline is tagged with a tag from > `org-koma-letter-special-tags' it will not be exported, but > -stored in `org-koma-letter-special-content' and included at the > +stored in `org-koma-letter-special-contents' and included at the > appropriate place." > (let* > ((tags (and (plist-get info :with-tags) > (org-export-get-tags headline info)))) > - (if (member (car tags) org-koma-letter-special-tags) > - (cond ((member (car tags) '("PS" "ps")) > - (progn > - (push (cons (car tags) (concat (plist-get info :ps-prefix) contents)) > - org-koma-letter-special-content) nil)) > - (t (progn > - (push (cons (car tags) contents) > - org-koma-letter-special-content) nil))) > + (if (member (upcase (car tags)) > + org-koma-letter-special-tags) > + ;; (cond ((member (car tags) '("PS" "ps")) > + ;; (progn > + ;; (push (cons (car tags) (concat (plist-get info :ps-prefix) contents)) > + ;; org-koma-letter-special-contents) nil)) > + (progn > + (push (cons (upcase (car tags)) contents) > + org-koma-letter-special-contents) > + nil) > contents))) > > > @@ -307,10 +313,9 @@ appropriate place." > "Return complete document string after KOMA Scrlttr2 conversion. > CONTENTS is the transcoded contents string. INFO is a plist > holding export options." > - ;; FIXME: instead of setq'ing org-koma-letter-special-content and > + ;; 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 > ;; as in org-groff... > - (setq org-koma-letter-special-content nil) > (concat > ;; Time-stamp. > (and (plist-get info :time-stamp-file) > @@ -412,15 +417,14 @@ holding export options." > (format "\n\\closing{%s}\n\n" (plist-get info :closing)) > (let (after-closing) > (dolist (ac org-koma-letter-special-tags-after-closing after-closing) > - (let ((x (org-koma-letter--get-tagged-content ac info))) > + (let ((x (org-koma-letter--get-tagged-content (upcase ac) info))) > (when x (setq after-closing > (concat after-closing > ;; sometimes LaTeX complains about newlines > ;; at the end of macros. Remove them. > (replace-regexp-in-string > "\n+$" "" > - (format "\\%s{%s}" (downcase ac) x))))) > - ))) > + (format "\\%s{%s}" (downcase ac) x)))))))) > ;; Letter end. > "\\end{letter}\n" > (let ((x (org-koma-letter--get-tagged-content "AFTER_LETTER" info))) > @@ -464,6 +468,7 @@ Export is done in a buffer named \"*Org KOMA-LETTER Export*\". It > will be displayed if `org-export-show-temporary-export-buffer' is > non-nil." > (interactive) > + (let (org-koma-letter-special-contents) > (if async > (org-export-async-start > (lambda (output) > @@ -480,7 +485,7 @@ non-nil." > subtreep visible-only body-only ext-plist))) > (with-current-buffer outbuf (LaTeX-mode)) > (when org-export-show-temporary-export-buffer > - (switch-to-buffer-other-window outbuf))))) > + (switch-to-buffer-other-window outbuf)))))) > > ;;;###autoload > (defun org-koma-letter-export-to-latex > -- > 1.8.2.3 > ^ permalink raw reply [flat|nested] 48+ messages in thread
* [PATCH] ox-koma-letter.el: Reintroduce variables removed in commit 832c6fd with proper defaults (was Re: [patch] ox-koma-letter.el: clean-up/semantic bug [4/4]) 2013-05-22 14:39 ` Viktor Rosenfeld @ 2013-05-22 22:06 ` Viktor Rosenfeld 2013-05-25 5:13 ` Robert Klein 0 siblings, 1 reply; 48+ messages in thread From: Viktor Rosenfeld @ 2013-05-22 22:06 UTC (permalink / raw) To: emacs-orgmode; +Cc: Rasmus [-- Attachment #1: Type: text/plain, Size: 2488 bytes --] Hi Rasmus, Viktor Rosenfeld wrote: > Hi Rasmus, > > Rasmus wrote: > > > Viktor Rosenfeld <listuser36@gmail.com> writes: > > > > > Or 5, keep the change from SENDER to AUTHOR but revert the default > > > values to `org-koma-letter-*' variables. (Right now the AUTHOR and EMAIL > > > lines could be removed because they duplicate the derived latex > > > backend.) > > > > I once had a teacher who talked about the optimal degree of > > conservatism (as well speaking positively about being in the infamoues > > ivory tower). 5. is fine with me. So I guess the deal is > > 1. default value is the same as in ox-latex. > > 2. . . . but it's kept in a seperete variable ox-kl variable. > > > > > I think that switching from SENDER to AUTHOR, keeping the > > > `org-koma-letter-{author,email}' variables in the KOMA backend, but > > > setting them per default to `user-full-name' and `user-mail-address', > > > would solve both your problems and let me keep LCO files. I would then > > > simply set these `org-koma-letter-*' variables to `nil' and document > > > this setup in the docstring. I'll see tomorrow if this is feasable. > > > > Does the attached patch work for you (also with ps tags?) > > It works, but I noticed the following problem: According to the Emacs > documentation `user-mail-address' is only set by Emacs after the > initialization process has completed and if it is not explicitly set > during initialization [1]. So, the defcustom of org-koma-letter-email > does not work as expected if the user has not set `user-mail-address' > before. Instead it is set to the empty string, which according to the > code setting `user-mail-address' means "not set yet." > > This can be taking care of by using `after-init-hook' as in the example > below. It has the added advantage that the value of `user-mail-address' > will be picked up regardless of whether it is set before or after > require'ing ox-koma-letter. > > Note that this creates a slight inconsistency with regard to > `user-full-name' which is only picked up correctly if it is set before > require'ing ox-koma-letter. I've fixed this by a slightly complicated > defcustom definition of `org-koma-letter-author' and another > after-init-hook. > > I've also changed the docstring to indicate what are the default values > and added the :group and :type flags again. I've put my changes into a patch against the current master (commit 06cdb2d2). Could you check it with your setup? Cheers, Viktor [-- Attachment #2: 0001-ox-koma-letter.el-Reintroduce-variables-removed-in-c.patch --] [-- Type: text/plain, Size: 4180 bytes --] From 271c6548aa1f0b61763c30b7116dbb3325364683 Mon Sep 17 00:00:00 2001 From: Viktor Rosenfeld <listuser36@gmail.com> Date: Thu, 23 May 2013 00:00:38 +0200 Subject: [PATCH] ox-koma-letter.el: Reintroduce variables removed in commit 832c6fd with proper defaults. * ox-koma-letter.el (org-koma-letter-author): Dedicated variable to set the KOMA variable fromname; initialized to `user-full-name' using `after-init-hook' if not set explicitly. (org-koma-letter-email): Dedicated variable to set the KOMA variable fromemail; initialized to `user-mail-address' using `after-init-hook' if not set explicitly. (koma-letter): Use dedicated variables for AUTHOR and EMAIL. (org-koma-letter-template): Variable name change. Setting the variables `org-koma-letter-author' and `org-koma-letter-email' to the values of `user-full-name' and `user-mail-address' respectively, allows the user to skip =#+AUTHOR:= and =#+EMAIL:= lines when configuring a letter. However, if the user wishes to set this information in LCO files, these variables need to be set to nil. --- contrib/lisp/ox-koma-letter.el | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el index 4318db1..b56dadb 100644 --- a/contrib/lisp/ox-koma-letter.el +++ b/contrib/lisp/ox-koma-letter.el @@ -80,6 +80,32 @@ :group 'org-export-koma-letter :type 'string) +(defcustom org-koma-letter-author (if (boundp 'org-koma-letter-author) + user-full-name + ;; Empty string means "not set yet." + "") + "The sender's name. + +This variable defaults to the value of `user-full-name'." + :group 'org-export-koma-letter + :type 'string) + +(add-hook 'after-init-hook + (lambda () + (if (string= org-koma-letter-author "") + (setq org-koma-letter-author user-full-name)))) + +(defcustom org-koma-letter-email user-mail-address + "The sender's email address. + +This variable defaults to the value of `user-mail-address'." + :group 'org-export-koma-letter + :type 'string) + +(add-hook 'after-init-hook + (lambda () + (if (string= org-koma-letter-email "") + (setq org-koma-letter-email user-mail-address)))) (defcustom org-koma-letter-from-address nil "Sender's address, as a string." @@ -91,7 +117,6 @@ :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 @@ -153,10 +178,10 @@ Use `foldmarks:true' to activate default fold marks or (org-export-define-derived-backend 'koma-letter 'latex :options-alist '((:lco "LCO" nil org-koma-letter-class-option-file) - (:sender "AUTHOR" nil user-full-name t) + (:author "AUTHOR" nil org-koma-letter-author t) (:from-address "FROM_ADDRESS" nil org-koma-letter-from-address newline) (:phone-number "PHONE_NUMBER" nil org-koma-letter-phone-number) - (:email "EMAIL" nil user-mail-address t) + (:email "EMAIL" nil org-koma-letter-email t) (:to-address "TO_ADDRESS" nil nil newline) (:place "PLACE" nil org-koma-letter-place) (:opening "OPENING" nil org-koma-letter-opening) @@ -250,7 +275,7 @@ holding export options." (plist-get info :latex-header-extra)))) info))))) (let ((lco (plist-get info :lco)) - (sender (plist-get info :sender)) + (author (plist-get info :author)) (from-address (plist-get info :from-address)) (phone-number (plist-get info :phone-number)) (email (plist-get info :email)) @@ -264,8 +289,8 @@ holding export options." (setq lco-def (format "%s\\LoadLetterOption{%s}\n" lco-def lco-file))) lco-def)) ;; Define "From" data. - (when sender (format "\\setkomavar{fromname}{%s}\n" - (org-export-data sender info))) + (when author (format "\\setkomavar{fromname}{%s}\n" + (org-export-data author info))) (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)) -- 1.8.2.3 ^ permalink raw reply related [flat|nested] 48+ messages in thread
* Re: [PATCH] ox-koma-letter.el: Reintroduce variables removed in commit 832c6fd with proper defaults (was Re: [patch] ox-koma-letter.el: clean-up/semantic bug [4/4]) 2013-05-22 22:06 ` [PATCH] ox-koma-letter.el: Reintroduce variables removed in commit 832c6fd with proper defaults (was Re: [patch] ox-koma-letter.el: clean-up/semantic bug [4/4]) Viktor Rosenfeld @ 2013-05-25 5:13 ` Robert Klein 2013-05-25 8:05 ` Viktor Rosenfeld 0 siblings, 1 reply; 48+ messages in thread From: Robert Klein @ 2013-05-25 5:13 UTC (permalink / raw) To: emacs-orgmode, Rasmus Hi, FWIW, from a users view it would be nice if: - Use Author/Email information from org file - If not present use information from LCO file - if neither org file nor LCO file has any information use user-full-name and user-email-address Could this be solved by having several e.g. `setkomavar{fromname}' and so on in the tex file, so is created as follows: if no #+AUTHOR in org-file and user-full-name is set: add user-full-name if #+LCO(s) in org-file: add LCO file(s) if #+AUTHOR in org-file: add \setkomavar{fromname}{#+AUTHOR} .... same for email add \setkomavar{signature}{\usekomavar{fromname}} so the result tex file may have: \setkomavar{fromname}{Hans Wurst} \setkomavar{fromemail}{hans_wurst@example.com} ... \setkomavar{fromname}{Reiner Zufall} \setkomavar{fromemail}{reiner_zufall@example.com} \setkomavar{signature}{\usekomavar{fromname}} This probably isn't a `clean' solution, but should work without a need to grep LCO files. Best regards Robert On 05/23/2013 12:06 AM, Viktor Rosenfeld wrote: > Hi Rasmus, > > Viktor Rosenfeld wrote: > >> Hi Rasmus, >> >> Rasmus wrote: >> >>> Viktor Rosenfeld <listuser36@gmail.com> writes: >>> >>>> Or 5, keep the change from SENDER to AUTHOR but revert the default >>>> values to `org-koma-letter-*' variables. (Right now the AUTHOR and EMAIL >>>> lines could be removed because they duplicate the derived latex >>>> backend.) >>> >>> I once had a teacher who talked about the optimal degree of >>> conservatism (as well speaking positively about being in the infamoues >>> ivory tower). 5. is fine with me. So I guess the deal is >>> 1. default value is the same as in ox-latex. >>> 2. . . . but it's kept in a seperete variable ox-kl variable. >>> >>>> I think that switching from SENDER to AUTHOR, keeping the >>>> `org-koma-letter-{author,email}' variables in the KOMA backend, but >>>> setting them per default to `user-full-name' and `user-mail-address', >>>> would solve both your problems and let me keep LCO files. I would then >>>> simply set these `org-koma-letter-*' variables to `nil' and document >>>> this setup in the docstring. I'll see tomorrow if this is feasable. >>> >>> Does the attached patch work for you (also with ps tags?) >> >> It works, but I noticed the following problem: According to the Emacs >> documentation `user-mail-address' is only set by Emacs after the >> initialization process has completed and if it is not explicitly set >> during initialization [1]. So, the defcustom of org-koma-letter-email >> does not work as expected if the user has not set `user-mail-address' >> before. Instead it is set to the empty string, which according to the >> code setting `user-mail-address' means "not set yet." >> >> This can be taking care of by using `after-init-hook' as in the example >> below. It has the added advantage that the value of `user-mail-address' >> will be picked up regardless of whether it is set before or after >> require'ing ox-koma-letter. >> >> Note that this creates a slight inconsistency with regard to >> `user-full-name' which is only picked up correctly if it is set before >> require'ing ox-koma-letter. I've fixed this by a slightly complicated >> defcustom definition of `org-koma-letter-author' and another >> after-init-hook. >> >> I've also changed the docstring to indicate what are the default values >> and added the :group and :type flags again. > > I've put my changes into a patch against the current master (commit > 06cdb2d2). Could you check it with your setup? > > Cheers, > Viktor > ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: [PATCH] ox-koma-letter.el: Reintroduce variables removed in commit 832c6fd with proper defaults (was Re: [patch] ox-koma-letter.el: clean-up/semantic bug [4/4]) 2013-05-25 5:13 ` Robert Klein @ 2013-05-25 8:05 ` Viktor Rosenfeld 2013-05-25 9:20 ` Alan Schmitt 0 siblings, 1 reply; 48+ messages in thread From: Viktor Rosenfeld @ 2013-05-25 8:05 UTC (permalink / raw) To: Robert Klein; +Cc: emacs-orgmode, Rasmus Hi Robert, Robert Klein wrote: > Hi, > > FWIW, from a users view it would be nice if: > > - Use Author/Email information from org file > - If not present use information from LCO file > - if neither org file nor LCO file has any information use > user-full-name and user-email-address > > Could this be solved by having several e.g. `setkomavar{fromname}' > and so on in the tex file, so is created as follows: > > > if no #+AUTHOR in org-file and user-full-name is set: > add user-full-name > if #+LCO(s) in org-file: > add LCO file(s) > if #+AUTHOR in org-file: > add \setkomavar{fromname}{#+AUTHOR} > .... same for email > add \setkomavar{signature}{\usekomavar{fromname}} This is what is implemented by the latest patch (http://thread.gmane.org/gmane.emacs.orgmode/72430/focus=72525). > so the result tex file may have: > > > \setkomavar{fromname}{Hans Wurst} > \setkomavar{fromemail}{hans_wurst@example.com} > ... > \setkomavar{fromname}{Reiner Zufall} > \setkomavar{fromemail}{reiner_zufall@example.com} > \setkomavar{signature}{\usekomavar{fromname}} Why do you repeat fromname and fromemail in your example? Cheers, Viktor > This probably isn't a `clean' solution, but should work without a need > to grep LCO files. > > Best regards > Robert > > > On 05/23/2013 12:06 AM, Viktor Rosenfeld wrote: > > Hi Rasmus, > > > > Viktor Rosenfeld wrote: > > > >> Hi Rasmus, > >> > >> Rasmus wrote: > >> > >>> Viktor Rosenfeld <listuser36@gmail.com> writes: > >>> > >>>> Or 5, keep the change from SENDER to AUTHOR but revert the default > >>>> values to `org-koma-letter-*' variables. (Right now the AUTHOR and EMAIL > >>>> lines could be removed because they duplicate the derived latex > >>>> backend.) > >>> > >>> I once had a teacher who talked about the optimal degree of > >>> conservatism (as well speaking positively about being in the infamoues > >>> ivory tower). 5. is fine with me. So I guess the deal is > >>> 1. default value is the same as in ox-latex. > >>> 2. . . . but it's kept in a seperete variable ox-kl variable. > >>> > >>>> I think that switching from SENDER to AUTHOR, keeping the > >>>> `org-koma-letter-{author,email}' variables in the KOMA backend, but > >>>> setting them per default to `user-full-name' and `user-mail-address', > >>>> would solve both your problems and let me keep LCO files. I would then > >>>> simply set these `org-koma-letter-*' variables to `nil' and document > >>>> this setup in the docstring. I'll see tomorrow if this is feasable. > >>> > >>> Does the attached patch work for you (also with ps tags?) > >> > >> It works, but I noticed the following problem: According to the Emacs > >> documentation `user-mail-address' is only set by Emacs after the > >> initialization process has completed and if it is not explicitly set > >> during initialization [1]. So, the defcustom of org-koma-letter-email > >> does not work as expected if the user has not set `user-mail-address' > >> before. Instead it is set to the empty string, which according to the > >> code setting `user-mail-address' means "not set yet." > >> > >> This can be taking care of by using `after-init-hook' as in the example > >> below. It has the added advantage that the value of `user-mail-address' > >> will be picked up regardless of whether it is set before or after > >> require'ing ox-koma-letter. > >> > >> Note that this creates a slight inconsistency with regard to > >> `user-full-name' which is only picked up correctly if it is set before > >> require'ing ox-koma-letter. I've fixed this by a slightly complicated > >> defcustom definition of `org-koma-letter-author' and another > >> after-init-hook. > >> > >> I've also changed the docstring to indicate what are the default values > >> and added the :group and :type flags again. > > > > I've put my changes into a patch against the current master (commit > > 06cdb2d2). Could you check it with your setup? > > > > Cheers, > > Viktor > > > > ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: [PATCH] ox-koma-letter.el: Reintroduce variables removed in commit 832c6fd with proper defaults (was Re: [patch] ox-koma-letter.el: clean-up/semantic bug [4/4]) 2013-05-25 8:05 ` Viktor Rosenfeld @ 2013-05-25 9:20 ` Alan Schmitt 2013-05-25 13:57 ` Rasmus 0 siblings, 1 reply; 48+ messages in thread From: Alan Schmitt @ 2013-05-25 9:20 UTC (permalink / raw) To: Viktor Rosenfeld; +Cc: emacs-orgmode, Robert Klein, Rasmus Hello, Viktor Rosenfeld writes: > Hi Robert, > > Robert Klein wrote: > >> Hi, >> >> FWIW, from a users view it would be nice if: >> >> - Use Author/Email information from org file >> - If not present use information from LCO file >> - if neither org file nor LCO file has any information use >> user-full-name and user-email-address >> >> Could this be solved by having several e.g. `setkomavar{fromname}' >> and so on in the tex file, so is created as follows: >> >> >> if no #+AUTHOR in org-file and user-full-name is set: >> add user-full-name >> if #+LCO(s) in org-file: >> add LCO file(s) >> if #+AUTHOR in org-file: >> add \setkomavar{fromname}{#+AUTHOR} >> .... same for email >> add \setkomavar{signature}{\usekomavar{fromname}} > > This is what is implemented by the latest patch > (http://thread.gmane.org/gmane.emacs.orgmode/72430/focus=72525). I'm waiting for Rasmus's confirmation that it works for him before committing it. Alan ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: [PATCH] ox-koma-letter.el: Reintroduce variables removed in commit 832c6fd with proper defaults (was Re: [patch] ox-koma-letter.el: clean-up/semantic bug [4/4]) 2013-05-25 9:20 ` Alan Schmitt @ 2013-05-25 13:57 ` Rasmus 2013-05-25 17:03 ` Viktor Rosenfeld 2013-05-25 20:51 ` [PATCH] ox-koma-letter.el: Reintroduce variables removed in commit 832c6fd with proper defaults (was Re: [patch] ox-koma-letter.el: clean-up/semantic bug [4/4]) Robert Klein 0 siblings, 2 replies; 48+ messages in thread From: Rasmus @ 2013-05-25 13:57 UTC (permalink / raw) To: emacs-orgmode Alan Schmitt <alan.schmitt@polytechnique.org> writes: > Hello, > > Viktor Rosenfeld writes: > >> Hi Robert, >> >> Robert Klein wrote: >> >>> Hi, >>> >>> FWIW, from a users view it would be nice if: >>> >>> - Use Author/Email information from org file >>> - If not present use information from LCO file >>> - if neither org file nor LCO file has any information use >>> user-full-name and user-email-address >>> >>> Could this be solved by having several e.g. `setkomavar{fromname}' >>> and so on in the tex file, so is created as follows: I'd go with 'no'. It's not aesthetically pleasing and I don't want my output to look like LyX. When feasible we should go for beautiful output. This isn't always the case at the moment, but still. >>> if no #+AUTHOR in org-file and user-full-name is set: >>> add user-full-name >>> if #+LCO(s) in org-file: >>> add LCO file(s) >>> if #+AUTHOR in org-file: >>> add \setkomavar{fromname}{#+AUTHOR} >>> .... same for email Currently the ordering is: #+AUTHOR > #+LCO and AUTHOR default to (user-full-name). On a side-note, Viktor: this seems to be the default in scrletter anyway: >>> add \setkomavar{signature}{\usekomavar{fromname}} Could we remove it? I'd like us to get to a more clean template (C-e # koma-letter RET). >> This is what is implemented by the latest patch >> (http://thread.gmane.org/gmane.emacs.orgmode/72430/focus=72525). > > I'm waiting for Rasmus's confirmation that it works for him before > committing it. Thanks and sorry for the wait. No it didn't work for me. My user name was always overwritten by "". . . I couldn't figure out why. I've attached a patch that work for me (it goes on top of Viktor's patch 148c737ae79f3a98d8e93147c2d0ec0db3a2389a). It allows for nil and it gets up-to-date default values by default. In my book it's a bit more clean 'cause it doesn't rely on hooks. It does, introduce a new helper function to distinguish between a function value (which are default for the two variables) and a string value (and nil for that matter). I don't know if this is undesirable. It would crash if you set the variables to a symbol that isn't nil and isn't a function. It seems to work in mine and Viktor's use-case (to the best of my testing ability). –Rasmus -- ⠠⠵ ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: [PATCH] ox-koma-letter.el: Reintroduce variables removed in commit 832c6fd with proper defaults (was Re: [patch] ox-koma-letter.el: clean-up/semantic bug [4/4]) 2013-05-25 13:57 ` Rasmus @ 2013-05-25 17:03 ` Viktor Rosenfeld 2013-05-25 17:48 ` [PATCH][ox-koma-letter]: sender, email and cleanup (was: [PATCH] ox-koma-letter.el: Reintroduce variables removed in commit 832c6fd with proper defaults) Rasmus 2013-05-25 20:51 ` [PATCH] ox-koma-letter.el: Reintroduce variables removed in commit 832c6fd with proper defaults (was Re: [patch] ox-koma-letter.el: clean-up/semantic bug [4/4]) Robert Klein 1 sibling, 1 reply; 48+ messages in thread From: Viktor Rosenfeld @ 2013-05-25 17:03 UTC (permalink / raw) To: Rasmus; +Cc: alan.schmitt, emacs-orgmode Hi Rasmus, Rasmus wrote: > The following message is a courtesy copy of an article > that has been posted to gmane.emacs.orgmode as well. > > Alan Schmitt <alan.schmitt@polytechnique.org> writes: > > > Hello, > > > > Viktor Rosenfeld writes: > > > >> Hi Robert, > >> > >> Robert Klein wrote: > >> > >>> Hi, > >>> > >>> FWIW, from a users view it would be nice if: > >>> > >>> - Use Author/Email information from org file > >>> - If not present use information from LCO file > >>> - if neither org file nor LCO file has any information use > >>> user-full-name and user-email-address > >>> > >>> Could this be solved by having several e.g. `setkomavar{fromname}' > >>> and so on in the tex file, so is created as follows: > > I'd go with 'no'. It's not aesthetically pleasing and I don't want my > output to look like LyX. When feasible we should go for beautiful > output. This isn't always the case at the moment, but still. I agree that there should not be multiple instances of, e.g., \setkomavar{fromname} in the TeX file. I must have overlooked that bit in the original mail. > On a side-note, Viktor: this seems to be the default in scrletter > anyway: > >>> add \setkomavar{signature}{\usekomavar{fromname}} > Could we remove it? I'd like us to get to a more clean template (C-e > # koma-letter RET). I think so, yes. > >> This is what is implemented by the latest patch > >> (http://thread.gmane.org/gmane.emacs.orgmode/72430/focus=72525). > > > > I'm waiting for Rasmus's confirmation that it works for him before > > committing it. > > Thanks and sorry for the wait. No it didn't work for me. My user > name was always overwritten by "". . . I couldn't figure out why. Hmm, that's too bad. I tested it pretty thoroughly. Could you maybe trace the contents of the variable by adding calls to message in various places? > I've attached a patch that work for me (it goes on top of Viktor's > patch 148c737ae79f3a98d8e93147c2d0ec0db3a2389a). It allows for nil > and it gets up-to-date default values by default. In my book it's a > bit more clean 'cause it doesn't rely on hooks. It does, introduce a > new helper function to distinguish between a function value (which are > default for the two variables) and a string value (and nil for that > matter). I don't know if this is undesirable. It would crash if you > set the variables to a symbol that isn't nil and isn't a function. Did you send the patch? I did not receive it and it's not available on gmane. Cheers, Viktor > > It seems to work in mine and Viktor's use-case (to the best of my > testing ability). > > –Rasmus > > -- > ⠠⠵ > ^ permalink raw reply [flat|nested] 48+ messages in thread
* [PATCH][ox-koma-letter]: sender, email and cleanup (was: [PATCH] ox-koma-letter.el: Reintroduce variables removed in commit 832c6fd with proper defaults) 2013-05-25 17:03 ` Viktor Rosenfeld @ 2013-05-25 17:48 ` Rasmus 2013-05-25 21:27 ` [PATCH][ox-koma-letter]: sender, email and cleanup Rasmus 2013-05-26 10:54 ` [PATCH][ox-koma-letter]: sender, email and cleanup (was: [PATCH] ox-koma-letter.el: Reintroduce variables removed in commit 832c6fd with proper defaults) Viktor Rosenfeld 0 siblings, 2 replies; 48+ messages in thread From: Rasmus @ 2013-05-25 17:48 UTC (permalink / raw) To: emacs-orgmode; +Cc: alan.schmitt [-- Attachment #1: Type: text/plain, Size: 1445 bytes --] Dear Viktor and Alan, > Hmm, that's too bad. I tested it pretty thoroughly. Could you maybe > trace the contents of the variable by adding calls to message in > various places? I tried to figure it out. For some reason it kept resetting my name to "". > Did you send the patch? I did not receive it and it's not available on > gmane. My apology. It should inform me when something is supposed to be attached but isn't. I've attached them this time so if they are not here now something funky is going on that I'm not in control of. Attached are three patches that goes on top of Viktor's latest patch (I've also attached it here since I rebased stuff and might have changed it by accident). 1. Viktor's latest patch. 2. The patch describe above that gets user name and email and works on my system. . . 3. Cleaning up special-tags functions introduced in ec108f4c3507ed546a564a48b7379355a65aa9f4. It works a lot better now and some of the mess in the template is moved to other functions. 4. Sets defcustom org-koma-letter-signature nil since that corresponds to default scrlttr2 behavior anyway (p. 183 in the manual). Re 4.: I'd like to do something similar to org-koma-letter-subject-format. But I'm not sure how, at the moment (perhaps make t the default and associate it with the current default list). –Rasmus -- This is the kind of tedious nonsense up with which I will not put [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-ox-koma-letter.el-Reintroduce-variables-removed-in-c.patch --] [-- Type: text/x-patch, Size: 4160 bytes --] From bbaf9a6ddd75368b2143e6b8fb50be64bd66b50d Mon Sep 17 00:00:00 2001 From: Viktor Rosenfeld <listuser36@gmail.com> Date: Thu, 23 May 2013 00:00:38 +0200 Subject: [PATCH 1/4] ox-koma-letter.el: Reintroduce variables removed in commit 832c6fd with proper defaults. * ox-koma-letter.el (org-koma-letter-author): Dedicated variable to set the KOMA variable fromname; initialized to `user-full-name' using `after-init-hook' if not set explicitly. (org-koma-letter-email): Dedicated variable to set the KOMA variable fromemail; initialized to `user-mail-address' using `after-init-hook' if not set explicitly. (koma-letter): Use dedicated variables for AUTHOR and EMAIL. (org-koma-letter-template): Variable name change. Setting the variables `org-koma-letter-author' and `org-koma-letter-email' to the values of `user-full-name' and `user-mail-address' respectively, allows the user to skip =#+AUTHOR:= and =#+EMAIL:= lines when configuring a letter. However, if the user wishes to set this information in LCO files, these variables need to be set to nil. --- contrib/lisp/ox-koma-letter.el | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el index 92cf13a..24c1ac5 100644 --- a/contrib/lisp/ox-koma-letter.el +++ b/contrib/lisp/ox-koma-letter.el @@ -82,6 +82,32 @@ :group 'org-export-koma-letter :type 'string) +(defcustom org-koma-letter-author (if (boundp 'org-koma-letter-author) + user-full-name + ;; Empty string means "not set yet." + "") + "The sender's name. + +This variable defaults to the value of `user-full-name'." + :group 'org-export-koma-letter + :type 'string) + +(add-hook 'after-init-hook + (lambda () + (if (string= org-koma-letter-author "") + (setq org-koma-letter-author user-full-name)))) + +(defcustom org-koma-letter-email user-mail-address + "The sender's email address. + +This variable defaults to the value of `user-mail-address'." + :group 'org-export-koma-letter + :type 'string) + +(add-hook 'after-init-hook + (lambda () + (if (string= org-koma-letter-email "") + (setq org-koma-letter-email user-mail-address)))) (defcustom org-koma-letter-from-address nil "Sender's address, as a string." @@ -93,7 +119,6 @@ :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 @@ -207,10 +232,10 @@ content temporarily.") (org-export-define-derived-backend 'koma-letter 'latex :options-alist '((:lco "LCO" nil org-koma-letter-class-option-file) - (:sender "AUTHOR" nil org-koma-letter-author) + (:author "AUTHOR" nil org-koma-letter-author t) (:from-address "FROM_ADDRESS" nil org-koma-letter-from-address newline) (:phone-number "PHONE_NUMBER" nil org-koma-letter-phone-number) - (:email "EMAIL" nil org-koma-letter-email) + (:email "EMAIL" nil org-koma-letter-email t) (:to-address "TO_ADDRESS" nil nil newline) (:place "PLACE" nil org-koma-letter-place) (:opening "OPENING" nil org-koma-letter-opening) @@ -343,7 +368,7 @@ holding export options." (plist-get info :latex-header-extra)))) info))))) (let ((lco (plist-get info :lco)) - (sender (plist-get info :sender)) + (author (plist-get info :author)) (from-address (plist-get info :from-address)) (phone-number (plist-get info :phone-number)) (email (plist-get info :email)) @@ -357,8 +382,8 @@ holding export options." (setq lco-def (format "%s\\LoadLetterOption{%s}\n" lco-def lco-file))) lco-def)) ;; Define "From" data. - (when sender (format "\\setkomavar{fromname}{%s}\n" - (org-export-data sender info))) + (when author (format "\\setkomavar{fromname}{%s}\n" + (org-export-data author info))) (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)) -- 1.8.2.3 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #3: 0002-Trying-to-get-good-default-for-email-and-author.patch --] [-- Type: text/x-patch, Size: 4784 bytes --] From 3df51bf5a57eb9d3a96fc4742a1b4b16998d701d Mon Sep 17 00:00:00 2001 From: "rasmus.pank" <rasmus.pank@gmail.com> Date: Sat, 25 May 2013 15:31:45 +0200 Subject: [PATCH 2/4] Trying to get good default for email and author. * ox-koma-letter.el (org-koma-letter-author): defaults to a function that returns =`user-full-name'= * ox-koma-letter.el (org-koma-letter-email): defaults to a function that returns =`user-mail-address'= With the old after-init-hook method my user name was always set to "". Now org-koma-letter will (i) allow for default nil values (good if you use LCO files); (ii) default to =`user-full-name'= and =`user-mail-address'= like =ox-latex.el=. These values are obtained on-the-fly. The two variables in question can also be strings or functions returning strings. --- contrib/lisp/ox-koma-letter.el | 58 ++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el index 24c1ac5..c8be5ab 100644 --- a/contrib/lisp/ox-koma-letter.el +++ b/contrib/lisp/ox-koma-letter.el @@ -82,32 +82,30 @@ :group 'org-export-koma-letter :type 'string) -(defcustom org-koma-letter-author (if (boundp 'org-koma-letter-author) - user-full-name - ;; Empty string means "not set yet." - "") +(defcustom org-koma-letter-author 'user-full-name "The sender's name. -This variable defaults to the value of `user-full-name'." +This variable defaults to calling the function `user-full-name' +which just returns the current `user-full-name'. Alternatively a +string, nil or a function may be given. Functions must return a +string." :group 'org-export-koma-letter - :type 'string) - -(add-hook 'after-init-hook - (lambda () - (if (string= org-koma-letter-author "") - (setq org-koma-letter-author user-full-name)))) + :type '(radio (function-item user-full-name) + (string) + (function) + (const nil))) -(defcustom org-koma-letter-email user-mail-address +(defcustom org-koma-letter-email 'org-koma-letter-email "The sender's email address. -This variable defaults to the value of `user-mail-address'." +This variable defaults to the value `org-koma-letter-email' which +returns `user-mail-address'. Alternatively a string, nil or a +function may be given. Functions must return a string." :group 'org-export-koma-letter - :type 'string) - -(add-hook 'after-init-hook - (lambda () - (if (string= org-koma-letter-email "") - (setq org-koma-letter-email user-mail-address)))) + :type '(radio (function-item org-koma-letter-email) + (string) + (function) + (const nil))) (defcustom org-koma-letter-from-address nil "Sender's address, as a string." @@ -134,12 +132,6 @@ This variable defaults to the value of `user-mail-address'." :group 'org-export-koma-letter :type 'string) -(defcustom org-koma-letter-email user-mail-address - "The default email address stored in the letter." ) - -(defcustom org-koma-letter-author user-full-name - "The default name of the sender." ) - (defcustom org-koma-letter-signature "\\usekomavar{fromname}" "String used as the signature." :group 'org-export-koma-letter @@ -232,17 +224,16 @@ content temporarily.") (org-export-define-derived-backend 'koma-letter 'latex :options-alist '((:lco "LCO" nil org-koma-letter-class-option-file) - (:author "AUTHOR" nil org-koma-letter-author t) + (:author "AUTHOR" nil (org-koma-letter--get-custom org-koma-letter-author) t) (:from-address "FROM_ADDRESS" nil org-koma-letter-from-address newline) (:phone-number "PHONE_NUMBER" nil org-koma-letter-phone-number) - (:email "EMAIL" nil org-koma-letter-email t) + (:email "EMAIL" nil (org-koma-letter--get-custom org-koma-letter-email) t) (: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) (:ps-prefix nil "ps-prefix" org-koma-letter-ps-prefix) - (: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) @@ -266,6 +257,17 @@ content temporarily.") (org-open-file (org-koma-letter-export-to-pdf nil s v b)))))))) \f +;;; Helper functions + +(defun org-koma-letter-email () + "Return the current `user-mail-address'" + user-mail-address) + +(defun org-koma-letter--get-custom (value) + (when value + (cond ((stringp value) value) + ((symbolp value) (funcall value))))) + ;;; Transcode Functions ;;;; Export Block -- 1.8.2.3 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #4: 0003-bug-fix-for-special-headers.patch --] [-- Type: text/x-patch, Size: 8054 bytes --] From 173826ce58954f24b268f09f45e07ac877d751de Mon Sep 17 00:00:00 2001 From: "rasmus.pank" <rasmus.pank@gmail.com> Date: Sat, 25 May 2013 19:08:37 +0200 Subject: [PATCH 3/4] bug-fix for special headers. * ox-koma-letter.el(org-koma-letter-ps-prefix): removed * ox-koma-letter.el(org-koma-letter-special-tags-after-closing): downcased to correspond to actual LaTeX-functions * ox-koma-letter.el(org-koma-letter-special-tags-after-letter): list of headings to be inserted after =\end{letter}= * ox-koma-letter.el(org-koma-letter-special-tags): removed. generated on the go. * ox-koma-letter.el(org-koma-letter-special-contents): special headings are controlled via =:with-after-closing= and =:with-after-letter=. These can also be used for reordering the way headers are inserted. * ox-koma-letter.el: some cleaning up. * ox-koma-letter.el(org-koma-letter--prepare-special-contents-as-macro): new function for inserting macros based on list of special tags. --- contrib/lisp/ox-koma-letter.el | 111 +++++++++++++++++++++++------------------ 1 file changed, 62 insertions(+), 49 deletions(-) diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el index c8be5ab..bbfe168 100644 --- a/contrib/lisp/ox-koma-letter.el +++ b/contrib/lisp/ox-koma-letter.el @@ -196,23 +196,13 @@ Use `foldmarks:true' to activate default fold marks or :group 'org-export-koma-letter :type 'boolean) -(defcustom org-koma-letter-ps-prefix "\\textsc{ps}: " - "The prefix of PS. Used to construct PS as \"PS-SUFFIX PS\"" - :group 'org-export-koma-letter - :type 'string) - (defconst org-koma-letter-special-tags-after-closing - '("PS" "ENCL" "CC") - "Headers tags to be inserted after closing") - -(defconst org-koma-letter-special-tags-other - '("FROM" "AFTER_LETTER") - "Headers tags to be inserted after closing") + '("ps" "encl" "cc") + "Header tags to be inserted after closing") -(defconst org-koma-letter-special-tags - (append org-koma-letter-special-tags-other - org-koma-letter-special-tags-after-closing) - "Header tags with special meaning") +(defconst org-koma-letter-special-tags-after-letter + '("after_letter") + "Header tags to be inserted after closing") (defvar org-koma-letter-special-contents nil "holds special content temporarily.") @@ -233,13 +223,15 @@ content temporarily.") (:opening "OPENING" nil org-koma-letter-opening) (:closing "CLOSING" nil org-koma-letter-closing) (:signature "SIGNATURE" nil org-koma-letter-signature newline) - (:ps-prefix nil "ps-prefix" org-koma-letter-ps-prefix) + (:with-after-closing nil "after-closing-order" + 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-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-after-closing nil "after-closing-order" org-koma-letter-special-tags-after-closing) (:with-subject nil "subject" org-koma-letter-subject-format)) :translate-alist '((export-block . org-koma-letter-export-block) (export-snippet . org-koma-letter-export-snippet) @@ -263,11 +255,47 @@ content temporarily.") "Return the current `user-mail-address'" user-mail-address) +;; The following is taken from/inspired by ox-grof.el +;; Thanks, Luis! + +(defun org-koma-letter--get-tagged-contents (tag) + "Get tagged content from `org-koma-letter-special-contents'" + (cdr (assoc tag org-koma-letter-special-contents))) + (defun org-koma-letter--get-custom (value) + "Determines whether a value is nil, a string or a +function (a symobl). If it is a function it it evaluates it." (when value (cond ((stringp value) value) ((symbolp value) (funcall value))))) + +(defun org-koma-letter--prepare-special-contents-as-macro (a-list &optional keep-newlines no-tag) + "Finds all the components of `org-koma-letter-special-contents' +corresponding to members of the `a-list' and return them as a +string to be formatted. The function is used for inserting +content of speciall headings such as PS. + +If keep-newlines is t newlines will not be removed. If no-tag is +is t the content in `org-koma-letter-special-contents' will not +be wrapped in a macro named whatever the members of a-list are called. +" + (let (output) + (dolist (ac a-list output) + (let + ((x (org-koma-letter--get-tagged-contents ac)) + (regexp (if keep-newlines "" "\\`\n+\\|\n*\\'"))) + (when x + (setq output + (concat + output "\n" + ;; sometimes LaTeX complains about newlines + ;; at the end or beginning of macros. Remove them. + (unless no-tag (format "\\%s{" ac)) + (format "%s" (replace-regexp-in-string regexp "" x)) + (unless no-tag "}") + ))))))) + ;;; Transcode Functions ;;;; Export Block @@ -302,17 +330,12 @@ channel." (org-export-with-backend 'latex keyword contents info)))) -;; The following is taken from/inspired by ox-grof.el -;; Thanks, Luis! - -(defun org-koma-letter--get-tagged-content (tag info) - (cdr (assoc tag org-koma-letter-special-contents))) - +;; Headline (defun org-koma-letter-headline (headline contents info) "Transcode a HEADLINE element from Org to LaTeX. CONTENTS holds the contents of the headline. INFO is a plist -holding contextual informatio.n +holding contextual information. Note that if a headline is tagged with a tag from `org-koma-letter-special-tags' it will not be exported, but @@ -320,16 +343,14 @@ stored in `org-koma-letter-special-contents' and included at the appropriate place." (let* ((tags (and (plist-get info :with-tags) - (org-export-get-tags headline info)))) - (if (member (upcase (car tags)) - org-koma-letter-special-tags) - ;; (cond ((member (car tags) '("PS" "ps")) - ;; (progn - ;; (push (cons (car tags) (concat (plist-get info :ps-prefix) contents)) - ;; org-koma-letter-special-contents) nil)) + (org-export-get-tags headline info))) + (tag (downcase (car tags)))) + (if (member tag + (append (plist-get info :with-after-letter) + (plist-get info :with-after-closing))) (progn - (push (cons (upcase (car tags)) contents) - org-koma-letter-special-contents) + (push (cons tag contents) + org-koma-letter-special-contents) nil) contents))) @@ -441,23 +462,15 @@ holding export options." ;; Letter body. contents ;; Closing. - (format "\n\\closing{%s}\n\n" (plist-get info :closing)) - (let (after-closing) - (dolist (ac org-koma-letter-special-tags-after-closing after-closing) - (let ((x (org-koma-letter--get-tagged-content (upcase ac) info))) - (when x (setq after-closing - (concat after-closing - ;; sometimes LaTeX complains about newlines - ;; at the end of macros. Remove them. - (replace-regexp-in-string - "\n+$" "" - (format "\\%s{%s}" (downcase ac) x)))))))) + (format "\n\\closing{%s}\n" (plist-get info :closing)) + (org-koma-letter--prepare-special-contents-as-macro + (plist-get info :with-after-closing)) ;; Letter end. - "\\end{letter}\n" - (let ((x (org-koma-letter--get-tagged-content "AFTER_LETTER" info))) - (when x (format x))) + "\n\\end{letter}\n" + (org-koma-letter--prepare-special-contents-as-macro + (plist-get info :with-after-letter) t t) ;; Document end. - "\\end{document}" + "\n\\end{document}" )) \f @@ -487,7 +500,7 @@ contents of hidden elements. When optional argument BODY-ONLY is non-nil, only write code between \"\\begin{letter}\" and \"\\end{letter}\". -EXT-PLIST, when provided, is a property list with external +EXT-PLIST, when provided, is a proeprty list with external parameters overriding Org default settings, but still inferior to file-local settings. -- 1.8.2.3 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #5: 0004-change-default-of-org-koma-letter-signature-to-nil.patch --] [-- Type: text/x-patch, Size: 980 bytes --] From 05c5371628af21e5f2a2a10404c4cfc354486ec6 Mon Sep 17 00:00:00 2001 From: "rasmus.pank" <rasmus.pank@gmail.com> Date: Sat, 25 May 2013 19:35:10 +0200 Subject: [PATCH 4/4] change default of org-koma-letter-signature to nil * ox-koma-letter.el(org-koma-letter-signature): set to nil The previoues value corresponds to the default value cf. the the koma manual pp. 183. --- contrib/lisp/ox-koma-letter.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el index bbfe168..4cb402e 100644 --- a/contrib/lisp/ox-koma-letter.el +++ b/contrib/lisp/ox-koma-letter.el @@ -132,7 +132,7 @@ function may be given. Functions must return a string." :group 'org-export-koma-letter :type 'string) -(defcustom org-koma-letter-signature "\\usekomavar{fromname}" +(defcustom org-koma-letter-signature nil "String used as the signature." :group 'org-export-koma-letter :type 'string) -- 1.8.2.3 ^ permalink raw reply related [flat|nested] 48+ messages in thread
* Re: [PATCH][ox-koma-letter]: sender, email and cleanup 2013-05-25 17:48 ` [PATCH][ox-koma-letter]: sender, email and cleanup (was: [PATCH] ox-koma-letter.el: Reintroduce variables removed in commit 832c6fd with proper defaults) Rasmus @ 2013-05-25 21:27 ` Rasmus 2013-05-26 10:58 ` Viktor Rosenfeld 2013-05-26 10:54 ` [PATCH][ox-koma-letter]: sender, email and cleanup (was: [PATCH] ox-koma-letter.el: Reintroduce variables removed in commit 832c6fd with proper defaults) Viktor Rosenfeld 1 sibling, 1 reply; 48+ messages in thread From: Rasmus @ 2013-05-25 21:27 UTC (permalink / raw) To: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 1174 bytes --] Rasmus <rasmus@gmx.us> writes: > 4. Sets defcustom org-koma-letter-signature nil since that > corresponds to default scrlttr2 behavior anyway (p. 183 in the > manual). > > Re 4.: I'd like to do something similar to > org-koma-letter-subject-format. But I'm not sure how, at the moment > (perhaps make t the default and associate it with the current default > list). This patch makes the subject option "easier" although still relying on a list for multiple options (see the description in the patch). The default is t corresponding to do nothing but print komavar subject. I haven't found any bugs but please test it (along with other patches) if time permits. A potential problem is that subject default to the file name and can only be disabled with the option subject:nil. The file name to title convention is bad in ox-latex.el and I think it's if anything worse here. I'd like to make it nil by default. What do you guys think? –Rasmus PS: Perhaps it would it be beneficial to make some test-letter displaying the different scenarios in which we use ox-koma-letter? To make sure that stuff doesn't get broken. -- May the Force be with you [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0005-Only-print-subject-options-when-necessary.patch --] [-- Type: text/x-patch, Size: 2477 bytes --] From 880f99622a4513520d1dd4e110428f18453a3af1 Mon Sep 17 00:00:00 2001 From: "rasmus.pank" <rasmus.pank@gmail.com> Date: Sat, 25 May 2013 20:49:57 +0200 Subject: [PATCH 5/5] Only print subject options when necessary * ox-koma-letter.el (org-koma-letter-subject-format): default is now t * ox-koma-letter.el (org-koma-letter-template): better subject handling. If =#+OPTIONS: subject:(x,y)= then =\KOMAoption{subject}{x, y}=. If =subject:x= then =\KOMAoption{subject}{x}=. If =subject:t= then =\KOMAoption{subject}{...}= is not printed but \setkomavar{subject}{...} is printed. If =subject:nil= neither are printed. --- contrib/lisp/ox-koma-letter.el | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el index 4cb402e..ca20ec7 100644 --- a/contrib/lisp/ox-koma-letter.el +++ b/contrib/lisp/ox-koma-letter.el @@ -137,7 +137,7 @@ function may be given. Functions must return a string." :group 'org-export-koma-letter :type 'string) -(defcustom org-koma-letter-subject-format '("beforeopening" "left" "untitled") +(defcustom org-koma-letter-subject-format t "Use the title as the subject of the letter. At the time of writing the following values are allowed: @@ -162,6 +162,7 @@ English manual of 2012-07-22)" (const "titled") (const "untitled") (const :tag "No export" nil) + (const :tag "Default options" t) (string)) :group 'org-export-koma-letter) @@ -432,20 +433,16 @@ holding export options." "\\begin{document}\n\n" ;; Subject (let* ((with-subject (plist-get info :with-subject)) - (subject-format - (if (member - ;; test if subject-format is t - (cond ((symbolp with-subject) (downcase (symbol-name with-subject))) - ((stringp with-subject) (downcase with-subject)) - (t nil)) - '("true" "t")) - org-koma-letter-subject-format - 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 (if (stringp subject-format) 1 (length subject-format))) + (l (length subject-format)) (y "")) (concat - (when with-subject + (when (and with-subject subject-format) (concat "\\KOMAoption{subject}{" (apply 'format -- 1.8.2.3 ^ permalink raw reply related [flat|nested] 48+ messages in thread
* Re: [PATCH][ox-koma-letter]: sender, email and cleanup 2013-05-25 21:27 ` [PATCH][ox-koma-letter]: sender, email and cleanup Rasmus @ 2013-05-26 10:58 ` Viktor Rosenfeld 2013-05-26 14:38 ` Rasmus 0 siblings, 1 reply; 48+ messages in thread From: Viktor Rosenfeld @ 2013-05-26 10:58 UTC (permalink / raw) To: Rasmus; +Cc: emacs-orgmode Hi Rasmus, Rasmus wrote: > Rasmus <rasmus@gmx.us> writes: > > > 4. Sets defcustom org-koma-letter-signature nil since that > > corresponds to default scrlttr2 behavior anyway (p. 183 in the > > manual). > > > > Re 4.: I'd like to do something similar to > > org-koma-letter-subject-format. But I'm not sure how, at the moment > > (perhaps make t the default and associate it with the current default > > list). > > > This patch makes the subject option "easier" although still relying on > a list for multiple options (see the description in the patch). The > default is t corresponding to do nothing but print komavar subject. > > I haven't found any bugs but please test it (along with other patches) > if time permits. I could not apply this either and I am pressed for time right now. Could you resend a diff against the current master? > A potential problem is that subject default to the file name and can > only be disabled with the option subject:nil. The file name to title > convention is bad in ox-latex.el and I think it's if anything worse > here. I'd like to make it nil by default. What do you guys think? I'm also not a big fan of the title defaulting to the filename. But I think it is a minor issue. What I think is quite useful is setting the subject to the headline of the exported subtree. Wouldn't we also lose this if subject is nil? Cheers, Viktor > > –Rasmus > > PS: Perhaps it would it be beneficial to make some test-letter > displaying the different scenarios in which we use ox-koma-letter? To > make sure that stuff doesn't get broken. > > -- > May the Force be with you > >From 880f99622a4513520d1dd4e110428f18453a3af1 Mon Sep 17 00:00:00 2001 > From: "rasmus.pank" <rasmus.pank@gmail.com> > Date: Sat, 25 May 2013 20:49:57 +0200 > Subject: [PATCH 5/5] Only print subject options when necessary > > * ox-koma-letter.el (org-koma-letter-subject-format): default is now t > * ox-koma-letter.el (org-koma-letter-template): better subject handling. > > If =#+OPTIONS: subject:(x,y)= then =\KOMAoption{subject}{x, y}=. If > =subject:x= then =\KOMAoption{subject}{x}=. > If =subject:t= then =\KOMAoption{subject}{...}= is not printed but > \setkomavar{subject}{...} is printed. If =subject:nil= neither are > printed. > --- > contrib/lisp/ox-koma-letter.el | 21 +++++++++------------ > 1 file changed, 9 insertions(+), 12 deletions(-) > > diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el > index 4cb402e..ca20ec7 100644 > --- a/contrib/lisp/ox-koma-letter.el > +++ b/contrib/lisp/ox-koma-letter.el > @@ -137,7 +137,7 @@ function may be given. Functions must return a string." > :group 'org-export-koma-letter > :type 'string) > > -(defcustom org-koma-letter-subject-format '("beforeopening" "left" "untitled") > +(defcustom org-koma-letter-subject-format t > "Use the title as the subject of the letter. At the time of > writing the following values are allowed: > > @@ -162,6 +162,7 @@ English manual of 2012-07-22)" > (const "titled") > (const "untitled") > (const :tag "No export" nil) > + (const :tag "Default options" t) > (string)) > :group 'org-export-koma-letter) > > @@ -432,20 +433,16 @@ holding export options." > "\\begin{document}\n\n" > ;; Subject > (let* ((with-subject (plist-get info :with-subject)) > - (subject-format > - (if (member > - ;; test if subject-format is t > - (cond ((symbolp with-subject) (downcase (symbol-name with-subject))) > - ((stringp with-subject) (downcase with-subject)) > - (t nil)) > - '("true" "t")) > - org-koma-letter-subject-format > - 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 (if (stringp subject-format) 1 (length subject-format))) > + (l (length subject-format)) > (y "")) > (concat > - (when with-subject > + (when (and with-subject subject-format) > (concat > "\\KOMAoption{subject}{" > (apply 'format > -- > 1.8.2.3 > ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: [PATCH][ox-koma-letter]: sender, email and cleanup 2013-05-26 10:58 ` Viktor Rosenfeld @ 2013-05-26 14:38 ` Rasmus 0 siblings, 0 replies; 48+ messages in thread From: Rasmus @ 2013-05-26 14:38 UTC (permalink / raw) To: emacs-orgmode Viktor Rosenfeld <listuser36@gmail.com> writes: > I'm also not a big fan of the title defaulting to the filename. But I > think it is a minor issue. What I think is quite useful is setting the > subject to the headline of the exported subtree. Wouldn't we also lose > this if subject is nil? Without knowing the details wrt title: We can control for a special case and call the vanilla title function otherwise. How easy it is to big up this special case? I don't know. –Rasnmus -- Vote for proprietary math! ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: [PATCH][ox-koma-letter]: sender, email and cleanup (was: [PATCH] ox-koma-letter.el: Reintroduce variables removed in commit 832c6fd with proper defaults) 2013-05-25 17:48 ` [PATCH][ox-koma-letter]: sender, email and cleanup (was: [PATCH] ox-koma-letter.el: Reintroduce variables removed in commit 832c6fd with proper defaults) Rasmus 2013-05-25 21:27 ` [PATCH][ox-koma-letter]: sender, email and cleanup Rasmus @ 2013-05-26 10:54 ` Viktor Rosenfeld 2013-05-26 14:36 ` [PATCH][ox-koma-letter]: sender, email and cleanup Rasmus 2013-05-26 14:51 ` Rasmus 1 sibling, 2 replies; 48+ messages in thread From: Viktor Rosenfeld @ 2013-05-26 10:54 UTC (permalink / raw) To: Rasmus; +Cc: alan.schmitt, emacs-orgmode Hi Rasmus, Rasmus wrote: > Attached are three patches that goes on top of Viktor's latest patch > (I've also attached it here since I rebased stuff and might have > changed it by accident). > > 1. Viktor's latest patch. > 2. The patch describe above that gets user name and email and works > on my system. . . Your code works for me. From my point of view, the pros are that per default `org-koma-letter-{author,sender}' pick up the values of `user-full-name' and `user-mail-address' whenever they are changed. That's very nice! The cons are that IHMO it's quite complicated for setting something as simple as author and email and you mentioned a possible crash which I did not test further. Could this be tested using `functionp'? Still, I think we should stick with it for now. > 3. Cleaning up special-tags functions introduced in > ec108f4c3507ed546a564a48b7379355a65aa9f4. It works a lot better > now and some of the mess in the template is moved to other > functions. I could not apply this. > 4. Sets defcustom org-koma-letter-signature nil since that > corresponds to default scrlttr2 behavior anyway (p. 183 in the > manual). Works for me. As a side note, I had quite a few problems working with your patches. None of them applied against master, or against my latest patch as you claimed. I had to merge in some of the changes of 0002 by hand. I suggest that we nail down the workings of AUTHOR and EMAIL first (should be done now) and then start with clean separate branches branched from master for your subject and heading code. We could even use github for this, what do you think? Cheers, Viktor > Re 4.: I'd like to do something similar to > org-koma-letter-subject-format. But I'm not sure how, at the moment > (perhaps make t the default and associate it with the current default > list). > > –Rasmus > > -- > This is the kind of tedious nonsense up with which I will not put > > >From bbaf9a6ddd75368b2143e6b8fb50be64bd66b50d Mon Sep 17 00:00:00 2001 > From: Viktor Rosenfeld <listuser36@gmail.com> > Date: Thu, 23 May 2013 00:00:38 +0200 > Subject: [PATCH 1/4] ox-koma-letter.el: Reintroduce variables removed in > commit 832c6fd with proper defaults. > > * ox-koma-letter.el (org-koma-letter-author): Dedicated > variable to set the KOMA variable fromname; initialized to > `user-full-name' using `after-init-hook' if not set > explicitly. > (org-koma-letter-email): Dedicated variable to set the KOMA > variable fromemail; initialized to `user-mail-address' using > `after-init-hook' if not set explicitly. > (koma-letter): Use dedicated variables for AUTHOR and EMAIL. > (org-koma-letter-template): Variable name change. > > Setting the variables `org-koma-letter-author' and `org-koma-letter-email' to the values of `user-full-name' and `user-mail-address' respectively, allows the user to skip =#+AUTHOR:= and =#+EMAIL:= lines when configuring a letter. However, if the user wishes to set this information in LCO files, these variables need to be set to nil. > --- > contrib/lisp/ox-koma-letter.el | 37 +++++++++++++++++++++++++++++++------ > 1 file changed, 31 insertions(+), 6 deletions(-) > > diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el > index 92cf13a..24c1ac5 100644 > --- a/contrib/lisp/ox-koma-letter.el > +++ b/contrib/lisp/ox-koma-letter.el > @@ -82,6 +82,32 @@ > :group 'org-export-koma-letter > :type 'string) > > +(defcustom org-koma-letter-author (if (boundp 'org-koma-letter-author) > + user-full-name > + ;; Empty string means "not set yet." > + "") > + "The sender's name. > + > +This variable defaults to the value of `user-full-name'." > + :group 'org-export-koma-letter > + :type 'string) > + > +(add-hook 'after-init-hook > + (lambda () > + (if (string= org-koma-letter-author "") > + (setq org-koma-letter-author user-full-name)))) > + > +(defcustom org-koma-letter-email user-mail-address > + "The sender's email address. > + > +This variable defaults to the value of `user-mail-address'." > + :group 'org-export-koma-letter > + :type 'string) > + > +(add-hook 'after-init-hook > + (lambda () > + (if (string= org-koma-letter-email "") > + (setq org-koma-letter-email user-mail-address)))) > > (defcustom org-koma-letter-from-address nil > "Sender's address, as a string." > @@ -93,7 +119,6 @@ > :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 > @@ -207,10 +232,10 @@ content temporarily.") > (org-export-define-derived-backend 'koma-letter 'latex > :options-alist > '((:lco "LCO" nil org-koma-letter-class-option-file) > - (:sender "AUTHOR" nil org-koma-letter-author) > + (:author "AUTHOR" nil org-koma-letter-author t) > (:from-address "FROM_ADDRESS" nil org-koma-letter-from-address newline) > (:phone-number "PHONE_NUMBER" nil org-koma-letter-phone-number) > - (:email "EMAIL" nil org-koma-letter-email) > + (:email "EMAIL" nil org-koma-letter-email t) > (:to-address "TO_ADDRESS" nil nil newline) > (:place "PLACE" nil org-koma-letter-place) > (:opening "OPENING" nil org-koma-letter-opening) > @@ -343,7 +368,7 @@ holding export options." > (plist-get info :latex-header-extra)))) > info))))) > (let ((lco (plist-get info :lco)) > - (sender (plist-get info :sender)) > + (author (plist-get info :author)) > (from-address (plist-get info :from-address)) > (phone-number (plist-get info :phone-number)) > (email (plist-get info :email)) > @@ -357,8 +382,8 @@ holding export options." > (setq lco-def (format "%s\\LoadLetterOption{%s}\n" lco-def lco-file))) > lco-def)) > ;; Define "From" data. > - (when sender (format "\\setkomavar{fromname}{%s}\n" > - (org-export-data sender info))) > + (when author (format "\\setkomavar{fromname}{%s}\n" > + (org-export-data author info))) > (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)) > -- > 1.8.2.3 > > >From 3df51bf5a57eb9d3a96fc4742a1b4b16998d701d Mon Sep 17 00:00:00 2001 > From: "rasmus.pank" <rasmus.pank@gmail.com> > Date: Sat, 25 May 2013 15:31:45 +0200 > Subject: [PATCH 2/4] Trying to get good default for email and author. > > * ox-koma-letter.el (org-koma-letter-author): defaults to a function > that returns =`user-full-name'= > * ox-koma-letter.el (org-koma-letter-email): defaults to a function > that returns =`user-mail-address'= > > With the old after-init-hook method my user name was always set to "". > Now org-koma-letter will (i) allow for default nil values (good if you > use LCO files); (ii) default to =`user-full-name'= and > =`user-mail-address'= like =ox-latex.el=. These values are obtained > on-the-fly. > > The two variables in question can also be strings or functions > returning strings. > --- > contrib/lisp/ox-koma-letter.el | 58 ++++++++++++++++++++++-------------------- > 1 file changed, 30 insertions(+), 28 deletions(-) > > diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el > index 24c1ac5..c8be5ab 100644 > --- a/contrib/lisp/ox-koma-letter.el > +++ b/contrib/lisp/ox-koma-letter.el > @@ -82,32 +82,30 @@ > :group 'org-export-koma-letter > :type 'string) > > -(defcustom org-koma-letter-author (if (boundp 'org-koma-letter-author) > - user-full-name > - ;; Empty string means "not set yet." > - "") > +(defcustom org-koma-letter-author 'user-full-name > "The sender's name. > > -This variable defaults to the value of `user-full-name'." > +This variable defaults to calling the function `user-full-name' > +which just returns the current `user-full-name'. Alternatively a > +string, nil or a function may be given. Functions must return a > +string." > :group 'org-export-koma-letter > - :type 'string) > - > -(add-hook 'after-init-hook > - (lambda () > - (if (string= org-koma-letter-author "") > - (setq org-koma-letter-author user-full-name)))) > + :type '(radio (function-item user-full-name) > + (string) > + (function) > + (const nil))) > > -(defcustom org-koma-letter-email user-mail-address > +(defcustom org-koma-letter-email 'org-koma-letter-email > "The sender's email address. > > -This variable defaults to the value of `user-mail-address'." > +This variable defaults to the value `org-koma-letter-email' which > +returns `user-mail-address'. Alternatively a string, nil or a > +function may be given. Functions must return a string." > :group 'org-export-koma-letter > - :type 'string) > - > -(add-hook 'after-init-hook > - (lambda () > - (if (string= org-koma-letter-email "") > - (setq org-koma-letter-email user-mail-address)))) > + :type '(radio (function-item org-koma-letter-email) > + (string) > + (function) > + (const nil))) > > (defcustom org-koma-letter-from-address nil > "Sender's address, as a string." > @@ -134,12 +132,6 @@ This variable defaults to the value of `user-mail-address'." > :group 'org-export-koma-letter > :type 'string) > > -(defcustom org-koma-letter-email user-mail-address > - "The default email address stored in the letter." ) > - > -(defcustom org-koma-letter-author user-full-name > - "The default name of the sender." ) > - > (defcustom org-koma-letter-signature "\\usekomavar{fromname}" > "String used as the signature." > :group 'org-export-koma-letter > @@ -232,17 +224,16 @@ content temporarily.") > (org-export-define-derived-backend 'koma-letter 'latex > :options-alist > '((:lco "LCO" nil org-koma-letter-class-option-file) > - (:author "AUTHOR" nil org-koma-letter-author t) > + (:author "AUTHOR" nil (org-koma-letter--get-custom org-koma-letter-author) t) > (:from-address "FROM_ADDRESS" nil org-koma-letter-from-address newline) > (:phone-number "PHONE_NUMBER" nil org-koma-letter-phone-number) > - (:email "EMAIL" nil org-koma-letter-email t) > + (:email "EMAIL" nil (org-koma-letter--get-custom org-koma-letter-email) t) > (: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) > (:ps-prefix nil "ps-prefix" org-koma-letter-ps-prefix) > - > (: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) > @@ -266,6 +257,17 @@ content temporarily.") > (org-open-file (org-koma-letter-export-to-pdf nil s v b)))))))) > > \f > +;;; Helper functions > + > +(defun org-koma-letter-email () > + "Return the current `user-mail-address'" > + user-mail-address) > + > +(defun org-koma-letter--get-custom (value) > + (when value > + (cond ((stringp value) value) > + ((symbolp value) (funcall value))))) > + > ;;; Transcode Functions > > ;;;; Export Block > -- > 1.8.2.3 > > >From 173826ce58954f24b268f09f45e07ac877d751de Mon Sep 17 00:00:00 2001 > From: "rasmus.pank" <rasmus.pank@gmail.com> > Date: Sat, 25 May 2013 19:08:37 +0200 > Subject: [PATCH 3/4] bug-fix for special headers. > > * ox-koma-letter.el(org-koma-letter-ps-prefix): removed > * ox-koma-letter.el(org-koma-letter-special-tags-after-closing): > downcased to correspond to actual LaTeX-functions > * ox-koma-letter.el(org-koma-letter-special-tags-after-letter): > list of headings to be inserted after =\end{letter}= > * ox-koma-letter.el(org-koma-letter-special-tags): > removed. generated on the go. > * ox-koma-letter.el(org-koma-letter-special-contents): special > headings are controlled via =:with-after-closing= and > =:with-after-letter=. These can also be used for reordering the > way headers are inserted. > * ox-koma-letter.el: some cleaning up. > * ox-koma-letter.el(org-koma-letter--prepare-special-contents-as-macro): > new function for inserting macros based on list of special > tags. > --- > contrib/lisp/ox-koma-letter.el | 111 +++++++++++++++++++++++------------------ > 1 file changed, 62 insertions(+), 49 deletions(-) > > diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el > index c8be5ab..bbfe168 100644 > --- a/contrib/lisp/ox-koma-letter.el > +++ b/contrib/lisp/ox-koma-letter.el > @@ -196,23 +196,13 @@ Use `foldmarks:true' to activate default fold marks or > :group 'org-export-koma-letter > :type 'boolean) > > -(defcustom org-koma-letter-ps-prefix "\\textsc{ps}: " > - "The prefix of PS. Used to construct PS as \"PS-SUFFIX PS\"" > - :group 'org-export-koma-letter > - :type 'string) > - > (defconst org-koma-letter-special-tags-after-closing > - '("PS" "ENCL" "CC") > - "Headers tags to be inserted after closing") > - > -(defconst org-koma-letter-special-tags-other > - '("FROM" "AFTER_LETTER") > - "Headers tags to be inserted after closing") > + '("ps" "encl" "cc") > + "Header tags to be inserted after closing") > > -(defconst org-koma-letter-special-tags > - (append org-koma-letter-special-tags-other > - org-koma-letter-special-tags-after-closing) > - "Header tags with special meaning") > +(defconst org-koma-letter-special-tags-after-letter > + '("after_letter") > + "Header tags to be inserted after closing") > > (defvar org-koma-letter-special-contents nil "holds special > content temporarily.") > @@ -233,13 +223,15 @@ content temporarily.") > (:opening "OPENING" nil org-koma-letter-opening) > (:closing "CLOSING" nil org-koma-letter-closing) > (:signature "SIGNATURE" nil org-koma-letter-signature newline) > - (:ps-prefix nil "ps-prefix" org-koma-letter-ps-prefix) > + (:with-after-closing nil "after-closing-order" > + 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-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-after-closing nil "after-closing-order" org-koma-letter-special-tags-after-closing) > (:with-subject nil "subject" org-koma-letter-subject-format)) > :translate-alist '((export-block . org-koma-letter-export-block) > (export-snippet . org-koma-letter-export-snippet) > @@ -263,11 +255,47 @@ content temporarily.") > "Return the current `user-mail-address'" > user-mail-address) > > +;; The following is taken from/inspired by ox-grof.el > +;; Thanks, Luis! > + > +(defun org-koma-letter--get-tagged-contents (tag) > + "Get tagged content from `org-koma-letter-special-contents'" > + (cdr (assoc tag org-koma-letter-special-contents))) > + > (defun org-koma-letter--get-custom (value) > + "Determines whether a value is nil, a string or a > +function (a symobl). If it is a function it it evaluates it." > (when value > (cond ((stringp value) value) > ((symbolp value) (funcall value))))) > > + > +(defun org-koma-letter--prepare-special-contents-as-macro (a-list &optional keep-newlines no-tag) > + "Finds all the components of `org-koma-letter-special-contents' > +corresponding to members of the `a-list' and return them as a > +string to be formatted. The function is used for inserting > +content of speciall headings such as PS. > + > +If keep-newlines is t newlines will not be removed. If no-tag is > +is t the content in `org-koma-letter-special-contents' will not > +be wrapped in a macro named whatever the members of a-list are called. > +" > + (let (output) > + (dolist (ac a-list output) > + (let > + ((x (org-koma-letter--get-tagged-contents ac)) > + (regexp (if keep-newlines "" "\\`\n+\\|\n*\\'"))) > + (when x > + (setq output > + (concat > + output "\n" > + ;; sometimes LaTeX complains about newlines > + ;; at the end or beginning of macros. Remove them. > + (unless no-tag (format "\\%s{" ac)) > + (format "%s" (replace-regexp-in-string regexp "" x)) > + (unless no-tag "}") > + ))))))) > + > ;;; Transcode Functions > > ;;;; Export Block > @@ -302,17 +330,12 @@ channel." > (org-export-with-backend 'latex keyword contents info)))) > > > -;; The following is taken from/inspired by ox-grof.el > -;; Thanks, Luis! > - > -(defun org-koma-letter--get-tagged-content (tag info) > - (cdr (assoc tag org-koma-letter-special-contents))) > - > +;; Headline > > (defun org-koma-letter-headline (headline contents info) > "Transcode a HEADLINE element from Org to LaTeX. > CONTENTS holds the contents of the headline. INFO is a plist > -holding contextual informatio.n > +holding contextual information. > > Note that if a headline is tagged with a tag from > `org-koma-letter-special-tags' it will not be exported, but > @@ -320,16 +343,14 @@ stored in `org-koma-letter-special-contents' and included at the > appropriate place." > (let* > ((tags (and (plist-get info :with-tags) > - (org-export-get-tags headline info)))) > - (if (member (upcase (car tags)) > - org-koma-letter-special-tags) > - ;; (cond ((member (car tags) '("PS" "ps")) > - ;; (progn > - ;; (push (cons (car tags) (concat (plist-get info :ps-prefix) contents)) > - ;; org-koma-letter-special-contents) nil)) > + (org-export-get-tags headline info))) > + (tag (downcase (car tags)))) > + (if (member tag > + (append (plist-get info :with-after-letter) > + (plist-get info :with-after-closing))) > (progn > - (push (cons (upcase (car tags)) contents) > - org-koma-letter-special-contents) > + (push (cons tag contents) > + org-koma-letter-special-contents) > nil) > contents))) > > @@ -441,23 +462,15 @@ holding export options." > ;; Letter body. > contents > ;; Closing. > - (format "\n\\closing{%s}\n\n" (plist-get info :closing)) > - (let (after-closing) > - (dolist (ac org-koma-letter-special-tags-after-closing after-closing) > - (let ((x (org-koma-letter--get-tagged-content (upcase ac) info))) > - (when x (setq after-closing > - (concat after-closing > - ;; sometimes LaTeX complains about newlines > - ;; at the end of macros. Remove them. > - (replace-regexp-in-string > - "\n+$" "" > - (format "\\%s{%s}" (downcase ac) x)))))))) > + (format "\n\\closing{%s}\n" (plist-get info :closing)) > + (org-koma-letter--prepare-special-contents-as-macro > + (plist-get info :with-after-closing)) > ;; Letter end. > - "\\end{letter}\n" > - (let ((x (org-koma-letter--get-tagged-content "AFTER_LETTER" info))) > - (when x (format x))) > + "\n\\end{letter}\n" > + (org-koma-letter--prepare-special-contents-as-macro > + (plist-get info :with-after-letter) t t) > ;; Document end. > - "\\end{document}" > + "\n\\end{document}" > )) > > \f > @@ -487,7 +500,7 @@ contents of hidden elements. > When optional argument BODY-ONLY is non-nil, only write code > between \"\\begin{letter}\" and \"\\end{letter}\". > > -EXT-PLIST, when provided, is a property list with external > +EXT-PLIST, when provided, is a proeprty list with external > parameters overriding Org default settings, but still inferior to > file-local settings. > > -- > 1.8.2.3 > > >From 05c5371628af21e5f2a2a10404c4cfc354486ec6 Mon Sep 17 00:00:00 2001 > From: "rasmus.pank" <rasmus.pank@gmail.com> > Date: Sat, 25 May 2013 19:35:10 +0200 > Subject: [PATCH 4/4] change default of org-koma-letter-signature to nil > > * ox-koma-letter.el(org-koma-letter-signature): set to nil > > The previoues value corresponds to the default value cf. the the koma > manual pp. 183. > --- > contrib/lisp/ox-koma-letter.el | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el > index bbfe168..4cb402e 100644 > --- a/contrib/lisp/ox-koma-letter.el > +++ b/contrib/lisp/ox-koma-letter.el > @@ -132,7 +132,7 @@ function may be given. Functions must return a string." > :group 'org-export-koma-letter > :type 'string) > > -(defcustom org-koma-letter-signature "\\usekomavar{fromname}" > +(defcustom org-koma-letter-signature nil > "String used as the signature." > :group 'org-export-koma-letter > :type 'string) > -- > 1.8.2.3 > ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: [PATCH][ox-koma-letter]: sender, email and cleanup 2013-05-26 10:54 ` [PATCH][ox-koma-letter]: sender, email and cleanup (was: [PATCH] ox-koma-letter.el: Reintroduce variables removed in commit 832c6fd with proper defaults) Viktor Rosenfeld @ 2013-05-26 14:36 ` Rasmus 2013-05-27 6:25 ` Alan Schmitt 2013-05-26 14:51 ` Rasmus 1 sibling, 1 reply; 48+ messages in thread From: Rasmus @ 2013-05-26 14:36 UTC (permalink / raw) To: listuser36; +Cc: alan.schmitt, emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 3147 bytes --] Viktor, >> 1. Viktor's latest patch. >> 2. The patch describe above that gets user name and email and works >> on my system. . . > > Your code works for me. From my point of view, the pros are that per > default `org-koma-letter-{author,sender}' pick up the values of > `user-full-name' and `user-mail-address' whenever they are changed. > That's very nice! The cons are that IHMO it's quite complicated for > setting something as simple as author and email and you mentioned a > possible crash which I did not test further. Could this be tested using > `functionp'? Still, I think we should stick with it for now. functionp seems better, yes. I didn't know about it (doh!). Thanks! While it is complicated I think it's OK given our desire to disable author and still have a similar default to ox-latex.el. Also, it allows for arbitrary functions which could potentially determine the name based on the context of the letter (I don't know since it's already initialized in the options-alist). I'll let you and Alan decide. > As a side note, I had quite a few problems working with your patches. > None of them applied against master, or against my latest patch as you > claimed. Right. I was working off of branch and I guess one reasons is that it was against the history of my previoues patches—of which not all was applied to the master, it seems (?). I've now tried to rework the entire thing against the current master and produces simplified patches. I tested them with git am and they work on my system. There are still things I don't understand such as why git wants to re-add the authors in patch 4 but I've spend way to much time on rebasing and understanding git already and my head hurts. It seems to ignore it when using git am. Before applying the patches my git log says commit 847637f4bdacb861723438c1389f1a3bcdac48af Merge: 43cc5be 206762b Author: Nicolas Goaziou <n.goaziou@gmail.com> Date: Sat May 25 22:03:48 2013 +0200 Merge branch 'maint' Patches: 1. summarizes all changes in author. It uses my solution as mentioned above. 2. full support for after closing keywords. See commit message 3. signature to nil 4. change handling of subject and allow for setting subject in OPTION-line. > I had to merge in some of the changes of 0002 by hand. I > suggest that we nail down the workings of AUTHOR and EMAIL first (should > be done now) and then start with clean separate branches branched from > master for your subject and heading code. > We could even use github for this, what do you think? Yeah, could be better. It's way too hectic with all the patches and keeping track of moving repos. If you think it can ease the burden of collaborating I'm all for it. I tried to make a git repo retaining the history of ox-koma-letter.el, but I ended up with a repo of 42mb even after applying all the "garbage collection" tips the interweb had to offer. . . I'm indifferent between bitbucket and github btw, but I'd prefer it someone with more git skills would set it up. -Rasmus -- m-mm-mmm-mmmm bacon! [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-ox-koma-letter.el-org-koma-letter-author-defaults-to.patch --] [-- Type: text/x-patch, Size: 4718 bytes --] From bd51fc02a1345cf1005d0137fc0888d301e1089b Mon Sep 17 00:00:00 2001 From: "rasmus.pank" <rasmus.pank@gmail.com> Date: Sun, 26 May 2013 16:13:39 +0200 Subject: [PATCH 1/4] * ox-koma-letter.el (org-koma-letter-author): defaults to a function that returns =`user-full-name'= * ox-koma-letter.el (org-koma-letter-email): defaults to a function that returns =`user-mail-address'= Setting the variables `org-koma-letter-author' and `org-koma-letter-email' to the values of `user-full-name' and `user-mail-address' respectively, allows the user to skip =#+AUTHOR:= and =#+EMAIL:= lines when configuring a letter. However, if the user wishes to set this information in LCO files, these variables need to be set to nil. With the old after-init-hook method my user name was always set to "". Now org-koma-letter will (i) allow for default nil values (good if you use LCO files); (ii) default to =`user-full-name'= and =`user-mail-address'= like =ox-latex.el=. These values are obtained on-the-fly. The two variables in question can also be strings or functions returning strings. --- contrib/lisp/ox-koma-letter.el | 50 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el index 4318db1..7f50530 100644 --- a/contrib/lisp/ox-koma-letter.el +++ b/contrib/lisp/ox-koma-letter.el @@ -80,6 +80,30 @@ :group 'org-export-koma-letter :type 'string) +(defcustom org-koma-letter-author 'user-full-name + "The sender's name. + +This variable defaults to calling the function `user-full-name' +which just returns the current `user-full-name'. Alternatively a +string, nil or a function may be given. Functions must return a +string." + :group 'org-export-koma-letter + :type '(radio (function-item user-full-name) + (string) + (function) + (const nil))) + +(defcustom org-koma-letter-email 'org-koma-letter-email + "The 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 +function may be given. Functions must return a string." + :group 'org-export-koma-letter + :type '(radio (function-item org-koma-letter-email) + (string) + (function) + (const nil))) (defcustom org-koma-letter-from-address nil "Sender's address, as a string." @@ -153,10 +177,10 @@ Use `foldmarks:true' to activate default fold marks or (org-export-define-derived-backend 'koma-letter 'latex :options-alist '((:lco "LCO" nil org-koma-letter-class-option-file) - (:sender "AUTHOR" nil user-full-name t) + (:author "AUTHOR" nil (org-koma-letter--get-custom org-koma-letter-author) t) (:from-address "FROM_ADDRESS" nil org-koma-letter-from-address newline) (:phone-number "PHONE_NUMBER" nil org-koma-letter-phone-number) - (:email "EMAIL" nil user-mail-address t) + (:email "EMAIL" nil (org-koma-letter--get-custom org-koma-letter-email) t) (:to-address "TO_ADDRESS" nil nil newline) (:place "PLACE" nil org-koma-letter-place) (:opening "OPENING" nil org-koma-letter-opening) @@ -184,6 +208,22 @@ Use `foldmarks:true' to activate default fold marks or (org-open-file (org-koma-letter-export-to-pdf nil s v b)))))))) \f +;;; Helper functions + +(defun org-koma-letter-email () + "Return the current `user-mail-address'" + user-mail-address) + + +(defun org-koma-letter--get-custom (value) + "Determines whether a value is nil, a string or a +function (a symobl). If it is a function it it evaluates it." + (when value + (cond ((stringp value) value) + ((functionp value) (funcall value)) + ((symbolp value) (symbol-name value))))) + + ;;; Transcode Functions ;;;; Export Block @@ -250,7 +290,7 @@ holding export options." (plist-get info :latex-header-extra)))) info))))) (let ((lco (plist-get info :lco)) - (sender (plist-get info :sender)) + (author (plist-get info :author)) (from-address (plist-get info :from-address)) (phone-number (plist-get info :phone-number)) (email (plist-get info :email)) @@ -264,8 +304,8 @@ holding export options." (setq lco-def (format "%s\\LoadLetterOption{%s}\n" lco-def lco-file))) lco-def)) ;; Define "From" data. - (when sender (format "\\setkomavar{fromname}{%s}\n" - (org-export-data sender info))) + (when author (format "\\setkomavar{fromname}{%s}\n" + (org-export-data author info))) (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)) -- 1.8.2.3 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #3: 0002-Added-support-for-after-closing-and-after-document.patch --] [-- Type: text/x-patch, Size: 8960 bytes --] From 19c8a5bbe4efe6cfcc0f0ce39936890db384d1ec Mon Sep 17 00:00:00 2001 From: "rasmus.pank" <rasmus.pank@gmail.com> Date: Sun, 26 May 2013 16:14:51 +0200 Subject: [PATCH 2/4] Added support for after closing and after document entities in ox-koma-letter. * ox-koma-letter.el (org-koma-letter-special-tags-after-closing): specials tags inserted after =\end{closing}= * ox-koma-letter.el (org-koma-letter-special-tags): collect the special lists * ox-koma-letter.el (org-koma-letter-headline): stores content in of headline if the first tag is special. Otherwise return content. * ox-koma-letter.el (org-koma-letter-special-content): holds special content temporarily. * ox-koma-letter.el (org-koma-letter--format-string-as-macro): format a string as a macro or don't. * ox-koma-letter.el (org-koma-letter-template): added support for the headings with special tags. The following example will now export a sensible manner. * my letter here's a letter * PS :ps: it's requires this patch * CC :cc: Nicolas, Viktor and Alan * ENCL :encl: many patches 1. this patch 2. another patch. * include patches :after_letter: \myspecialmacro \includepdf{pdf} Namely, content of ps, encl and cc headings will be exported after \closing{.} in the order prescribed by =`org-koma-letter-special-tags-after-closing'= as a (LaTeX) macro removing trailing and leading newlines. The macro is the same as the tag, althogh the case is determined by the special list. The concents of the =after_letter= heading will be inserted after =\end{letter}= and newlines are preserved. --- contrib/lisp/ox-koma-letter.el | 104 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 96 insertions(+), 8 deletions(-) diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el index 7f50530..22cfb2e 100644 --- a/contrib/lisp/ox-koma-letter.el +++ b/contrib/lisp/ox-koma-letter.el @@ -115,7 +115,6 @@ function may be given. Functions must return 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 @@ -171,6 +170,17 @@ Use `foldmarks:true' to activate default fold marks or :group 'org-export-koma-letter :type 'boolean) +(defconst org-koma-letter-special-tags-after-closing + '("ps" "encl" "cc") + "Header tags to be inserted after closing") + +(defconst org-koma-letter-special-tags-after-letter '("after_letter") + "Header tags to be inserted after closing") + +(defvar org-koma-letter-special-contents nil "holds special +content temporarily.") + + \f ;;; Define Back-End @@ -186,7 +196,13 @@ Use `foldmarks:true' to activate default fold marks or (:opening "OPENING" nil org-koma-letter-opening) (:closing "CLOSING" nil org-koma-letter-closing) (:signature "SIGNATURE" nil org-koma-letter-signature newline) - + (:special-tags nil nil + (append org-koma-letter-special-tags-after-closing + org-koma-letter-special-tags-after-letter)) + (:with-after-closing nil "after-closing-order" + 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-foldmarks nil "foldmarks" org-koma-letter-use-foldmarks) (:with-phone nil "phone" org-koma-letter-use-phone) @@ -195,6 +211,7 @@ Use `foldmarks:true' to activate default fold marks or (: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) + (headline . org-koma-letter-headline) (keyword . org-koma-letter-keyword) (template . org-koma-letter-template)) :menu-entry @@ -214,6 +231,12 @@ Use `foldmarks:true' to activate default fold marks or "Return the current `user-mail-address'" user-mail-address) +;; The following is taken from/inspired by ox-grof.el +;; Thanks, Luis! + +(defun org-koma-letter--get-tagged-contents (tag) + "Get tagged content from `org-koma-letter-special-contents'" + (cdr (assoc tag org-koma-letter-special-contents))) (defun org-koma-letter--get-custom (value) "Determines whether a value is nil, a string or a @@ -224,6 +247,37 @@ function (a symobl). If it is a function it it evaluates it." ((symbolp value) (symbol-name value))))) +(defun org-koma-letter--prepare-special-contents-as-macro (a-list &optional keep-newlines no-tag) + "Finds all the components of `org-koma-letter-special-contents' +corresponding to members of the `a-list' and return them as a +string to be formatted. The function is used for inserting +content of speciall headings such as PS. + +If keep-newlines is t newlines will not be removed. If no-tag is +is t the content in `org-koma-letter-special-contents' will not +be wrapped in a macro named whatever the members of a-list are called. +" + (let (output) + (dolist (ac a-list output) + (let + ((x (org-koma-letter--get-tagged-contents ac)) + (regexp (if keep-newlines "" "\\`\n+\\|\n*\\'"))) + (when x + (setq output + (concat + output "\n" + ;; sometimes LaTeX complains about newlines + ;; at the end or beginning of macros. Remove them. + (org-koma-letter--format-string-as-macro + (format "%s" (replace-regexp-in-string regexp "" x)) + (unless no-tag ac))))))))) + +(defun org-koma-letter--format-string-as-macro (string &optional macro) + "If a macro is given format as string as \"\\macro{string}\" else as \"string\"" + (if macro + (format "\\%s{%s}" macro string) + (format "%s" string))) + ;;; Transcode Functions ;;;; Export Block @@ -257,12 +311,39 @@ channel." (if (equal key "KOMA-LETTER") value (org-export-with-backend 'latex keyword contents info)))) + +;; Headline + +(defun org-koma-letter-headline (headline contents info) + "Transcode a HEADLINE element from Org to LaTeX. +CONTENTS holds the contents of the headline. INFO is a plist +holding contextual information. + +Note that if a headline is tagged with a tag from +`org-koma-letter-special-tags' it will not be exported, but +stored in `org-koma-letter-special-contents' and included at the +appropriate place." + (let* + ((tags (and (plist-get info :with-tags) + (org-export-get-tags headline info))) + (tag (downcase (car tags)))) + (if (member tag (plist-get info :special-tags)) + (progn + (push (cons tag contents) + org-koma-letter-special-contents) + nil) + contents))) + + ;;;; Template (defun org-koma-letter-template (contents info) "Return complete document string after KOMA Scrlttr2 conversion. CONTENTS is the transcoded contents string. INFO is a plist holding export options." + ;; 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 + ;; as in org-groff... (concat ;; Time-stamp. (and (plist-get info :time-stamp-file) @@ -297,7 +378,7 @@ holding export options." (signature (plist-get info :signature))) (concat ;; Letter Class Option File - (when lco + (when lco (let ((lco-files (split-string lco " ")) (lco-def "")) (dolist (lco-file lco-files lco-def) @@ -344,10 +425,16 @@ holding export options." ;; Letter body. contents ;; Closing. - (format "\n\\closing{%s}\n\n" (plist-get info :closing)) + (format "\n\\closing{%s}\n" (plist-get info :closing)) + (org-koma-letter--prepare-special-contents-as-macro + (plist-get info :with-after-closing)) ;; Letter end. - "\\end{letter}\n\\end{document}")) - + "\n\\end{letter}\n" + (org-koma-letter--prepare-special-contents-as-macro + (plist-get info :with-after-letter) t t) + ;; Document end. + "\n\\end{document}" + )) \f ;;; Commands @@ -376,7 +463,7 @@ contents of hidden elements. When optional argument BODY-ONLY is non-nil, only write code between \"\\begin{letter}\" and \"\\end{letter}\". -EXT-PLIST, when provided, is a property list with external +EXT-PLIST, when provided, is a proeprty list with external parameters overriding Org default settings, but still inferior to file-local settings. @@ -384,6 +471,7 @@ Export is done in a buffer named \"*Org KOMA-LETTER Export*\". It will be displayed if `org-export-show-temporary-export-buffer' is non-nil." (interactive) + (let (org-koma-letter-special-contents) (if async (org-export-async-start (lambda (output) @@ -400,7 +488,7 @@ non-nil." subtreep visible-only body-only ext-plist))) (with-current-buffer outbuf (LaTeX-mode)) (when org-export-show-temporary-export-buffer - (switch-to-buffer-other-window outbuf))))) + (switch-to-buffer-other-window outbuf)))))) ;;;###autoload (defun org-koma-letter-export-to-latex -- 1.8.2.3 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #4: 0003-change-default-of-org-koma-letter-signature-to-nil.patch --] [-- Type: text/x-patch, Size: 980 bytes --] From 8d0c65dfa90b2ef4b073949b610d4aba842890fc Mon Sep 17 00:00:00 2001 From: "rasmus.pank" <rasmus.pank@gmail.com> Date: Sat, 25 May 2013 19:35:10 +0200 Subject: [PATCH 3/4] change default of org-koma-letter-signature to nil * ox-koma-letter.el(org-koma-letter-signature): set to nil The previoues value corresponds to the default value cf. the the koma manual pp. 183. --- contrib/lisp/ox-koma-letter.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el index 22cfb2e..30671e5 100644 --- a/contrib/lisp/ox-koma-letter.el +++ b/contrib/lisp/ox-koma-letter.el @@ -130,7 +130,7 @@ function may be given. Functions must return a string." :group 'org-export-koma-letter :type 'string) -(defcustom org-koma-letter-signature "\\usekomavar{fromname}" +(defcustom org-koma-letter-signature nil "String used as the signature." :group 'org-export-koma-letter :type 'string) -- 1.8.2.3 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #5: 0004-ox-koma-letter-changed-handling-of-subject.patch --] [-- Type: text/x-patch, Size: 4765 bytes --] From dc9589140c9fdc05290efeaedff46c35e3e902e1 Mon Sep 17 00:00:00 2001 From: "rasmus.pank" <rasmus.pank@gmail.com> Date: Sun, 19 May 2013 17:32:44 +0200 Subject: [PATCH 4/4] ox-koma-letter: changed handling of subject * ox-koma-letter.el: =`org-koma-letter-subject-format'= can now be a list. Default is t. If nil neither subject format nor type is exported. * ox-koma-letter.el (org-koma-letter-template): better subject handling. * ox-koma-letter.el (org-koma-letter-template): allow for t value of =#+OPTIONS: subject:VALUE= * ox-koma-letter.el (org-koma-letter-template): export of subject format is independent of title, but title is not independent of =:with-subject=. The issue was with =#+OPTIONS: subject:t= one would get a LaTeX error. New behavior: If =#+OPTIONS: subject:(x,y)= then =\KOMAoption{subject}{x, y}=. If =subject:x= then =\KOMAoption{subject}{x}=. If =subject:t= then =\KOMAoption{subject}{...}= is not set but \setkomavar{subject}{...} is set (in the output file) If =subject:nil= neither are printed. --- contrib/lisp/ox-koma-letter.el | 63 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 52 insertions(+), 11 deletions(-) diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el index 30671e5..4af0ba7 100644 --- a/contrib/lisp/ox-koma-letter.el +++ b/contrib/lisp/ox-koma-letter.el @@ -4,6 +4,8 @@ ;; Author: Nicolas Goaziou <n.goaziou AT gmail DOT com> ;; Alan Schmitt <alan.schmitt AT polytechnique DOT org> +;; Viktor Rosenfeld <listuser36 AT gmail DOT com> +;; Rasmus Pank Roulund <emacs AT pank DOT eu> ;; Keywords: org, wp, tex ;; This program is free software: you can redistribute it and/or modify @@ -135,10 +137,36 @@ function may be given. Functions must return a string." :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-subject-format t + "Use the title as the subject of the letter. At the time of +writing the following values are allowed: + + - afteropening: subject after opening + - beforeopening: subject before opening + - centered: subject centered + - left:subject left-justified + - right: subject right-justified + - titled: add title/description to subject + - underlined: set subject underlined (see note in text please) + - 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)" + :type '(set (const "afteropening") + (const "beforeopening") + (const "centered") + (const "left") + (const "right") + (const "underlined") + (const "titled") + (const "untitled") + (const :tag "No export" nil) + (const :tag "Default options" t) + (string)) + :group 'org-export-koma-letter) + + (defcustom org-koma-letter-use-backaddress t "Print return address in small line above to address." @@ -208,7 +236,7 @@ content temporarily.") (: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)) + (:with-subject nil "subject" org-koma-letter-subject-format)) :translate-alist '((export-block . org-koma-letter-export-block) (export-snippet . org-koma-letter-export-snippet) (headline . org-koma-letter-headline) @@ -411,12 +439,25 @@ holding export options." ;; Document start "\\begin{document}\n\n" ;; 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))))) + (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 "")) + (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")) + (when (and subject with-subject) + (format "\\setkomavar{subject}{%s}\n\n" subject)))) ;; Letter start (format "\\begin{letter}{%%\n%s}\n\n" (or (plist-get info :to-address) "no address given")) -- 1.8.2.3 ^ permalink raw reply related [flat|nested] 48+ messages in thread
* Re: [PATCH][ox-koma-letter]: sender, email and cleanup 2013-05-26 14:36 ` [PATCH][ox-koma-letter]: sender, email and cleanup Rasmus @ 2013-05-27 6:25 ` Alan Schmitt 2013-05-27 9:22 ` Xavier Garrido 0 siblings, 1 reply; 48+ messages in thread From: Alan Schmitt @ 2013-05-27 6:25 UTC (permalink / raw) To: Rasmus; +Cc: emacs-orgmode Rasmus writes: > Viktor, > >>> 1. Viktor's latest patch. >>> 2. The patch describe above that gets user name and email and works >>> on my system. . . >> >> Your code works for me. From my point of view, the pros are that per >> default `org-koma-letter-{author,sender}' pick up the values of >> `user-full-name' and `user-mail-address' whenever they are changed. >> That's very nice! The cons are that IHMO it's quite complicated for >> setting something as simple as author and email and you mentioned a >> possible crash which I did not test further. Could this be tested using >> `functionp'? Still, I think we should stick with it for now. > > functionp seems better, yes. I didn't know about it (doh!). Thanks! > > While it is complicated I think it's OK given our desire to disable > author and still have a similar default to ox-latex.el. Also, it > allows for arbitrary functions which could potentially determine the > name based on the context of the letter (I don't know since it's > already initialized in the options-alist). > > I'll let you and Alan decide. I like this approach. >> As a side note, I had quite a few problems working with your patches. >> None of them applied against master, or against my latest patch as you >> claimed. > > Right. I was working off of branch and I guess one reasons is that it > was against the history of my previoues patches—of which not all was > applied to the master, it seems (?). I've now tried to rework the > entire thing against the current master and produces simplified > patches. I tested them with git am and they work on my system. > > There are still things I don't understand such as why git wants to > re-add the authors in patch 4 but I've spend way to much time on > rebasing and understanding git already and my head hurts. It seems to > ignore it when using git am. > > Before applying the patches my git log says > > commit 847637f4bdacb861723438c1389f1a3bcdac48af > Merge: 43cc5be 206762b > Author: Nicolas Goaziou <n.goaziou@gmail.com> > Date: Sat May 25 22:03:48 2013 +0200 > > Merge branch 'maint' > > Patches: > > 1. summarizes all changes in author. It uses my solution as mentioned above. > 2. full support for after closing keywords. See commit message > 3. signature to nil > 4. change handling of subject and allow for setting subject in > OPTION-line. I'm going to apply the patches. Thanks to both of you for the nice work! Alan ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: [PATCH][ox-koma-letter]: sender, email and cleanup 2013-05-27 6:25 ` Alan Schmitt @ 2013-05-27 9:22 ` Xavier Garrido 2013-05-27 9:51 ` Rasmus 2013-05-27 18:31 ` Viktor Rosenfeld 0 siblings, 2 replies; 48+ messages in thread From: Xavier Garrido @ 2013-05-27 9:22 UTC (permalink / raw) To: Rasmus, Viktor Rosenfeld; +Cc: Alan Schmitt, emacs-orgmode Hi koma-letterers, >> Patches: >> >> 1. summarizes all changes in author. It uses my solution as mentioned above. >> 2. full support for after closing keywords. See commit message >> 3. signature to nil >> 4. change handling of subject and allow for setting subject in >> OPTION-line. > > I'm going to apply the patches. Thanks to both of you for the nice work! I just update Org/git and install ox-koma-letter lisp file. I have a strange behavior with EMAIL keyword since there will be always a =\setkomavar{fromemail}= command in my LaTeX produced file even if there is no #+EMAIL: keyword on top of my org file. This is slightly different from what I get when I write or not #+AUTHOR: keyword : the =\setkomavar{fromname}= naturally disappears if AUTHOR is not written. I do not want to write every time my email in org file header since it is already set in a lco file. But given this problem, the email is always overloaded when exporting to latex/pdf. I had a look into ox-koma-letter script and even if I saw small differences when dealing with AUTHOR and EMAIL keywords, I am not able to solve solve this discrepancy. Xavier PS: except from this little problem, it works like a charm, so thanks a lot. ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: [PATCH][ox-koma-letter]: sender, email and cleanup 2013-05-27 9:22 ` Xavier Garrido @ 2013-05-27 9:51 ` Rasmus 2013-05-27 18:31 ` Viktor Rosenfeld 1 sibling, 0 replies; 48+ messages in thread From: Rasmus @ 2013-05-27 9:51 UTC (permalink / raw) To: emacs-orgmode; +Cc: xavier.garrido Hi Xavier, >>> 1. summarizes all changes in author. It uses my solution as mentioned above. >>> 2. full support for after closing keywords. See commit message >>> 3. signature to nil >>> 4. change handling of subject and allow for setting subject in >>> OPTION-line. >> >> I'm going to apply the patches. Thanks to both of you for the nice work! > > I just update Org/git and install ox-koma-letter lisp file. I have a > strange behavior with EMAIL keyword since there will be always a > =\setkomavar{fromemail}= command in my LaTeX produced file even if > there is no #+EMAIL: keyword on top of my org file. This is slightly > different from what I get when I write or not #+AUTHOR: keyword : the > =\setkomavar{fromname}= naturally disappears if AUTHOR is not written. Thanks for the quick report, and sorry about the inconvenience. I'm kind of busy this week due to obligations which I must attend to. Could you perhaps set the offending variable to nil for now? Either org-koma-letter-email or the org-koma-letter-use-email or use #+OPTIONS: email:nil. I couldn't see what would be causing the offending behavior straight away. Could you give me an example-file where the behavior fails? Then I'd also be able to test that future changes don't break expected behavior. Also, if time permits please do look over the (hopefully) elaborate changelogs and test that everything works as you expect it to. > I do not want to write every time my email in org file header since it > is already set in a lco file. But given this problem, the email is > always overloaded when exporting to latex/pdf. If you always have an email in you lco file you should disable email publishing. Cheers, Rasmus -- ⠠⠵ ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: [PATCH][ox-koma-letter]: sender, email and cleanup 2013-05-27 9:22 ` Xavier Garrido 2013-05-27 9:51 ` Rasmus @ 2013-05-27 18:31 ` Viktor Rosenfeld 2013-05-27 20:42 ` Xavier Garrido 1 sibling, 1 reply; 48+ messages in thread From: Viktor Rosenfeld @ 2013-05-27 18:31 UTC (permalink / raw) To: Xavier Garrido; +Cc: Alan Schmitt, emacs-orgmode, Rasmus Hi Xavier, Xavier Garrido wrote: > Hi koma-letterers, > > >>Patches: > >> > >>1. summarizes all changes in author. It uses my solution as mentioned above. > >>2. full support for after closing keywords. See commit message > >>3. signature to nil > >>4. change handling of subject and allow for setting subject in > >>OPTION-line. > > > >I'm going to apply the patches. Thanks to both of you for the nice work! > > I just update Org/git and install ox-koma-letter lisp file. I have a > strange behavior with EMAIL keyword since there will be always a > =\setkomavar{fromemail}= command in my LaTeX produced file even if > there is no #+EMAIL: keyword on top of my org file. This is slightly > different from what I get when I write or not #+AUTHOR: keyword : the > =\setkomavar{fromname}= naturally disappears if AUTHOR is not > written. > > I do not want to write every time my email in org file header since > it is already set in a lco file. But given this problem, the email is > always overloaded when exporting to latex/pdf. Please check the values of `org-koma-letter-email' and `org-koma-letter-author'. They should be set to nil if you have these settings defined in an LCO file and do not want to set them in the generated TeX sources. I use such a setup and the latest master branch is working for me. Cheers, Viktor > > I had a look into ox-koma-letter script and even if I saw small > differences when dealing with AUTHOR and EMAIL keywords, I am not > able to solve solve this discrepancy. > > Xavier > > PS: except from this little problem, it works like a charm, so thanks a lot. > ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: [PATCH][ox-koma-letter]: sender, email and cleanup 2013-05-27 18:31 ` Viktor Rosenfeld @ 2013-05-27 20:42 ` Xavier Garrido 0 siblings, 0 replies; 48+ messages in thread From: Xavier Garrido @ 2013-05-27 20:42 UTC (permalink / raw) To: Viktor Rosenfeld; +Cc: Xavier Garrido, Alan Schmitt, emacs-orgmode, Rasmus Hi Viktor, > Please check the values of `org-koma-letter-email' and > `org-koma-letter-author'. They should be set to nil if you have these > settings defined in an LCO file and do not want to set them in the > generated TeX sources. I use such a setup and the latest master branch > is working for me. Ok these are working. Thanks for your help, Cheers, Xavier ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: [PATCH][ox-koma-letter]: sender, email and cleanup 2013-05-26 10:54 ` [PATCH][ox-koma-letter]: sender, email and cleanup (was: [PATCH] ox-koma-letter.el: Reintroduce variables removed in commit 832c6fd with proper defaults) Viktor Rosenfeld 2013-05-26 14:36 ` [PATCH][ox-koma-letter]: sender, email and cleanup Rasmus @ 2013-05-26 14:51 ` Rasmus 1 sibling, 0 replies; 48+ messages in thread From: Rasmus @ 2013-05-26 14:51 UTC (permalink / raw) To: emacs-orgmode > As a side note, I had quite a few problems working with your patches. > None of them applied against master, or against my latest patch as you > claimed. I had to merge in some of the changes of 0002 by hand. I > suggest that we nail down the workings of AUTHOR and EMAIL first (should > be done now) and then start with clean separate branches branched from > master for your subject and heading code. We could even use github for > this, what do you think? . . . Also, a separate place/branch would allow for a common TODO file to keep a record of what we discuss and more importantly what we've concluded on subject X, Y, Z which otherwise might be forgotten. It could also hold a working copy of Viktor's tutorial which then could be updated more frequently. Lot's of explanation (which is my fault) is now hidden in the commit messages. –Rasmus PS: What would be even better would be to keep the source and tutorial in the same file encoring updating. Of course, I'd want the docstrings to be the main documentation still. E.g. using Org-babel or "some-other-mechanism". E.g. paredit generates info automatically. ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: [PATCH] ox-koma-letter.el: Reintroduce variables removed in commit 832c6fd with proper defaults (was Re: [patch] ox-koma-letter.el: clean-up/semantic bug [4/4]) 2013-05-25 13:57 ` Rasmus 2013-05-25 17:03 ` Viktor Rosenfeld @ 2013-05-25 20:51 ` Robert Klein 2013-05-25 21:41 ` [PATCH] ox-koma-letter.el: Reintroduce variables removed in commit 832c6fd with proper defaults Rasmus 2013-05-26 11:04 ` [PATCH] ox-koma-letter.el: Reintroduce variables removed in commit 832c6fd with proper defaults (was Re: [patch] ox-koma-letter.el: clean-up/semantic bug [4/4]) Viktor Rosenfeld 1 sibling, 2 replies; 48+ messages in thread From: Robert Klein @ 2013-05-25 20:51 UTC (permalink / raw) To: Rasmus; +Cc: emacs-orgmode Hello, On 05/25/2013 03:57 PM, Rasmus wrote: > Alan Schmitt <alan.schmitt@polytechnique.org> writes: > >> Hello, >> >> Viktor Rosenfeld writes: >> >>> Hi Robert, >>> >>> Robert Klein wrote: >>> >>>> Hi, >>>> >>>> FWIW, from a users view it would be nice if: >>>> >>>> - Use Author/Email information from org file >>>> - If not present use information from LCO file >>>> - if neither org file nor LCO file has any information use >>>> user-full-name and user-email-address >>>> >>>> Could this be solved by having several e.g. `setkomavar{fromname}' >>>> and so on in the tex file, so is created as follows: > > I'd go with 'no'. It's not aesthetically pleasing and I don't want my > output to look like LyX. When feasible we should go for beautiful > output. This isn't always the case at the moment, but still. > >>>> if no #+AUTHOR in org-file and user-full-name is set: >>>> add user-full-name >>>> if #+LCO(s) in org-file: >>>> add LCO file(s) >>>> if #+AUTHOR in org-file: >>>> add \setkomavar{fromname}{#+AUTHOR} >>>> .... same for email > > Currently the ordering is: #+AUTHOR > #+LCO and AUTHOR default to > (user-full-name). hmm, sorry, I did not express myself in a good way. what I meant is, if #+AUTHOR defaults to (user-full-name), could the \setkomavar commands be placed /before/ \LoadLetterOption in the TeX file, and after \LoadLetterOptions if #+AUTHOR is set in the .org file? So you'd still get only one set of \setkomavar in the TeX file, but get a (for me) more useful order of #+AUTHOR != (user-full-name) > #+LCO > #+AUTHOR == (user-full-name) Best regards Robert ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: [PATCH] ox-koma-letter.el: Reintroduce variables removed in commit 832c6fd with proper defaults 2013-05-25 20:51 ` [PATCH] ox-koma-letter.el: Reintroduce variables removed in commit 832c6fd with proper defaults (was Re: [patch] ox-koma-letter.el: clean-up/semantic bug [4/4]) Robert Klein @ 2013-05-25 21:41 ` Rasmus 2013-05-26 11:04 ` [PATCH] ox-koma-letter.el: Reintroduce variables removed in commit 832c6fd with proper defaults (was Re: [patch] ox-koma-letter.el: clean-up/semantic bug [4/4]) Viktor Rosenfeld 1 sibling, 0 replies; 48+ messages in thread From: Rasmus @ 2013-05-25 21:41 UTC (permalink / raw) To: emacs-orgmode Hi Robert, > what I meant is, if #+AUTHOR defaults to (user-full-name), could the > \setkomavar commands be placed /before/ \LoadLetterOption in the TeX > file, and after \LoadLetterOptions if #+AUTHOR is set in the .org file? > > So you'd still get only one set of \setkomavar in the TeX file, but get > a (for me) more useful order of #+AUTHOR != (user-full-name) > #+LCO > > #+AUTHOR == (user-full-name) I see. It could be done but it could be kind of inconvenient, I guess, since currently #+AUTHOR and the default org-koma-letter-author share the same variable name during export. You can always disable it with empty values, although a bit of a hassle (e.g. "#+AUTHOR:\n"). If my memory serves me correctly Viktor decided the order of LCO values versus file values carefully so he'll have a better idea about this. That being said, I can think of two ways to do it. 1. use something like `org-koma-letter--prepare-special-contents-as-macro' and make an ordering dependent on a list like with org-koma-letter-special-tags-after-closing. 2. Test whether a particular value is equal to the default. But it seems like something that could easily go wrong. . . –Rasmus -- Hvor meget poesi tror De kommer ud af et glas isvand? ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: [PATCH] ox-koma-letter.el: Reintroduce variables removed in commit 832c6fd with proper defaults (was Re: [patch] ox-koma-letter.el: clean-up/semantic bug [4/4]) 2013-05-25 20:51 ` [PATCH] ox-koma-letter.el: Reintroduce variables removed in commit 832c6fd with proper defaults (was Re: [patch] ox-koma-letter.el: clean-up/semantic bug [4/4]) Robert Klein 2013-05-25 21:41 ` [PATCH] ox-koma-letter.el: Reintroduce variables removed in commit 832c6fd with proper defaults Rasmus @ 2013-05-26 11:04 ` Viktor Rosenfeld 1 sibling, 0 replies; 48+ messages in thread From: Viktor Rosenfeld @ 2013-05-26 11:04 UTC (permalink / raw) To: Robert Klein; +Cc: emacs-orgmode, Rasmus Hi Robert, Robert Klein wrote: > Hello, > On 05/25/2013 03:57 PM, Rasmus wrote: > > Alan Schmitt <alan.schmitt@polytechnique.org> writes: > > > >> Hello, > >> > >> Viktor Rosenfeld writes: > >> > >>> Hi Robert, > >>> > >>> Robert Klein wrote: > >>> > >>>> Hi, > >>>> > >>>> FWIW, from a users view it would be nice if: > >>>> > >>>> - Use Author/Email information from org file > >>>> - If not present use information from LCO file > >>>> - if neither org file nor LCO file has any information use > >>>> user-full-name and user-email-address > >>>> > >>>> Could this be solved by having several e.g. `setkomavar{fromname}' > >>>> and so on in the tex file, so is created as follows: > > > > I'd go with 'no'. It's not aesthetically pleasing and I don't want my > > output to look like LyX. When feasible we should go for beautiful > > output. This isn't always the case at the moment, but still. > > > >>>> if no #+AUTHOR in org-file and user-full-name is set: > >>>> add user-full-name > >>>> if #+LCO(s) in org-file: > >>>> add LCO file(s) > >>>> if #+AUTHOR in org-file: > >>>> add \setkomavar{fromname}{#+AUTHOR} > >>>> .... same for email > > > > Currently the ordering is: #+AUTHOR > #+LCO and AUTHOR default to > > (user-full-name). > > hmm, sorry, I did not express myself in a good way. > > what I meant is, if #+AUTHOR defaults to (user-full-name), could the > \setkomavar commands be placed /before/ \LoadLetterOption in the TeX > file, and after \LoadLetterOptions if #+AUTHOR is set in the .org file? > > So you'd still get only one set of \setkomavar in the TeX file, but get > a (for me) more useful order of #+AUTHOR != (user-full-name) > #+LCO > > #+AUTHOR == (user-full-name) I'm still having trouble to understand what would be gained by placing \setkomavar{author}{.} before \LoadLetterOption if it defaults to user-full-name. Could you maybe describe your setup and what you want to achieve? Cheers, Viktor > > > Best regards > Robert > > ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: [patch] ox-koma-letter.el: credit [1/4] 2013-05-20 0:28 [patch] ox-koma-letter.el: credit [1/4] Rasmus ` (2 preceding siblings ...) 2013-05-20 0:54 ` [patch] ox-koma-letter.el: clean-up/semantic bug [4/4] Rasmus @ 2013-05-20 15:44 ` Alan Schmitt 2013-05-20 15:49 ` Rasmus 2013-05-21 17:06 ` Viktor Rosenfeld 4 siblings, 1 reply; 48+ messages in thread From: Alan Schmitt @ 2013-05-20 15:44 UTC (permalink / raw) To: Rasmus; +Cc: n.goaziou, emacs-orgmode Rasmus writes: > This one just updates the credit: most importantly with Viktor. This is a great idea, however you seem to have forgotten the patch. Alan ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: [patch] ox-koma-letter.el: credit [1/4] 2013-05-20 15:44 ` [patch] ox-koma-letter.el: credit [1/4] Alan Schmitt @ 2013-05-20 15:49 ` Rasmus 2013-05-20 16:01 ` Alan Schmitt 0 siblings, 1 reply; 48+ messages in thread From: Rasmus @ 2013-05-20 15:49 UTC (permalink / raw) To: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 282 bytes --] Alan Schmitt <alan.schmitt@polytechnique.org> writes: > Rasmus writes: > >> This one just updates the credit: most importantly with Viktor. > > This is a great idea, however you seem to have forgotten the patch. Right. Need to figure out that git email program . . . -- ⠠⠵ [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-Updated-author-list-of-ox-koma-letter.el.patch --] [-- Type: text/x-patch, Size: 1235 bytes --] From 4dfe8ba80661c4e35c9f3de8313b8ddef65846a3 Mon Sep 17 00:00:00 2001 From: "rasmus.pank" <rasmus@gmx.us> Date: Sun, 19 May 2013 15:43:24 +0200 Subject: [PATCH 1/4] Updated author list of ox-koma-letter.el * ox-koma-letter.el: added Viktor Rosenfeld and Rasmus as contributors to ox-koma-letters.el. TINYCHANGE --- contrib/lisp/ox-koma-letter.el | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el index 96c0569..2389025 100644 --- a/contrib/lisp/ox-koma-letter.el +++ b/contrib/lisp/ox-koma-letter.el @@ -4,6 +4,9 @@ ;; Author: Nicolas Goaziou <n.goaziou AT gmail DOT com> ;; Alan Schmitt <alan.schmitt AT polytechnique DOT org> +;; Viktor Rosenfeld <listuser36 AT gmail DOT com> +;; Rasmus Pank Roulund <emacs AT pank DOT eu> + ;; Keywords: org, wp, tex ;; This program is free software: you can redistribute it and/or modify @@ -265,7 +268,7 @@ holding export options." (signature (plist-get info :signature))) (concat ;; Letter Class Option File - (when lco + (when lco (let ((lco-files (split-string lco " ")) (lco-def "")) (dolist (lco-file lco-files lco-def) -- 1.8.2.3 ^ permalink raw reply related [flat|nested] 48+ messages in thread
* Re: [patch] ox-koma-letter.el: credit [1/4] 2013-05-20 15:49 ` Rasmus @ 2013-05-20 16:01 ` Alan Schmitt 0 siblings, 0 replies; 48+ messages in thread From: Alan Schmitt @ 2013-05-20 16:01 UTC (permalink / raw) To: Rasmus; +Cc: emacs-orgmode Rasmus writes: > Alan Schmitt <alan.schmitt@polytechnique.org> writes: > >> Rasmus writes: >> >>> This one just updates the credit: most importantly with Viktor. >> >> This is a great idea, however you seem to have forgotten the patch. > > Right. Need to figure out that git email program . . . I applied it. I had to edit it to remove the spurious diff at the end for it to apply cleanly, though. Alan ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: [patch] ox-koma-letter.el: credit [1/4] 2013-05-20 0:28 [patch] ox-koma-letter.el: credit [1/4] Rasmus ` (3 preceding siblings ...) 2013-05-20 15:44 ` [patch] ox-koma-letter.el: credit [1/4] Alan Schmitt @ 2013-05-21 17:06 ` Viktor Rosenfeld 4 siblings, 0 replies; 48+ messages in thread From: Viktor Rosenfeld @ 2013-05-21 17:06 UTC (permalink / raw) To: Rasmus; +Cc: emacs-orgmode Hi, Rasmus wrote: > This one just updates the credit: most importantly with Viktor. Cool, thanks! > - Is it me or is there no option to have git send-email just fix a > the subject and heads and let the email program do the rest?! The > manual and various blog post did not reveal how on earth to get it > to just use Gnus for sending. . . The program seems not really to > follow the Unix principle. . . I use format-patch to create the patch and send them manually. But getting send-email to work would automate some things. Cheers, Viktor ^ permalink raw reply [flat|nested] 48+ messages in thread
end of thread, other threads:[~2013-05-27 20:42 UTC | newest] Thread overview: 48+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-05-20 0:28 [patch] ox-koma-letter.el: credit [1/4] Rasmus 2013-05-20 0:40 ` [patch] ox-koma-letter.el: subject changes [2/4] Rasmus 2013-05-20 15:49 ` Alan Schmitt 2013-05-20 18:23 ` Rasmus 2013-05-21 7:24 ` Alan Schmitt 2013-05-21 15:52 ` Viktor Rosenfeld 2013-05-21 17:48 ` Rasmus 2013-05-20 0:51 ` [patch] ox-koma-letter.el: credit [3/4] Rasmus 2013-05-20 15:52 ` Alan Schmitt 2013-05-21 16:56 ` Viktor Rosenfeld 2013-05-21 17:35 ` Rasmus 2013-05-21 20:06 ` Viktor Rosenfeld [not found] ` <87zjvo7xkl.fsf@pank.eu> [not found] ` <20130522145312.GB61443@kenny.local> 2013-05-22 17:16 ` Rasmus 2013-05-22 17:38 ` Viktor Rosenfeld 2013-05-20 0:54 ` [patch] ox-koma-letter.el: clean-up/semantic bug [4/4] Rasmus [not found] ` <m2ehd1tziq.fsf@polytechnique.org> 2013-05-21 9:05 ` Rasmus 2013-05-21 11:32 ` Alan Schmitt 2013-05-21 12:22 ` Rasmus 2013-05-21 17:02 ` Viktor Rosenfeld 2013-05-21 18:13 ` Rasmus 2013-05-21 19:54 ` Viktor Rosenfeld 2013-05-21 23:23 ` Rasmus 2013-05-22 14:39 ` Viktor Rosenfeld 2013-05-22 22:06 ` [PATCH] ox-koma-letter.el: Reintroduce variables removed in commit 832c6fd with proper defaults (was Re: [patch] ox-koma-letter.el: clean-up/semantic bug [4/4]) Viktor Rosenfeld 2013-05-25 5:13 ` Robert Klein 2013-05-25 8:05 ` Viktor Rosenfeld 2013-05-25 9:20 ` Alan Schmitt 2013-05-25 13:57 ` Rasmus 2013-05-25 17:03 ` Viktor Rosenfeld 2013-05-25 17:48 ` [PATCH][ox-koma-letter]: sender, email and cleanup (was: [PATCH] ox-koma-letter.el: Reintroduce variables removed in commit 832c6fd with proper defaults) Rasmus 2013-05-25 21:27 ` [PATCH][ox-koma-letter]: sender, email and cleanup Rasmus 2013-05-26 10:58 ` Viktor Rosenfeld 2013-05-26 14:38 ` Rasmus 2013-05-26 10:54 ` [PATCH][ox-koma-letter]: sender, email and cleanup (was: [PATCH] ox-koma-letter.el: Reintroduce variables removed in commit 832c6fd with proper defaults) Viktor Rosenfeld 2013-05-26 14:36 ` [PATCH][ox-koma-letter]: sender, email and cleanup Rasmus 2013-05-27 6:25 ` Alan Schmitt 2013-05-27 9:22 ` Xavier Garrido 2013-05-27 9:51 ` Rasmus 2013-05-27 18:31 ` Viktor Rosenfeld 2013-05-27 20:42 ` Xavier Garrido 2013-05-26 14:51 ` Rasmus 2013-05-25 20:51 ` [PATCH] ox-koma-letter.el: Reintroduce variables removed in commit 832c6fd with proper defaults (was Re: [patch] ox-koma-letter.el: clean-up/semantic bug [4/4]) Robert Klein 2013-05-25 21:41 ` [PATCH] ox-koma-letter.el: Reintroduce variables removed in commit 832c6fd with proper defaults Rasmus 2013-05-26 11:04 ` [PATCH] ox-koma-letter.el: Reintroduce variables removed in commit 832c6fd with proper defaults (was Re: [patch] ox-koma-letter.el: clean-up/semantic bug [4/4]) Viktor Rosenfeld 2013-05-20 15:44 ` [patch] ox-koma-letter.el: credit [1/4] Alan Schmitt 2013-05-20 15:49 ` Rasmus 2013-05-20 16:01 ` Alan Schmitt 2013-05-21 17:06 ` Viktor Rosenfeld
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).