[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Spelled out example of org-latex-format-headline-function custom
From: |
Bastien |
Subject: |
Re: [O] Spelled out example of org-latex-format-headline-function customization? |
Date: |
Tue, 19 Mar 2013 16:51:16 +0100 |
User-agent: |
Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.3.50 (gnu/linux) |
Hi John,
John Hendy <address@hidden> writes:
> Am I missing the "docstring" (not sure what that is).
The "docstring" is the documentation string attached to a
function/command or a variable/option.
C-h v org-latex-format-headline-function RET
will show you the docstring of the variable.
C-h f org-latex-format-headline-default-function RET
will show you the docstring of the function.
> I think it would
> be wonderful to simply spell out what
> =org-latex-format-headline-default-function= *is* in plain language,
> in the customize buffer.
>
> ETA: perhaps the plain language docstring used to be there, but was
> then replaced with a function?
> - http://lists.gnu.org/archive/html/emacs-orgmode/2013-02/msg01306.html
Yes, that's the case.
> In looking through ox-latex.el, I found this:
>
> #+begin_src ox-latex.el
>
> (concat
> (and todo (format "{\\bfseries\\sffamily %s} " todo))
> (and priority (format "\\framebox{\\#%c} " priority))
> text
> (and tags
> (format "\\hfill{}\\textsc{%s}" (mapconcat 'identity tags ":")))))
>
> #+end_src
>
> For myself, not being familiar with elisp, it's unclear how to
> translate that to a variable setting. I'm thinking at least some of
> that is unnecessary for actually setting the variable. If not, my best
> guess was:
>
> #+begin_src .emacs
>
> (setq org-latex-format-headline-function (concat
> (and todo (format "{\\bfseries\\sffamily %s} " todo))
> (and priority (format "\\framebox{\\#%c} " priority))
> text
> (and tags
> (format "\\hfill{}\\textsc{%s}" (mapconcat 'identity tags ":")))))
>
> #+end_src
>
> That didn't work.
You need to
1) define a new function
(defun john-org-latex-headline-function (todo todo-type priority text tags)
"The docstring of my function."
(concat
(and todo (format "{\\bfseries\\sffamily %s} " todo))
(and priority (format "\\framebox{\\#%c} " priority))
text
(and tags
(format "\\hfill{}\\textsc{%s}" (mapconcat 'identity tags ":")))))
The function has 5 arguments : todo todo-type priority text tags
All these arguments are strings that you can manipulate in your
own function.
E.g.,
(and todo (format "{\\bfseries\\sffamily %s} " todo))
translates "If the todo argument has a value, then let's format
the string "{\\bfseries\\sffamily %s} " by replacing %s with the
todo string. Which results in e.g. "{\bfseries\sffamily TODO} "
Inside formatting strings, you need to escape the \ character,
i.e. to prepend it with another \ char.
> Thanks for enduring those of us with no elisp background knowledge.
That's actually an area where I think we should make things simple.
Nicolas and I have been exchanging a few ideas, but nothing stable
emerges yet.
Best,
--
Bastien