From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: [patch, ox-latex] better hyperref and title options Date: Fri, 13 Feb 2015 00:59:29 +0100 Message-ID: <87bnkyvfz2.fsf@nicolasgoaziou.fr> References: <87bnl0ynd2.fsf@gmx.us> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:51730) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YM3eM-0002GL-6A for emacs-orgmode@gnu.org; Thu, 12 Feb 2015 18:58:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YM3eI-00027g-V0 for emacs-orgmode@gnu.org; Thu, 12 Feb 2015 18:58:26 -0500 Received: from relay4-d.mail.gandi.net ([2001:4b98:c:538::196]:49285) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YM3eI-00027b-Lz for emacs-orgmode@gnu.org; Thu, 12 Feb 2015 18:58:22 -0500 In-Reply-To: <87bnl0ynd2.fsf@gmx.us> (rasmus@gmx.us's message of "Thu, 12 Feb 2015 01:39:21 +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 Hello, Rasmus writes: > This patch does two things. > > 1. Add better format-spec to ox-latex hyperref and title-command. > 2. Use this to extend basic hyperref formatting to include title, > author, language etc. > > Wrt the title-command, this is useful if you need one-off "custom" > formatting of a header in LaTeX, e.g. in ox-publish projects. OK. > (defcustom org-latex-title-command "\\maketitle" > "The command used to insert the title just after \\begin{document}. > -If this string contains the formatting specification \"%s\" then > -it will be used as a formatting string, passing the title as an > -argument." > + > +A number of formatting keys can be used to construct the command. > +See `org-latex-format-spec'." Since this is a defcustom, I think formatting keys should be listed in full in its docstring. > (defcustom org-latex-hyperref-template > - "\\hypersetup{\n pdfkeywords={%k},\n pdfsubject={%d},\n pdfcreator={%c}}\n" > + "\\hypersetup{\n pdfauthor={%a},\n pdftitle={%t},\n pdfkeywords={%k}, > + pdfsubject={%d},\n pdfcreator={%c}, \n pdflang={%l}}\n" > "Template for hyperref package options. > > -Value is a format string, which can contain the following placeholders: > - > - %k for KEYWORDS line > - %d for DESCRIPTION line > - %c for CREATOR line > +See `org-latex-format-spec' for placeholder keys. Ditto. > +(defun org-latex-format-spec (info) > + "Create a format-spec for e.g. `org-latex-hyperref-template'. > + > +Value is a format string, which can contain the following placeholders: > + > + %a for AUTHOR keyword > + %t for TITLE keyword > + %k for KEYWORDS line > + %d for DESCRIPTION line > + %c for CREATOR line > + %l for Language keyword > + %D for DATE keyword" > + > + `((?a . ,(or (org-export-data (plist-get info :author) info) "")) > + (?t . ,(or (org-export-data (plist-get info :title) info) "")) > + (?k . ,(or (plist-get info :keywords) "")) > + (?d . ,(or (plist-get info :description) "")) > + (?c . ,(if (plist-get info :with-creator) (plist-get info :creator) "")) > + (?l . ,(or (plist-get info :language) "")) > + (?D . ,(org-export-data (org-export-get-date info) info)))) Please rename it `org-latex--format-spec', this is clearly an internal function. Also, its docstring should refer to INFO parameter. > + (let ((template (plist-get info :latex-hyperref-template))) > + (and (stringp template) > + (format-spec template > + (org-latex-format-spec info)))) > ;; Document start. > "\\begin{document}\n\n" > ;; Title command. > - (let ((command (plist-get info :latex-title-command))) > + (let* ((title-command (plist-get info :latex-title-command)) > + (command (and (stringp title-command) > + (format-spec title-command > + (org-latex-format-spec info))))) This is sub-optimal: you're building the spec twice. I suggest to use a (let ((spec (org-latex--format-spec info)))) somewhere above. You can apply the changes once these issues are resolved. Thank you. Regards, -- Nicolas Goaziou