Aloha Bastien,
Thanks for looking at this. The problem isn't that the description is
being protected from conversion, it is that it is there at all. The
link in the example lacks a description and the documentation says
that in this case desc will be nil, so it was a surprise to find a
value being passed instead.
In the example code (and desc) is supposed to evaluate false if the
link lacks a description. However, it never evaluates to false.
I'm using the following code now, which tests for both the documented
and actual behavior when a description is absent from the link.
#+source: define-citet-link
#+begin_src emacs-lisp :results silent
(org-add-link-type
"citet" 'ebib
(lambda (path desc format)
(cond
((eq format 'latex)
(if (or (not desc) (equal 0 (search "citet:" desc)))
(format "\\citet{%s}" path)
(format "\\citet[%s]{%s}" desc path)
)))))
#+end_src
All the best,
Tom
On Jan 17, 2011, at 8:35 AM, Bastien wrote:
Hi Thomas,
"Thomas S. Dye" <t...@tsdye.com> writes:
(org-add-link-type
"citet" 'ebib
(lambda (path desc format)
(cond
((eq format 'latex)
(if (and desc)
(format "\\citet[%s]{%s}" desc path)
(format "\\citet{%s}" path))))))
[[citet:green84:_settl_patter_studies_ocean]]
yields this:
\citet[citet:green84:_settl\_patter\_studies\_ocean]
{green84:_settl_patter_studies_ocean}
This is because "_" chars are usually protected from conversion in
links, but the LaTeX exporter might be confused by links it doesn't
know.
What about this :
(org-add-link-type
"citet" 'ebib
(lambda (path desc format)
(cond
((eq format 'latex)
(if (and desc)
(org-export-latex-protect-string
(format "\\citet[%s]{%s}" desc path))
(org-export-latex-protect-string
(format "\\citet{%s}" path)))))))
Check for other uses of `org-export-latex-protect-string' in
org-latex.el to better understand in what contexts this function
is useful.
HTH,
--
Bastien
_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode