From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasmus Subject: Re: koma letter exporter: changing the priority of options Date: Sat, 17 Aug 2013 18:37:02 +0200 Message-ID: <87eh9s46kx.fsf@pank.eu> References: <20130609180059.GA2104@kenny.local> <874nd6we8q.fsf@pank.eu> <20130720115503.GA67549@kenny.local> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53663) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VAjV2-00073p-MV for emacs-orgmode@gnu.org; Sat, 17 Aug 2013 12:37:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VAjUx-0000yC-SS for emacs-orgmode@gnu.org; Sat, 17 Aug 2013 12:37:12 -0400 Received: from eumx.net ([91.82.101.43]:39701 helo=owm.eumx.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VAjUx-0000xt-Im for emacs-orgmode@gnu.org; Sat, 17 Aug 2013 12:37:07 -0400 In-Reply-To: (Alan Schmitt's message of "Mon, 22 Jul 2013 16:53:06 +0200") 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: alan.schmitt@polytechnique.org Cc: emacs-orgmode@gnu.org Alan, > alan.schmitt@polytechnique.org writes: > >> Yes, this is not satisfactory (and the email and author is also >> problematic in this regard). We need to know whether an option was set >> in the file, independently of its default value. Is there a way to do >> this? > > Thanks to Nicolas, I've been able to create a cleaner solution: we track > some of the variables (ones for which we currently output something by > default, typically because they are set or because we choose to always > output something, like from-phone), and we only output the code if the > variable was set in the file. Thus if nothing is set, the lco file > wins. Note that with this approach, one can have a default in the lco > that is overridden by the file, for instance for foldmarks or to display > phone numbers. > > Regarding the name and email, we output it before the lco if they are > not specified in the file, and after if they are. > > What do you think of this approach? Are there other variables we should > track? I'm so sorry I haven't looked at this before now despite promising to do it much earlier (off-list)! The changed in buffer approach is cleaver and elegant. Good job Alan and Nicolas!. > From 9a6995fe9dcbb792a76fd8f0737a02d4d4015f82 Mon Sep 17 00:00:00 2001 > From: Alan Schmitt > Date: Mon, 22 Jul 2013 16:46:02 +0200 > Subject: [PATCH] Koma exporter: Ensure customization to LCO files are tak= en > into account > > * contrib/lisp/ox-koma-letter.el: Change default values to match the scrl= ttr2 > default values. Track which options are set in the file and only output = the > corresponding options when they are changed. > --- > contrib/lisp/ox-koma-letter.el | 47 +++++++++++++++++++++++++++++++-----= ------ > 1 file changed, 35 insertions(+), 12 deletions(-) > > diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter= .el > index 44626a9..ff71bd3 100644 > --- a/contrib/lisp/ox-koma-letter.el > +++ b/contrib/lisp/ox-koma-letter.el > @@ -228,7 +228,7 @@ English manual of 2012-07-22)" >=20=20 >=20=20 >=20=20 > -(defcustom org-koma-letter-use-backaddress t > +(defcustom org-koma-letter-use-backaddress nil > "Print return address in small line above to address." > :group 'org-export-koma-letter > :type 'boolean) > @@ -243,12 +243,12 @@ Use `foldmarks:true' to activate default fold marks= or > :group 'org-export-koma-letter > :type 'string) > -(defcustom org-koma-letter-use-phone t > +(defcustom org-koma-letter-use-phone nil > "Print sender's phone number." > :group 'org-export-koma-letter > :type 'boolean) >=20=20 > -(defcustom org-koma-letter-use-email t > +(defcustom org-koma-letter-use-email nil > "Print sender's email address." > :group 'org-export-koma-letter > :type 'boolean) Great!=20=20 > @@ -287,9 +287,11 @@ Use `foldmarks:true' to activate default fold marks = or > org-koma-letter-default-class > org-latex-default-class) t) > (:author "AUTHOR" nil (org-koma-letter--get-custom org-koma-letter-a= uthor) t) > + (:author-changed-in-buffer-p "AUTHOR" nil nil t) > (:from-address "FROM_ADDRESS" nil nil newline) > (:phone-number "PHONE_NUMBER" nil org-koma-letter-phone-number) > (:email "EMAIL" nil (org-koma-letter--get-custom org-koma-letter-ema= il) t) > + (:email-changed-in-buffer-p "EMAIL" nil nil t) > (:to-address "TO_ADDRESS" nil nil newline) > (:place "PLACE" nil org-koma-letter-place) > (:opening "OPENING" nil org-koma-letter-opening) > @@ -306,9 +308,13 @@ Use `foldmarks:true' to activate default fold marks = or > (:with-after-letter nil "after-letter-order" > org-koma-letter-special-tags-after-letter) > (:with-backaddress nil "backaddress" org-koma-letter-use-backaddress) > + (:with-backaddress-changed-in-buffer-p nil "backaddress" nil) > (:with-foldmarks nil "foldmarks" org-koma-letter-use-foldmarks) > + (:with-foldmarks-changed-in-buffer-p nil "foldmarks" nil) > (:with-phone nil "phone" org-koma-letter-use-phone) > + (:with-phone-changed-in-buffer-p nil "phone" nil) > (:with-email nil "email" org-koma-letter-use-email) > + (:with-email-changed-in-buffer-p nil "email" nil) > (:with-place nil "place" org-koma-letter-use-place) > (:with-subject nil "subject" org-koma-letter-subject-format)) > :translate-alist '((export-block . org-koma-letter-export-block) > @@ -522,11 +528,19 @@ holding export options." > info))) > (let ((lco (plist-get info :lco)) > (author (plist-get info :author)) > + (author-set (plist-get info :author-changed-in-buffer-p)) > (from-address (org-koma-letter--determine-special-value info 'from)) > (phone-number (plist-get info :phone-number)) > (email (plist-get info :email)) > + (email-set (plist-get info :email-changed-in-buffer-p)) > (signature (plist-get info :signature))) > (concat > + ;; author or email not set in file: may be overridden by lco > + (unless author-set > + (when author (format "\\setkomavar{fromname}{%s}\n" > + (org-export-data author info)))) > + (unless email-set > + (when email (format "\\setkomavar{fromemail}{%s}\n" email))) Couldn't you use `and' and make it more compact? Not that it matters much. > ;; Letter Class Option File > (when lco > (let ((lco-files (split-string lco " ")) > @@ -535,11 +549,12 @@ holding export options." > (setq lco-def (format "%s\\LoadLetterOption{%s}\n" lco-def lco-file= ))) > lco-def)) > ;; Define "From" data. > - (when author (format "\\setkomavar{fromname}{%s}\n" > - (org-export-data author info))) > + (when (and author author-set) (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-n= umber)) > - (when email (format "\\setkomavar{fromemail}{%s}\n" email)) > + (when phone-number > + (format "\\setkomavar{fromphone}{%s}\n" phone-number)) > + (when (and email email-set) (format "\\setkomavar{fromemail}{%s}\n= " email)) > (when signature (format "\\setkomavar{signature}{%s}\n" signature)= ))) > ;; Date. > (format "\\date{%s}\n" (org-export-data (org-export-get-date info) in= fo)) > @@ -550,14 +565,22 @@ holding export options." > (format "\\setkomavar{place}{%s}\n" (if with-place place "")))) > ;; KOMA options > (let ((with-backaddress (plist-get info :with-backaddress)) > + (with-backaddress-set (plist-get info :with-backaddress-changed-in-buf= fer-p)) > (with-foldmarks (plist-get info :with-foldmarks)) > + (with-foldmarks-set (plist-get info :with-foldmarks-changed-in-buffer-= p)) > (with-phone (plist-get info :with-phone)) > - (with-email (plist-get info :with-email))) > + (with-phone-set (plist-get info :with-phone-changed-in-buffer-p)) > + (with-email (plist-get info :with-email)) > + (with-email-set (plist-get info :with-email-changed-in-buffer-p))) > (concat > - (format "\\KOMAoption{backaddress}{%s}\n" (if with-backaddress "tr= ue" "false")) > - (format "\\KOMAoption{foldmarks}{%s}\n" (if with-foldmarks with-fo= ldmarks "false")) > - (format "\\KOMAoption{fromphone}{%s}\n" (if with-phone "true" "fal= se")) > - (format "\\KOMAoption{fromemail}{%s}\n" (if with-email "true" "fal= se")))) > + (when with-backaddress-set > + (format "\\KOMAoption{backaddress}{%s}\n" (if with-backaddress "true" "= false"))) > + (when with-foldmarks-set > + (format "\\KOMAoption{foldmarks}{%s}\n" (if with-foldmarks with-foldmar= ks "false"))) > + (when with-phone-set > + (format "\\KOMAoption{fromphone}{%s}\n" (if with-phone "true" "false"))) > + (when with-email-set > + (format "\\KOMAoption{fromemail}{%s}\n" (if with-email "true" "false"))= ))) > ;; Document start > "\\begin{document}\n\n" > ;; Subject Looks OK. I didn't find any mistakes.=20=20 =E2=80=93Rasmus --=20 Hvor meget poesi tror De kommer ud af et glas isvand?