From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasmus Subject: Re: small koma bug Date: Mon, 10 Mar 2014 14:24:56 +0100 Message-ID: <87bnxep4nr.fsf@gmx.us> References: 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]:55894) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WN0Ae-00012J-Kn for emacs-orgmode@gnu.org; Mon, 10 Mar 2014 09:23:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WN0AY-00039O-Lu for emacs-orgmode@gnu.org; Mon, 10 Mar 2014 09:23:08 -0400 Received: from mout.gmx.net ([212.227.15.19]:56893) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WN0AY-00038l-DH for emacs-orgmode@gnu.org; Mon, 10 Mar 2014 09:23:02 -0400 In-Reply-To: (Alan Schmitt's message of "Mon, 10 Mar 2014 09:44:10 +0100") 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 Hi Alan, Alan Schmitt writes: > I think I have found a small bug in ox-koma-letter, but to fix it I > would like your input. > > The bug: if "from-address" is not specified in the file, then it will be > set unconditionally to the empty string, even if it is specified in an > lco file. OK. AFAIK it's OK to leave out the fromaddress and fromname. > The reason of the bug is as follows. > > To set up the from address, we call this: > > #+begin_src emacs-lisp > (let ((from-address (org-koma-letter--determine-to-and-from info 'from= ))) > (and from-address (format "\\setkomavar{fromaddress}{%s}\n" from-add= ress))) > #+end_src How about: (let ((from-address (org-koma-letter--determine-to-and-from info 'from))) (and (org-string-nw-p from-address) (format "\\setkomavar{fromaddress}= {%s}\n" from-address))) Or more explicitly (let ((from-address (org-koma-letter--determine-to-and-from info 'from))) (when (org-string-nw-p from-address) (format "\\setkomavar{fromaddress= }{%s}\n" from-address))) > This uses this function: > #+begin_src emacs-lisp > (defun org-koma-letter--determine-to-and-from (info key) > "Given INFO determine KEY for the letter. > KEY should be `to' or `from'. > > `ox-koma-letter' allows two ways to specify TO and FROM. If both > are present return the preferred one as determined by > `org-koma-letter-prefer-special-headings'." > (let ((option (plist-get info (if (eq key 'to) :to-address :from-addres= s))) > (headline (org-koma-letter--get-tagged-contents key))) > (replace-regexp-in-string > "\n" "\\\\\\\\\n" > (org-trim > (or (if (plist-get info :special-headings) (or headline option) > (or option headline)) > ;; Fallback values. > (if (eq key 'to) "\\mbox{}" org-koma-letter-from-address)))))) > #+end_src I guess org-koma-letter-from-address can be left empty, but for instance 'to must have a value different from the empty string to not create a LaTeX error. As I said above, quick testing suggest this is not necessary for fromaddress. > As the empty string is considered as "true", we apply the format > function in the first code block. See below. > I would suggest to have "org-koma-letter-from-address" begin "nil" as > default. My question is: is it an allowed value for a string? You can use org-string-nw-p to test is S is only white-space. When Nicolas cleaned the file he made all (or most?) defaults into strings, so let's stick with that. Let me know if your happy with this. =E2=80=94Rasmus --=20 Summon the Mothership!