emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Thomas S. Dye" <tsd@tsdye.com>
To: Bastien <bastien.guerry@wikimedia.fr>
Cc: Org Mode <emacs-orgmode@gnu.org>, mail@christianmoe.com
Subject: Re: org-add-link-type
Date: Tue, 18 Jan 2011 07:45:35 -1000	[thread overview]
Message-ID: <8B0421E0-25BE-4773-9D6B-DC65E0478EF0@tsdye.com> (raw)
In-Reply-To: <87fwsr1iqu.fsf@altern.org>

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" <tsd@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

  reply	other threads:[~2011-01-18 17:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-27  0:29 org-add-link-type Thomas S. Dye
2010-12-27  6:10 ` org-add-link-type Christian Moe
2010-12-27  7:06   ` org-add-link-type Thomas S. Dye
2010-12-27 10:58     ` org-add-link-type Christian Moe
2011-01-17 18:35     ` org-add-link-type Bastien
2011-01-18 17:45       ` Thomas S. Dye [this message]
2011-02-12 22:39         ` org-add-link-type Bastien
2011-02-12 23:16           ` org-add-link-type Thomas S. Dye
2011-02-12 23:32             ` org-add-link-type 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=8B0421E0-25BE-4773-9D6B-DC65E0478EF0@tsdye.com \
    --to=tsd@tsdye.com \
    --cc=bastien.guerry@wikimedia.fr \
    --cc=emacs-orgmode@gnu.org \
    --cc=mail@christianmoe.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).