emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: Rasmus <rasmus@gmx.us>
Cc: emacs-orgmode@gnu.org
Subject: Re: [patch, ox-latex] better hyperref and title options
Date: Fri, 13 Feb 2015 00:59:29 +0100	[thread overview]
Message-ID: <87bnkyvfz2.fsf@nicolasgoaziou.fr> (raw)
In-Reply-To: <87bnl0ynd2.fsf@gmx.us> (rasmus@gmx.us's message of "Thu, 12 Feb 2015 01:39:21 +0100")

Hello,

Rasmus <rasmus@gmx.us> 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

  reply	other threads:[~2015-02-12 23:58 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-12  0:39 [patch, ox-latex] better hyperref and title options Rasmus
2015-02-12 23:59 ` Nicolas Goaziou [this message]
2015-02-15  1:53   ` Rasmus
2015-02-15 10:49     ` Nicolas Goaziou
2015-02-15 11:42       ` Rasmus
2015-02-15 12:57         ` Nicolas Goaziou
2015-02-15 13:11           ` Rasmus
2015-02-15 15:57             ` Nicolas Goaziou
2015-02-15 16:55               ` Rasmus
2015-02-19  1:26           ` Rasmus
2015-02-19  9:24             ` Nicolas Goaziou
2015-02-19 21:43               ` Rasmus
2015-02-19 22:58                 ` Nicolas Goaziou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bnkyvfz2.fsf@nicolasgoaziou.fr \
    --to=mail@nicolasgoaziou.fr \
    --cc=emacs-orgmode@gnu.org \
    --cc=rasmus@gmx.us \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).