emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Bastien <bzg@altern.org>
To: John Hendy <jw.hendy@gmail.com>
Cc: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Re: Spelled out example of org-latex-format-headline-function customization?
Date: Tue, 19 Mar 2013 16:51:16 +0100	[thread overview]
Message-ID: <871ubbs80b.fsf@bzg.ath.cx> (raw)
In-Reply-To: <CA+M2ft8c9FHiy2Qvcf3XaAFTKSnLK-UoAkXcsiK8Xi5ji0xMhw@mail.gmail.com> (John Hendy's message of "Mon, 18 Mar 2013 21:56:06 -0500")

Hi John,

John Hendy <jw.hendy@gmail.com> 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

  reply	other threads:[~2013-03-19 15:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-19  2:56 Spelled out example of org-latex-format-headline-function customization? John Hendy
2013-03-19 15:51 ` Bastien [this message]
2013-03-19 16:18   ` John Hendy
2013-03-19 16:30     ` Charles Berry
2013-03-19 16:37     ` Bastien

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=871ubbs80b.fsf@bzg.ath.cx \
    --to=bzg@altern.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=jw.hendy@gmail.com \
    /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).