Re: [O] [patch] ox-koma-letter.el: credit [3/4]

2013-05-22 Thread Viktor Rosenfeld
Hi,

Rasmus wrote:

> Viktor Rosenfeld  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!!!
> 



Re: [O] [patch] ox-koma-letter.el: credit [3/4]

2013-05-22 Thread Rasmus
Viktor Rosenfeld  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!!!



Re: [O] [patch] ox-koma-letter.el: credit [3/4]

2013-05-21 Thread Viktor Rosenfeld
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
> 



Re: [O] [patch] ox-koma-letter.el: credit [3/4]

2013-05-21 Thread Rasmus
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



Re: [O] [patch] ox-koma-letter.el: credit [3/4]

2013-05-21 Thread Viktor Rosenfeld
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" 
> 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 "h

Re: [O] [patch] ox-koma-letter.el: credit [3/4]

2013-05-20 Thread Alan Schmitt
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



[O] [patch] ox-koma-letter.el: credit [3/4]

2013-05-19 Thread Rasmus

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!
>From eeaa129b6807465566be881b96a94e14706c9a28 Mon Sep 17 00:00:00 2001
From: "rasmus.pank" 
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.")
+
+
 
 ;;; 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 o