emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] Integration of RefTeX and LaTeX export


From: Nick Dokos
Subject: Re: [O] Integration of RefTeX and LaTeX export
Date: Fri, 17 Feb 2012 00:31:21 -0500

Andreas Willig <address@hidden> wrote:

> 
> Hi Thomas,
> 
> thanks for this hint. I have looked at this, the changed / added functions are
> below, everything else has not changed. I still have a problem.
> 
> I have created a new link type as you suggested and have consulted google
> on how to do it (my emacs-lisp-fu is not good enough to sort out directly what
> this function is doing ...). In my understanding the third argument is a 
> function
> that is called when an export process has started and a link is about to be
> exported. My first problem is: this handler function is never called, the 
> error
> message that i have inserted below does never appear. I have seen that the
> variable "org-link-types" contains the defined link type, and the variable
> "org-link-protocols" shows my handler.
> 
> My second problem is that the generated LaTeX output is
>   "\texttt{\cite{key}}"
> but it should simply be "\cite{key}". I would guess that the second problem
> is a corollary of the first one ...
> 
> Any ideas?
> 
> Andreas
> 

I'm pretty sure the second function is not quoted properly in your
org-add-link-type so it ends up actually getting called at the time of
the org-add-link-type is called.

Try the following:

--8<---------------cut here---------------start------------->8---
(defun rt-follow-handler (path)
  (message "dummy handler called, path = %s" path)
  (let ((arg (concat "\\cite{" path "}")))
    (reftex-view-crossref arg)))

(defun rt-export-handler  (path desc format)
  (message "my handler is called")
  (cond ((eq format 'latex)
         (if (or (not desc) (equal 0 (search "rtcite:" desc)))
             (format "\\cite{%s}" path)
           (format "\\cite[%s]{%s}" desc path)))))

(require 'org)
(org-add-link-type "rtcite" 
                   (function rt-follow-handler)
                   (function rt-export-handler))
--8<---------------cut here---------------end--------------->8---

By way of explanation:

I had this as part of a minimal .emacs and it seems to work more or
less OK: I replaced the error call with a message call, because it
actually triggered and blew up :-) The rt-export-handler needs tweaking
but you 'll know what to do better than I do when you see the latex
output.

I had to (require 'org) to pick up the definition of org-add-link-type:
that seems to be a missing autoload somewhere.

And finally I like to quote functions with function, not quote, for
compiled-code reasons, but in most cases, it won't make any difference:
use quotes if you prefer.

Nick

> ============================================
> 
> (defun rt-handler (path)
>   (message "dummy handler called, path = %s" path)
>   (let ((arg (concat "\\cite{" path "}")))
>     (reftex-view-crossref arg)))
> 
> (org-add-link-type "rtcite" 
>                  'rt-handler
>                  (lambda (path desc format)
>                    (error "my handler is called")
>                    (cond ((eq format 'latex)
>                           (if (or (not desc) (equal 0 (search "rtcite:" 
> desc)))
>                               (format "\\cite{%s}" path)
>                             (format "\\cite[%s]{%s}" desc path))))))
> 
> 
> ....



reply via email to

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