emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Orgmode] org-add-link-type


From: Thomas S. Dye
Subject: Re: [Orgmode] org-add-link-type
Date: Tue, 18 Jan 2011 07:45:35 -1000

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" <address@hidden> 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]