Re: [O] Integration of RefTeX and LaTeX export

2012-02-17 Thread Andreas Willig

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=canterbury.ac...@gnu.org on behalf 
of Andreas Willig
Sent: Fri 2/17/2012 8:39 PM
To: nicholas.do...@hp.com
Cc: nicholas.do...@hp.com; emacs-orgmode@gnu.org
Subject: Re: [O] Integration of RefTeX and LaTeX export
 

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.do...@hp.com]
Sent: Fri 2/17/2012 6:31 PM
To: Andreas Willig
Cc: Thomas S.Dye; emacs-orgmode@gnu.org; nicholas.do...@hp.com
Subject: Re: [O] Integration of RefTeX and LaTeX export
 
Andreas Willig andreas.wil...@canterbury.ac.nz 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))
 
 
 


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

Re: [O] Integration of RefTeX and LaTeX export

2012-02-17 Thread Andreas Willig

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. 

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.do...@hp.com
Cc: nicholas.do...@hp.com; emacs-orgmode@gnu.org
Subject: RE: [O] Integration of RefTeX and LaTeX export
 

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=canterbury.ac...@gnu.org on behalf 
of Andreas Willig
Sent: Fri 2/17/2012 8:39 PM
To: nicholas.do...@hp.com
Cc: nicholas.do...@hp.com; emacs-orgmode@gnu.org
Subject: Re: [O] Integration of RefTeX and LaTeX export
 

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.do...@hp.com]
Sent: Fri 2/17/2012 6:31 PM
To: Andreas Willig
Cc: Thomas S.Dye; emacs-orgmode@gnu.org; nicholas.do...@hp.com
Subject: Re: [O] Integration of RefTeX and LaTeX export
 
Andreas Willig andreas.wil...@canterbury.ac.nz 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))
 
 
 


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

[O] Integration of RefTeX and LaTeX export

2012-02-16 Thread Andreas Willig

Hi,

i am relatively new to org mode. Yesterday i have tried to use org mode for
the first time to write the beginnings of a paper, and found that i wanted to
insert literature references and a bibliography. I like RefTeX a lot and google
provided me some links for proper integration. As a result, i have added the
stuff to my .emacs that you find below. The org-latex-to-pdf-process stuff
works.

My problems are related to (reftex-set-cite-format ..). Right now i do not use
it and get the default implementation by which RefTeX simply expands the
chosen reference to \cite{Key}, which is not highlighted in the org buffer. I 
would
like to have this expanded into an org link with the [[][]] syntax. I have tried
several variations of (reftex-set-cite-format ...) but i have never succeeded in
creating the bibliography. After generating the LaTeX output into a buffer 
(C-c C-e L) i found that org translates [[][]] type of stuff into \hyperref{}s 
and not
into \cite{} commands.

So, how can i change things so that in the org buffer the bib key gets displayed
nicely and in the LaTeX output a \cite{} command is generated?

Any help would be appreciated!!

Best regards,

Andreas

--

(require 'org-latex)
(unless (boundp 'org-export-latex-classes)
  (setq org-export-latex-classes nil))


(add-to-list 'org-export-latex-classes
 '(article
   \\documentclass{article}
   (\\section{%s} . \\section*{%s})
   (\\subsection{%s} . \\subsection*{%s})
   (\\subsubsection{%s} . \\subsubsection*{%s})
   (\\paragraph{%s} . \\paragraph*{%s})))  

(add-to-list 'org-export-latex-classes
 '(komaarticle
   \\documentclass{scrartcl}
   (\\section{%s} . \\section*{%s})
   (\\subsection{%s} . \\subsection*{%s})
   (\\subsubsection{%s} . \\subsubsection*{%s})
   (\\paragraph{%s} . \\paragraph*{%s})))  


(add-to-list 'org-export-latex-classes
 '(komabook
   \\documentclass{scrbook}
   (\\chapter{%s} . \\chapter*{%s})
   (\\section{%s} . \\section*{%s})
   (\\subsection{%s} . \\subsection*{%s})
   (\\subsubsection{%s} . \\subsubsection*{%s})
   (\\paragraph{%s} . \\paragraph*{%s})))  


(defun org-mode-reftex-setup ()
  (load-library reftex)
  (and (buffer-file-name) (file-exists-p (buffer-file-name))
   (progn
 (global-auto-revert-mode t)
 (reftex-parse-all)
 ;;(reftex-set-cite-format \[cite][%l]])
 ))
  (define-key org-mode-map (kbd C-c )) 'reftex-citation)
  (define-key org-mode-map (kbd C-c () 'org-mode-reftex-search))

(add-hook 'org-mode-hook 'org-mode-reftex-setup)


(defun org-mode-reftex-search ()
  ;;jump to the notes for the paper pointed to at from reftex search
  (interactive)
  (org-open-link-from-string (format [[notes:%s]] (reftex-citation t
 
(setq org-latex-to-pdf-process
'(pdflatex -interaction nonstopmode %b
  bibtex %b
  pdflatex -interaction nonstopmode %b
  pdflatex -interaction nonstopmode %b))

 
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.



Re: [O] Integration of RefTeX and LaTeX export

2012-02-16 Thread Andreas Willig

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



(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))


(defun org-mode-reftex-setup ()
  (load-library reftex)
  (and (buffer-file-name) (file-exists-p (buffer-file-name))
   (progn
 ;;enable auto-revert-mode to update reftex when bibtex file changes on 
disk
 (global-auto-revert-mode t)
 (reftex-parse-all)
 ;;add a custom reftex cite format to insert links
 (reftex-set-cite-format [[rtcite:%l][\\cite{%l}]])
 ))
  (define-key org-mode-map (kbd C-c )) 'reftex-citation)
  (define-key org-mode-map (kbd C-c () 'org-mode-reftex-search))



On 17/02/2012, at 11:08 AM, Thomas S. Dye wrote:

 Andreas Willig andreas.wil...@canterbury.ac.nz writes:
 
 Hi,
 
 i am relatively new to org mode. Yesterday i have tried to use org mode for
 the first time to write the beginnings of a paper, and found that i wanted to
 insert literature references and a bibliography. I like RefTeX a lot and 
 google
 provided me some links for proper integration. As a result, i have added the
 stuff to my .emacs that you find below. The org-latex-to-pdf-process stuff
 works.
 
 My problems are related to (reftex-set-cite-format ..). Right now i do not 
 use
 it and get the default implementation by which RefTeX simply expands the
 chosen reference to \cite{Key}, which is not highlighted in the org buffer. 
 I would
 like to have this expanded into an org link with the [[][]] syntax. I have 
 tried
 several variations of (reftex-set-cite-format ...) but i have never 
 succeeded in
 creating the bibliography. After generating the LaTeX output into a buffer 
 (C-c C-e L) i found that org translates [[][]] type of stuff into 
 \hyperref{}s and not
 into \cite{} commands.
 
 So, how can i change things so that in the org buffer the bib key gets 
 displayed
 nicely and in the LaTeX output a \cite{} command is generated?
 
 Any help would be appreciated!!
 
 Best regards,
 
 Andreas
 
 --
 
 (require 'org-latex)
 (unless (boundp 'org-export-latex-classes)
  (setq org-export-latex-classes nil))
 
 
 (add-to-list 'org-export-latex-classes
 '(article
   \\documentclass{article}
   (\\section{%s} . \\section*{%s})
   (\\subsection{%s} . \\subsection*{%s})
   (\\subsubsection{%s} . \\subsubsection*{%s})
   (\\paragraph{%s} . \\paragraph*{%s})))  
 
 (add-to-list 'org-export-latex-classes
 '(komaarticle
   \\documentclass{scrartcl}
   (\\section{%s} . \\section*{%s})
   (\\subsection{%s} . \\subsection*{%s})
   (\\subsubsection{%s} . \\subsubsection*{%s})
   (\\paragraph{%s} . \\paragraph*{%s})))  
 
 
 (add-to-list 'org-export-latex-classes
 '(komabook
   \\documentclass{scrbook}
   (\\chapter{%s} . \\chapter*{%s})
   (\\section{%s} . \\section*{%s})
   (\\subsection{%s} . \\subsection*{%s})
   (\\subsubsection{%s} . \\subsubsection*{%s})
   (\\paragraph{%s} . \\paragraph*{%s})))  
 
 
 (defun org-mode-reftex-setup ()
  (load-library reftex)
  (and (buffer-file-name) (file-exists-p (buffer-file-name))
   (progn
   (global-auto-revert-mode t)
   (reftex-parse-all)
   ;;(reftex-set-cite-format \[cite][%l]])
   ))
  (define-key org-mode-map (kbd C-c )) 'reftex-citation)
  (define-key org-mode-map (kbd C-c () 'org-mode

Re: [O] Integration of RefTeX and LaTeX export

2012-02-16 Thread Andreas Willig

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.do...@hp.com]
Sent: Fri 2/17/2012 6:31 PM
To: Andreas Willig
Cc: Thomas S.Dye; emacs-orgmode@gnu.org; nicholas.do...@hp.com
Subject: Re: [O] Integration of RefTeX and LaTeX export
 
Andreas Willig andreas.wil...@canterbury.ac.nz 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))
 
 
 


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.