Re: [O] [patch] ox-koma-letter.el: clean-up/semantic bug [4/4]
Hi Rasmus, Rasmus wrote: Viktor Rosenfeld listuse...@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.p...@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
Re: [O] [patch] ox-koma-letter.el: clean-up/semantic bug [4/4]
Alan Schmitt alan.schm...@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
Re: [O] [patch] ox-koma-letter.el: clean-up/semantic bug [4/4]
Rasmus writes: Alan Schmitt alan.schm...@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
Re: [O] [patch] ox-koma-letter.el: clean-up/semantic bug [4/4]
Alan Schmitt alan.schm...@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!
Re: [O] [patch] ox-koma-letter.el: clean-up/semantic bug [4/4]
Hi, Rasmus wrote: Alan Schmitt alan.schm...@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!
Re: [O] [patch] ox-koma-letter.el: clean-up/semantic bug [4/4]
Viktor Rosenfeld listuse...@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. . .
Re: [O] [patch] ox-koma-letter.el: clean-up/semantic bug [4/4]
Hi, Rasmus wrote: Viktor Rosenfeld listuse...@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. . .
Re: [O] [patch] ox-koma-letter.el: clean-up/semantic bug [4/4]
Viktor Rosenfeld listuse...@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 fertilizerFrom 92b07bac2d707f01e48796778453b67a9ecd1daa Mon Sep 17 00:00:00 2001 From: rasmus.pank rasmus.p...@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)) -
Re: [O] [patch] ox-koma-letter.el: clean-up/semantic bug [4/4]
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 From 0cb47f73c2e3579a78c2ae7e7d9777012f142f20 Mon Sep 17 00:00:00 2001 From: rasmus.pank rasmus.p...@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