From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Thomas S. Dye" Subject: Re: org-add-link-type Date: Tue, 18 Jan 2011 07:45:35 -1000 Message-ID: <8B0421E0-25BE-4773-9D6B-DC65E0478EF0@tsdye.com> References: <4D182DBE.8030504@christianmoe.com> <348CF591-80F3-414A-BDD4-895410F5DEA6@tsdye.com> <87fwsr1iqu.fsf@altern.org> Mime-Version: 1.0 (Apple Message framework v936) Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Return-path: Received: from [140.186.70.92] (port=42330 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PfFd4-0005gS-8o for emacs-orgmode@gnu.org; Tue, 18 Jan 2011 12:46:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PfFcl-0000iH-Ee for emacs-orgmode@gnu.org; Tue, 18 Jan 2011 12:46:02 -0500 Received: from oproxy3-pub.bluehost.com ([69.89.21.8]:59523) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1PfFcl-0000ey-8f for emacs-orgmode@gnu.org; Tue, 18 Jan 2011 12:45:43 -0500 In-Reply-To: <87fwsr1iqu.fsf@altern.org> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Bastien Cc: Org Mode , mail@christianmoe.com 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" 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