From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: [patch, koma-letter] Change of subject behavior Date: Wed, 18 Mar 2015 21:27:53 +0100 Message-ID: <873852125y.fsf@nicolasgoaziou.fr> References: <87d247h6eo.fsf@gmx.us> <87wq2f1gqz.fsf@nicolasgoaziou.fr> <87mw3bdyv4.fsf@gmx.us> <87bnjr1au0.fsf@nicolasgoaziou.fr> <877fufdwf0.fsf@gmx.us> <877fue1qjm.fsf@nicolasgoaziou.fr> <878ueuv5rm.fsf@gmx.us> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:54004) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YYKYF-0007kb-FI for emacs-orgmode@gnu.org; Wed, 18 Mar 2015 16:26:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YYKYA-0007Vj-1o for emacs-orgmode@gnu.org; Wed, 18 Mar 2015 16:26:51 -0400 Received: from relay5-d.mail.gandi.net ([2001:4b98:c:538::197]:42314) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YYKY9-0007T2-Rl for emacs-orgmode@gnu.org; Wed, 18 Mar 2015 16:26:45 -0400 In-Reply-To: <878ueuv5rm.fsf@gmx.us> (rasmus@gmx.us's message of "Wed, 18 Mar 2015 13:39:41 +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: Rasmus Cc: emacs-orgmode@gnu.org Rasmus 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,