Re: [O] [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])
Hi Robert, Robert Klein wrote: Hello, On 05/25/2013 03:57 PM, Rasmus wrote: Alan Schmitt alan.schm...@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
Re: [O] [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])
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_wu...@example.com} ... \setkomavar{fromname}{Reiner Zufall} \setkomavar{fromemail}{reiner_zuf...@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 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. I've put my changes into a patch against the current master (commit 06cdb2d2). Could you check it with your setup? Cheers, Viktor
Re: [O] [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])
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
Re: [O] [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])
Alan Schmitt alan.schm...@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 -- ⠠⠵
Re: [O] [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])
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.schm...@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 -- ⠠⠵
Re: [O] [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])
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_wu...@example.com} ... \setkomavar{fromname}{Reiner Zufall} \setkomavar{fromemail}{reiner_zuf...@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 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. I've put my changes into a patch against the current master (commit 06cdb2d2). Could you check it with your setup? Cheers, Viktor
[O] [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])
Hi Rasmus, Viktor Rosenfeld wrote: 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. I've put my changes into a patch against the current master (commit 06cdb2d2). Could you check it with your setup? Cheers, Viktor From 271c6548aa1f0b61763c30b7116dbb3325364683 Mon Sep 17 00:00:00 2001 From: Viktor Rosenfeld listuse...@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