[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] [patch] ox-koma-letter.el: clean-up/semantic bug [4/4]
From: |
Viktor Rosenfeld |
Subject: |
Re: [O] [patch] ox-koma-letter.el: clean-up/semantic bug [4/4] |
Date: |
Wed, 22 May 2013 16:39:23 +0200 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
Hi Rasmus,
Rasmus wrote:
> Viktor Rosenfeld <address@hidden> 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.
#+BEGIN_SRC
(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-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))))
#+END_SRC
Cheers,
Viktor
[1]
http://www.gnu.org/software/emacs/manual/html_node/elisp/User-Identification.html#User-Identification
>
> –Rasmus
>
> --
> Dung makes an excellent fertilizer
> >From 92b07bac2d707f01e48796778453b67a9ecd1daa Mon Sep 17 00:00:00 2001
> From: "rasmus.pank" <address@hidden>
> Date: Wed, 22 May 2013 01:16:54 +0200
> Subject: [PATCH 5/5] Variables for author and email for ox-koma-letter and a
> bug fix.
>
> * ox-koma-letter.el (koma-letter): reintroduced koma-letter
> specif author and email.
> * ox-koma-letter.el (koma-letter): set
> org-koma-special-content to nil when exporting
>
> The former is needed so that author/email can be set in a LCO file.
>
> TINYCHANGE
> ---
> contrib/lisp/ox-koma-letter.el | 49
> +++++++++++++++++++++++-------------------
> 1 file changed, 27 insertions(+), 22 deletions(-)
>
> diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el
> index 020df52..92cf13a 100644
> --- a/contrib/lisp/ox-koma-letter.el
> +++ b/contrib/lisp/ox-koma-letter.el
> @@ -109,6 +109,12 @@
> :group 'org-export-koma-letter
> :type 'string)
>
> +(defcustom org-koma-letter-email user-mail-address
> + "The default email address stored in the letter." )
> +
> +(defcustom org-koma-letter-author user-full-name
> + "The default name of the sender." )
> +
> (defcustom org-koma-letter-signature "\\usekomavar{fromname}"
> "String used as the signature."
> :group 'org-export-koma-letter
> @@ -143,7 +149,6 @@ English manual of 2012-07-22)"
> :group 'org-export-koma-letter)
>
>
> -
> (defcustom org-koma-letter-use-backaddress t
> "Print return address in small line above to address."
> :group 'org-export-koma-letter
> @@ -179,7 +184,6 @@ Use `foldmarks:true' to activate default fold marks or
> :group 'org-export-koma-letter
> :type 'string)
>
> -
> (defconst org-koma-letter-special-tags-after-closing
> '("PS" "ENCL" "CC")
> "Headers tags to be inserted after closing")
> @@ -193,7 +197,7 @@ Use `foldmarks:true' to activate default fold marks or
> org-koma-letter-special-tags-after-closing)
> "Header tags with special meaning")
>
> -(defvar org-koma-letter-special-content nil "holds special
> +(defvar org-koma-letter-special-contents nil "holds special
> content temporarily.")
>
>
> @@ -203,10 +207,10 @@ content temporarily.")
> (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)
> + (:sender "AUTHOR" nil org-koma-letter-author)
> (: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)
> (:to-address "TO_ADDRESS" nil nil newline)
> (:place "PLACE" nil org-koma-letter-place)
> (:opening "OPENING" nil org-koma-letter-opening)
> @@ -275,29 +279,31 @@ channel."
> ;; Thanks, Luis!
>
> (defun org-koma-letter--get-tagged-content (tag info)
> - (cdr (assoc tag org-koma-letter-special-content)))
> + (cdr (assoc tag org-koma-letter-special-contents)))
>
>
> -(defun org-koma-letter-headline (headline conents info)
> +(defun org-koma-letter-headline (headline contents info)
> "Transcode a HEADLINE element from Org to LaTeX.
> CONTENTS holds the contents of the headline. INFO is a plist
> holding contextual informatio.n
>
> Note that if a headline is tagged with a tag from
> `org-koma-letter-special-tags' it will not be exported, but
> -stored in `org-koma-letter-special-content' and included at the
> +stored in `org-koma-letter-special-contents' and included at the
> appropriate place."
> (let*
> ((tags (and (plist-get info :with-tags)
> (org-export-get-tags headline info))))
> - (if (member (car tags) org-koma-letter-special-tags)
> - (cond ((member (car tags) '("PS" "ps"))
> - (progn
> - (push (cons (car tags) (concat (plist-get info :ps-prefix)
> contents))
> - org-koma-letter-special-content) nil))
> - (t (progn
> - (push (cons (car tags) contents)
> - org-koma-letter-special-content) nil)))
> + (if (member (upcase (car tags))
> + org-koma-letter-special-tags)
> + ;; (cond ((member (car tags) '("PS" "ps"))
> + ;; (progn
> + ;; (push (cons (car tags) (concat (plist-get info :ps-prefix)
> contents))
> + ;; org-koma-letter-special-contents) nil))
> + (progn
> + (push (cons (upcase (car tags)) contents)
> + org-koma-letter-special-contents)
> + nil)
> contents)))
>
>
> @@ -307,10 +313,9 @@ appropriate place."
> "Return complete document string after KOMA Scrlttr2 conversion.
> CONTENTS is the transcoded contents string. INFO is a plist
> holding export options."
> - ;; FIXME: instead of setq'ing org-koma-letter-special-content and
> + ;; FIXME: instead of setq'ing org-koma-letter-special-contents and
> ;; callying varioues stuff it might be nice to put a big let* around the
> templace
> ;; as in org-groff...
> - (setq org-koma-letter-special-content nil)
> (concat
> ;; Time-stamp.
> (and (plist-get info :time-stamp-file)
> @@ -412,15 +417,14 @@ holding export options."
> (format "\n\\closing{%s}\n\n" (plist-get info :closing))
> (let (after-closing)
> (dolist (ac org-koma-letter-special-tags-after-closing after-closing)
> - (let ((x (org-koma-letter--get-tagged-content ac info)))
> + (let ((x (org-koma-letter--get-tagged-content (upcase ac) info)))
> (when x (setq after-closing
> (concat after-closing
> ;; sometimes LaTeX complains about newlines
> ;; at the end of macros. Remove them.
> (replace-regexp-in-string
> "\n+$" ""
> - (format "\\%s{%s}" (downcase ac) x)))))
> - )))
> + (format "\\%s{%s}" (downcase ac) x))))))))
> ;; Letter end.
> "\\end{letter}\n"
> (let ((x (org-koma-letter--get-tagged-content "AFTER_LETTER" info)))
> @@ -464,6 +468,7 @@ Export is done in a buffer named \"*Org KOMA-LETTER
> Export*\". It
> will be displayed if `org-export-show-temporary-export-buffer' is
> non-nil."
> (interactive)
> + (let (org-koma-letter-special-contents)
> (if async
> (org-export-async-start
> (lambda (output)
> @@ -480,7 +485,7 @@ non-nil."
> subtreep visible-only body-only ext-plist)))
> (with-current-buffer outbuf (LaTeX-mode))
> (when org-export-show-temporary-export-buffer
> - (switch-to-buffer-other-window outbuf)))))
> + (switch-to-buffer-other-window outbuf))))))
>
> ;;;###autoload
> (defun org-koma-letter-export-to-latex
> --
> 1.8.2.3
>
- Re: [O] [patch] ox-koma-letter.el: credit [3/4], (continued)
Re: [O] [patch] ox-koma-letter.el: clean-up/semantic bug [4/4], Rasmus, 2013/05/19
- Message not available
- Re: [O] [patch] ox-koma-letter.el: clean-up/semantic bug [4/4], Rasmus, 2013/05/21
- Re: [O] [patch] ox-koma-letter.el: clean-up/semantic bug [4/4], Alan Schmitt, 2013/05/21
- Re: [O] [patch] ox-koma-letter.el: clean-up/semantic bug [4/4], Rasmus, 2013/05/21
- Re: [O] [patch] ox-koma-letter.el: clean-up/semantic bug [4/4], Viktor Rosenfeld, 2013/05/21
- Re: [O] [patch] ox-koma-letter.el: clean-up/semantic bug [4/4], Rasmus, 2013/05/21
- Re: [O] [patch] ox-koma-letter.el: clean-up/semantic bug [4/4], Viktor Rosenfeld, 2013/05/21
- Re: [O] [patch] ox-koma-letter.el: clean-up/semantic bug [4/4], Rasmus, 2013/05/21
- Re: [O] [patch] ox-koma-letter.el: clean-up/semantic bug [4/4],
Viktor Rosenfeld <=
- [O] [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]), Viktor Rosenfeld, 2013/05/22
- Re: [O] [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]), Robert Klein, 2013/05/25
- Re: [O] [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]), Viktor Rosenfeld, 2013/05/25
- Re: [O] [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]), Alan Schmitt, 2013/05/25
- Re: [O] [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]), Rasmus, 2013/05/25
- Re: [O] [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]), Viktor Rosenfeld, 2013/05/25
- [O] [PATCH][ox-koma-letter]: sender, email and cleanup (was: [PATCH] ox-koma-letter.el: Reintroduce variables removed in commit 832c6fd with proper defaults), Rasmus, 2013/05/25
- Re: [O] [PATCH][ox-koma-letter]: sender, email and cleanup, Rasmus, 2013/05/25
- Re: [O] [PATCH][ox-koma-letter]: sender, email and cleanup, Viktor Rosenfeld, 2013/05/26
- Re: [O] [PATCH][ox-koma-letter]: sender, email and cleanup, Rasmus, 2013/05/26