emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] [patch, koma-letter] Change of subject behavior


From: Nicolas Goaziou
Subject: Re: [O] [patch, koma-letter] Change of subject behavior
Date: Wed, 18 Mar 2015 21:27:53 +0100

Rasmus <address@hidden> writes:

> -  (cdr (assoc (org-koma-letter--get-value key)
> -           org-koma-letter-special-contents)))
> +  (cdr (assoc-string (org-koma-letter--get-value key)
> +                  org-koma-letter-special-contents)))

AFAIU, this is a bugfix, so it should go in a separate commit.

> +  (let ((special-tag (car (org-koma-letter--special-headline headline 
> info))))
> +    (if special-tag
> +     (progn (push (cons special-tag contents) 
> org-koma-letter-special-contents)
> +            "")
> +      contents)))

Nitpick:

  (if (not special-tag) contents
    (push ...)
    "")

In this case, I suggest to change `org-koma-letter--special-headline'
into `org-koma-letter--special-tag', where the latter explicitly returns
special tag associated to the current headline, or nil (this skips the
`car' part).

> +(defun org-koma-letter--special-headline (headline info)
> +  "Nonnil if HEADLINE is a special headline."
> +  (let ((special-tags (plist-get info :special-tags)))
> +    (mapcar (lambda (tag) (assoc-string tag special-tags))
> +         (org-export-get-tags headline info))))

"Non-nil"

Also, the docstring should document INFO. Moreover, it isn't really
a predicate anymore, since you're using the value returned. Thus, that
value should be explained.

Eventually, since you're only interested in the first special tag
encountered, it may be cleaner to exit early, e.g.,

  (defun org-koma-letter--special-tag (headline info)
    "Return special tag associated to HEADLINE, as a symbol, or nil.
  INFO is the current state of the export process, as a plist."
    (let ((special-tags (plist-get info :special-tags)))
      (catch 'exit
        (dolist (tag (org-export-get-tags headline info))
          (let ((special-match (assoc-string tag special-tags)))
            (when special-match (throw 'exit (car special-match))))))))


> +   (format "\\opening{%s}\n\n"
> +        (org-export-data
> +         (or (org-string-nw-p (plist-get info :opening))
> +             (when (plist-get info :with-headline-opening)
> +               (org-element-map (org-element-parse-buffer) 'headline
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^
                                  (plist-get info :parse-tree)

Regards,



reply via email to

[Prev in Thread] Current Thread [Next in Thread]