From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasmus Subject: Re: [PATCH][ox-koma-letter] changed-in-buffer, subject, minor fixes Date: Sat, 25 Jan 2014 14:44:48 +0100 Message-ID: <87bnz0jhv3.fsf@gmx.us> References: <87txf1xrnr.fsf@gmx.us> <8761ph8e38.fsf@gmx.us> <87ppnpuuuf.fsf@gmail.com> <871u058502.fsf@gmx.us> <878uudukcs.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48595) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W73Tb-00039Z-FG for emacs-orgmode@gnu.org; Sat, 25 Jan 2014 08:40:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W73TW-0000oa-1X for emacs-orgmode@gnu.org; Sat, 25 Jan 2014 08:40:47 -0500 Received: from mout.gmx.net ([212.227.15.19]:56432) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W73TV-0000kx-Mt for emacs-orgmode@gnu.org; Sat, 25 Jan 2014 08:40:41 -0500 Received: from W530 ([94.34.139.169]) by mail.gmx.com (mrgmx003) with ESMTPSA (Nemesis) id 0LdZAI-1VOKjl0T0k-00ih0D for ; Sat, 25 Jan 2014 14:40:39 +0100 In-Reply-To: <878uudukcs.fsf@gmail.com> (Nicolas Goaziou's message of "Sat, 18 Jan 2014 21:05:07 +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: n.goaziou@gmail.com Cc: alan.schmitt@polytechnique.org, emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Nicolas, Nicolas Goaziou writes: > Rasmus writes: > >> Nicolas Goaziou writes: >> >>>> I finally had the time to fix these old patches. Sorry about the >>>> wait. >>> >>> You should update Org first. I modified large parts of ox-koma-letter.el >>> recently so your patches will probably not apply. Also, some parts are >>> not necessary anymore. >> >> I did. . . And I formatted the patch against origin/master. I'll >> look into it. Thanks. > > After a cursory look, it seems that patches 1 and 2 are not necessary > anymore. I didn't tackle down subject vs title issue, so patch 3 is > needed. Though, I think it needs some changes to be applied. Would you give the attached patches a spin? I think they work nicely; only the second patch is non-trivial. Basically, one can ignore subject and title differences as now by setting org-koma-letter-prefer-subject to t and not use the SUBJECT keyword. I have set the default of -prefer-subject to nil per the discussion with Alan and Michael Strey. It should apply against master. =E2=80=93Rasmus --=20 Dung makes an excellent fertilizer --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Documentation-fixes-for-ox-koma-script.el.patch >From 10d5518e9f48f18898de138b98b3be97b446dbe3 Mon Sep 17 00:00:00 2001 From: Rasmus Date: Sat, 25 Jan 2014 14:08:15 +0100 Subject: [PATCH 1/2] Documentation fixes for ox-koma-script.el * ox-koma-letter.el commentary (org-koma-letter-use-backaddress): Better documentation. --- contrib/lisp/ox-koma-letter.el | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el index 7f2cd22..b1f37b8 100644 --- a/contrib/lisp/ox-koma-letter.el +++ b/contrib/lisp/ox-koma-letter.el @@ -105,11 +105,16 @@ ;; \[EXTRA]")) ;; ;; Then, in your Org document, be sure to require the proper class -;; with : +;; with: ;; ;; #+LATEX_CLASS: my-letter ;; ;; Or by setting `org-koma-letter-default-class'. +;; +;; You may have to load (LaTeX) Babel as well, e.g., by adding +;; it to `org-latex-packages-alist', +;; +;; (add-to-list 'org-latex-packages-alist '("AUTO" "babel" nil)) ;;; Code: @@ -252,7 +257,7 @@ This option can also be set with the OPTIONS keyword, e.g.: :group 'org-export-koma-letter) (defcustom org-koma-letter-use-backaddress nil - "Non-nil prints return address in small line above to address. + "Non-nil prints return address in line above to address. This option can also be set with the OPTIONS keyword, e.g.: \"backaddress:t\"." :group 'org-export-koma-letter -- 1.8.5.3 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0002-Allow-separate-subject-and-title-in-ox-koma-letter.patch >From 99cffa500dc86482bf217d725224cbbf19687711 Mon Sep 17 00:00:00 2001 From: Rasmus Date: Sat, 25 Jan 2014 14:15:03 +0100 Subject: [PATCH 2/2] Allow separate subject and title in ox-koma-letter * ox-koma-letter.el (org-koma-letter-use-title): New variable. (org-koma-letter-prefer-subject): New variable. (org-koma-letter-template): Allow separate subject and title. --- contrib/lisp/ox-koma-letter.el | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el index b1f37b8..d5ee1de 100644 --- a/contrib/lisp/ox-koma-letter.el +++ b/contrib/lisp/ox-koma-letter.el @@ -335,6 +335,14 @@ This option can also be set with the OPTIONS keyword, e.g.: :group 'org-export-koma-letter :type 'boolean) +(defcustom org-koma-letter-use-title t + "Non-nil means use a title in the letter if present. + +See also `org-koma-letter-prefer-subject' for the handling of +title versus subject." + :group 'org-export-koma-letter + :type 'boolean) + (defcustom org-koma-letter-default-class "default-koma-letter" "Default class for `org-koma-letter'. The value must be a member of `org-latex-classes'." @@ -348,6 +356,14 @@ A headline is only used if #+OPENING is not set. See also :group 'org-export-koma-letter :type 'boolean) +(defcustom org-koma-letter-prefer-subject nil + "Non-nil means title should be interpret as subject if subject is missing. + +This may be useful for older documents where the SUBJECT keyword +was not present." + :group 'org-export-koma-letter + :type 'boolean) + (defconst org-koma-letter-special-tags-in-letter '(to from) "Header tags related to the letter itself.") @@ -377,6 +393,7 @@ A headline is only used if #+OPENING is not set. See also (:opening "OPENING" nil org-koma-letter-opening) (:closing "CLOSING" nil org-koma-letter-closing) (:signature "SIGNATURE" nil org-koma-letter-signature newline) + (:subject "SUBJECT" nil nil space) (:special-headings nil "special-headings" org-koma-letter-prefer-special-headings) (:special-tags nil nil (append @@ -393,6 +410,8 @@ A headline is only used if #+OPENING is not set. See also (:with-phone nil "phone" org-koma-letter-use-phone) (:with-place nil "place" org-koma-letter-use-place) (:with-subject nil "subject" org-koma-letter-subject-format) + (:with-title nil "title" org-koma-letter-use-title) + (:with-title-as-subject nil "title-subject" org-koma-letter-prefer-subject) ;; Special properties non-nil when a setting happened in buffer. ;; They are used to prioritize in-buffer settings over "lco" ;; files. See `org-koma-letter-template'. @@ -598,17 +617,25 @@ holding export options." (format "\\date{%s}\n" (org-export-data (org-export-get-date info) info)) ;; Document start "\\begin{document}\n\n" - ;; Subject - (let ((with-subject (plist-get info :with-subject))) + ;; Subject and title + (let ((with-subject (plist-get info :with-subject)) + (title-as-subject (plist-get info :with-title-as-subject)) + (subject (org-string-nw-p (org-export-data (plist-get info :subject) info))) + (title (org-string-nw-p (org-export-data (plist-get info :title) info)))) (when with-subject (concat (unless (eq with-subject t) (format "\\KOMAoption{subject}{%s}\n" (if (symbolp with-subject) with-subject (mapconcat #'symbol-name with-subject ",")))) - (let ((subject (org-export-data (plist-get info :title) info))) - (and (org-string-nw-p subject) - (format "\\setkomavar{subject}{%s}\n\n" subject)))))) + (let ((subject (if title-as-subject (or subject title) subject)) + (title (if title-as-subject (and subject title) title))) + (concat + (and (org-string-nw-p subject) + (format "\\setkomavar{subject}{%s}\n" subject)) + (and (org-string-nw-p title) + (format "\\setkomavar{title}{%s}\n" title)) + (when (or (org-string-nw-p title) (org-string-nw-p subject)) "\n")))))) ;; Letter start. (format "\\begin{letter}{%%\n%s}\n\n" (org-koma-letter--determine-to-and-from info 'to)) -- 1.8.5.3 --=-=-=--