[Top][All Lists]

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

[AUCTeX] Re: Referencing labels with refstyle.sty

From: Alan Ristow
Subject: [AUCTeX] Re: Referencing labels with refstyle.sty
Date: Thu, 12 Jul 2007 09:31:23 -0400
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20070604 Thunderbird/ Mnenhy/

Ralf Angeli wrote:
* Alan Ristow (2007-07-12) writes:

Ralf Angeli wrote:
(set (make-local-variable 'reftex-format-ref-function)
I had to change that last line to:

(setq reftex-format-ref-function 'my-reftex-format-ref-function)))

But this will globally change the value of the variable. The idea of
the variant proposed by me was to change it only for buffers where
refstyle.sty is used.  I'm not sure why this is not working, though.

At this point I don't recall precisely how the code looked on my end when I wrote that last message, but ultimately what I did was put it in a refstyle.el that I added to my site-lisp/auctex/style. I *think* my addition of the setq line was based on what other styles (e.g., alltt.el) do with make-local-variable, but anyway here's what my refstyle.el contains:

 (lambda ()
   (make-local-variable 'reftex-format-ref-function)
   (setq reftex-format-ref-function 'refstyle-reftex-format-ref-function)))

(defun refstyle-reftex-format-ref-function (label format)
  (let* ((label-sep-pos (string-match ":" label))
         (prefix (substring label 0 label-sep-pos))
         (suffix (substring label (1+ label-sep-pos))))
    (format "\\%sref{%s}" prefix suffix)))

I've tested it with files that use refstyle.sty and those that don't and the local scope of the variable seems to be preserved -- the code in refstyle.el only takes effect when the document contains \usepackage{refstyle}, otherwise I get what my .emacs specifies in reftex-label-alist.

If you see anything wrong with this I'd love to know, but it does seem to be working as I had hoped.

Thanks again for your help!


reply via email to

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