From mboxrd@z Thu Jan 1 00:00:00 1970 From: Viktor Rosenfeld Subject: [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]) Date: Thu, 23 May 2013 00:06:50 +0200 Message-ID: <20130522220650.GB68001@kenny.local> References: <87ehd2sc6t.fsf@pank.eu> <87wqqsd7p8.fsf@pank.eu> <874ndwcyjx.fsf@pank.eu> <20130521170259.GB56408@client199-78.wlan.hu-berlin.de> <87ehd09p6r.fsf@pank.eu> <20130521195413.GA58739@kenny.local> <87vc6b9atm.fsf@pank.eu> <20130522143923.GA61443@kenny.local> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="W/nzBZO5zC0uMSeA" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:51627) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfHBW-00076U-9o for emacs-orgmode@gnu.org; Wed, 22 May 2013 18:07:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UfHBR-0003zL-Bh for emacs-orgmode@gnu.org; Wed, 22 May 2013 18:07:02 -0400 Received: from mail-bk0-x22a.google.com ([2a00:1450:4008:c01::22a]:42539) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfHBR-0003zE-1x for emacs-orgmode@gnu.org; Wed, 22 May 2013 18:06:57 -0400 Received: by mail-bk0-f42.google.com with SMTP id jk13so1422555bkc.29 for ; Wed, 22 May 2013 15:06:56 -0700 (PDT) Content-Disposition: inline In-Reply-To: <20130522143923.GA61443@kenny.local> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Cc: Rasmus --W/nzBZO5zC0uMSeA Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi Rasmus, Viktor Rosenfeld wrote: > Hi Rasmus, > > Rasmus wrote: > > > Viktor Rosenfeld 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 --W/nzBZO5zC0uMSeA Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0001-ox-koma-letter.el-Reintroduce-variables-removed-in-c.patch" >From 271c6548aa1f0b61763c30b7116dbb3325364683 Mon Sep 17 00:00:00 2001 From: Viktor Rosenfeld 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 --W/nzBZO5zC0uMSeA--