From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andreas Willig Subject: Re: Integration of RefTeX and LaTeX export Date: Fri, 17 Feb 2012 21:36:05 +1300 Message-ID: References: <24B979D4-6B28-4521-92F5-AED136335FB0@canterbury.ac.nz> <29415.1329456681@alphaville> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([140.186.70.92]:33910) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RyJKi-0001Dn-KQ for emacs-orgmode@gnu.org; Fri, 17 Feb 2012 03:38:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RyJKc-0000yO-5u for emacs-orgmode@gnu.org; Fri, 17 Feb 2012 03:38:24 -0500 Received: from cantvi.canterbury.ac.nz ([132.181.2.61]:2600) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RyJKb-0000xm-EI for emacs-orgmode@gnu.org; Fri, 17 Feb 2012 03:38:18 -0500 Received: from DISCAIMER-DAEMON.it.canterbury.ac.nz by it.canterbury.ac.nz (PMDF V6.5 #31848) id <01OC417M2CRK90XRK1@it.canterbury.ac.nz> for emacs-orgmode@gnu.org; Fri, 17 Feb 2012 21:38:12 +1200 (NEW ZEALAND STANDARD TIME) Content-Class: urn:content-classes:message List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Andreas Willig Andreas Willig Cc: nicholas.dokos@hp.com, emacs-orgmode@gnu.org Hi, it is a version problem. I have just downloaded the latest version of org-mode (7.8.03) and now the handler gets called.=20 Sorry for the fuss ... Thanks again, i really appreciate the quick help i have received here!! Andreas -----Original Message----- From: Andreas Willig Sent: Fri 2/17/2012 9:10 PM To: Andreas Willig; nicholas.dokos@hp.com Cc: nicholas.dokos@hp.com; emacs-orgmode@gnu.org Subject: RE: [O] Integration of RefTeX and LaTeX export =20 I should have added that the rt-follow-hander is properly called ... Is this a version problem? -----Original Message----- From: emacs-orgmode-bounces+andreas.willig=3Dcanterbury.ac.nz@gnu.org on = behalf of Andreas Willig Sent: Fri 2/17/2012 8:39 PM To: nicholas.dokos@hp.com Cc: nicholas.dokos@hp.com; emacs-orgmode@gnu.org Subject: Re: [O] Integration of RefTeX and LaTeX export =20 Hi Nick, thanks for this, but i cannot get it to work ... I have started a vanilla emacs without any init file (emacs -q), have loaded your snippet from a file and evaluated the buffer. Again, the export-handler does not get called. I am running Debian 6.0.4 and my emacs is the one coming with it (see below). I feel so stupid :-)) Andreas M-x emacs-version says: GNU Emacs 23.2.1 (i486-pc-linux-gnu, GTK+ = Version 2.20.0) of 2010-12-12 on raven, modified by Debian M-x org-version says: Org-mode version 6.33x Debian version is 6.0.4 (/etc/debian_version) -----Original Message----- From: Nick Dokos [mailto:nicholas.dokos@hp.com] Sent: Fri 2/17/2012 6:31 PM To: Andreas Willig Cc: Thomas S.Dye; emacs-orgmode@gnu.org; nicholas.dokos@hp.com Subject: Re: [O] Integration of RefTeX and LaTeX export =20 Andreas Willig wrote: >=20 > Hi Thomas, >=20 > 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. >=20 > 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. >=20 > 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 ... >=20 > Any ideas? >=20 > Andreas >=20 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 =3D %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"=20 (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 > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >=20 > (defun rt-handler (path) > (message "dummy handler called, path =3D %s" path) > (let ((arg (concat "\\cite{" path "}"))) > (reftex-view-crossref arg))) >=20 > (org-add-link-type "rtcite"=20 > '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)))))) >=20 >=20 > .... This email may be confidential and subject to legal privilege, it may not reflect the views of the University of Canterbury, and it is not guaranteed to be virus free. If you are not an intended recipient, please notify the sender immediately and erase all copies of the message and any attachments. Please refer to http://www.canterbury.ac.nz/emaildisclaimer for more information. This email may be confidential and subject to legal privilege, it may not reflect the views of the University of Canterbury, and it is not guaranteed to be virus free. If you are not an intended recipient, please notify the sender immediately and erase all copies of the message and any attachments. Please refer to http://www.canterbury.ac.nz/emaildisclaimer for more information.