From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasmus Subject: [patch] ox-koma-letter Date: Mon, 25 Feb 2013 21:25:58 +0100 Message-ID: <87vc9gkund.fsf@pank.eu> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:51226) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UA4ct-0002VA-97 for emacs-orgmode@gnu.org; Mon, 25 Feb 2013 15:26:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UA4cq-00078g-Dk for emacs-orgmode@gnu.org; Mon, 25 Feb 2013 15:26:18 -0500 Received: from plane.gmane.org ([80.91.229.3]:52391) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UA4cq-00078F-3h for emacs-orgmode@gnu.org; Mon, 25 Feb 2013 15:26:16 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UA4d8-0000Ex-3I for emacs-orgmode@gnu.org; Mon, 25 Feb 2013 21:26:34 +0100 Received: from dynamic-adsl-94-34-152-98.clienti.tiscali.it ([94.34.152.98]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 25 Feb 2013 21:26:34 +0100 Received: from rasmus by dynamic-adsl-94-34-152-98.clienti.tiscali.it with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 25 Feb 2013 21:26:34 +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: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Hi, I have been working on extending the KOMA letter support in Org. The backend is still rough and I would like to more stuff such as designing firstfood and firsthead with org elements (e.g. I use a tabularx for my firstfood with varioues stuff). I have changed the following objects: 1. Make keys sane; no reason why open pdf is O rather than o and why k is used in place of l (as in the tex exporter). 2. Added AFTER_CLOSING and AFTER_LETTER keywords for arbitrary code after \closing{.} and \end{letter}, respectively. a. A weird bug I don't understand is why I cannot have #+AFTER_CLOSING{\ps{ps:}} b. Would it be better to have a dedicated, say, PS and ENCL rather than the generic AFTER_CLOSING? 3. Added from-bank, invoice and other keywords like that. Still many to go, but some of them would probably need some thought. For instance firstfoot should work differently depending on whether it is given a NAMEd table or a string. Any though? I'm not a good programmer, so if someone could look through it, and say whether it's OK it'd be happy to work more on in and submit it a proper patch if deemed worthy. Also, if someone has thoughts on how to improve the letter experience that would be interesting to hear. I'd love to hear an explanation of point a. above. Further, perhaps we should remove all the silly defaults from the defcustoms in ox-koma-letter? –Rasmus -- . . . Stallman was indeed the tallest possible mountain and by standing on his shoulders you could see forever. . . --=-=-= Content-Type: text/plain Content-Disposition: attachment; filename=koma.diff diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el index 07633e3..069d458 100644 --- a/contrib/lisp/ox-koma-letter.el +++ b/contrib/lisp/ox-koma-letter.el @@ -91,6 +91,23 @@ :group 'org-export-koma-letter :type 'string) +(defcustom org-koma-letter-from-bank "" + "Sender's bank account, as a string." + :group 'org-export-koma-letter + :type 'string) + +(defcustom org-koma-letter-from-fax "" + "Sender's fax number, as a string." + :group 'org-export-koma-letter + :type 'string) + +(defcustom org-koma-letter-from-url "" + "Sender's url, as a string." + :group 'org-export-koma-letter + :type 'string) + + + (defcustom org-koma-letter-opening "Dear Sir," "Letter's opening, as a string." :group 'org-export-koma-letter @@ -106,33 +123,42 @@ :group 'org-export-koma-letter :type 'string) - + ;;; Define Back-End (org-export-define-derived-backend koma-letter latex :options-alist - ((:closing "CLOSING" nil org-koma-letter-closing) + ((:after-closing "AFTER_CLOSING" nil "" newline) + (:after-letter "AFTER_LETTER" nil "" newline) + (:closing "CLOSING" nil org-koma-letter-closing) (:from-address "FROM_ADDRESS" nil org-koma-letter-from-address newline) + (:from-bank "FROM_BANK" nil org-koma-letter-from-bank t) + (:from-fax "FROM_FAX" nil org-koma-letter-from-fax t) + (:from-url "FROM_FAX" nil org-koma-letter-from-url t) + (:invoice "INVOICE" nil "" t) + (:my-ref "MY_REF" nil "" t) + (:your-ref "YOUR_REF" nil "" t) (:lco "LCO" nil org-koma-letter-class-option-file) (:opening "OPENING" nil org-koma-letter-opening) (:phone-number "PHONE_NUMBER" nil org-koma-letter-phone-number) - (:signature "SIGNATURE" nil nil newline) - (:to-address "TO_ADDRESS" nil nil newline)) + (:signature "SIGNATURE" nil user-full-name newline) + (:to-address "TO_ADDRESS" nil nil newline) + ) :translate-alist ((export-block . org-koma-letter-export-block) (export-snippet . org-koma-letter-export-snippet) (keyword . org-koma-letter-keyword) (template . org-koma-letter-template)) :menu-entry (?k "Export with KOMA Scrlttr2" - ((?K "As LaTeX buffer" org-koma-letter-export-as-latex) - (?k "As LaTeX file" org-koma-letter-export-to-latex) + ((?L "As LaTeX buffer" org-koma-letter-export-as-latex) + (?l "As LaTeX file" org-koma-letter-export-to-latex) (?p "As PDF file" org-koma-letter-export-to-pdf) - (?O "As PDF file and open" + (?o "As PDF file and open" (lambda (a s v b) (if a (org-koma-letter-export-to-pdf t s v b) (org-open-file (org-koma-letter-export-to-pdf nil s v b)))))))) - + ;;; Transcode Functions ;;;; Export Block @@ -204,7 +230,15 @@ holding export options." (format "\\setkomavar{signature}{%s}\n" (plist-get info :signature)) (format "\\setkomavar{fromemail}{%s}\n" (org-export-data (plist-get info :email) info)) + (format "\\setkomavar{frombank}{%s}\n" + (org-export-data (plist-get info :from-bank) info)) (format "\\setkomavar{fromphone}{%s}\n" (plist-get info :phone-number)) + (format "\\setkomavar{frombank}{%s}\n" (plist-get info :from-bank)) + (format "\\setkomavar{fromfax}{%s}\n" (plist-get info :from-fax)) + (format "\\setkomavar{fromurl}{%s}\n" (plist-get info :from-url)) + (format "\\setkomavar{myref}{%s}\n" (plist-get info :my-ref)) + (format "\\setkomavar{yourref}{%s}\n" (plist-get info :your-ref)) + (format "\\setkomavar{invoice}{%s}\n" (plist-get info :invoice)) ;; Date. (format "\\date{%s}\n" (org-export-data (plist-get info :date) info)) ;; Letter Class Option File @@ -221,11 +255,13 @@ holding export options." contents ;; Closing. (format "\n\\closing{%s}\n\n" (plist-get info :closing)) + (format "\n%s\n" (plist-get info :after-closing)) ;; Letter end. - "\\end{letter}\n\\end{document}")) + "\\end{letter}\n\n" + (format "%s" (plist-get info :after-letter)) + "\\end{document}")) - ;;; Commands ;;;###autoload --=-=-=--