From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Subject: Re: Spelled out example of org-latex-format-headline-function customization? Date: Tue, 19 Mar 2013 16:51:16 +0100 Message-ID: <871ubbs80b.fsf@bzg.ath.cx> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([208.118.235.92]:57496) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UHyp0-0004ae-LT for emacs-orgmode@gnu.org; Tue, 19 Mar 2013 11:51:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UHyov-0003lF-Hg for emacs-orgmode@gnu.org; Tue, 19 Mar 2013 11:51:30 -0400 Received: from mail-wi0-x22d.google.com ([2a00:1450:400c:c05::22d]:52597) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UHyov-0003l4-9r for emacs-orgmode@gnu.org; Tue, 19 Mar 2013 11:51:25 -0400 Received: by mail-wi0-f173.google.com with SMTP id hq4so4127904wib.6 for ; Tue, 19 Mar 2013 08:51:24 -0700 (PDT) In-Reply-To: (John Hendy's message of "Mon, 18 Mar 2013 21:56:06 -0500") 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: John Hendy Cc: emacs-orgmode Hi John, John Hendy 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