[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: spaces in labels
From: |
Arash Esbati |
Subject: |
Re: spaces in labels |
Date: |
Mon, 09 Dec 2024 23:17:02 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Sigurd Angenent <sigurdangenent@gmail.com> writes:
> A while ago coauthors of mine discovered that LaTeX actually allows
> spaces in labels and since then they have gotten addicted to this
> feature.
>
> Reftex has a function (reftex-view-crossref) that searches for the
> defining \label{bla bla bla} statement from any \ref{bla bla bla} or
> \eqref{bla bla bla} statement. This is very useful except it doesn't
> work with labels that have spaces.
>
> On my computer I looked in the file reftex-dcr.el and deleted the
> space from the string on line 56 in the statement
>
> (key (reftex-this-word "^{}%\n\r,\t"))
Interestingly, a SPACE was added to the regexp with this patch[1].
> I saved and byte compiled the file and it now seems to work on labels
> with spaces for me. I don't know how many other problems I have
> created by doing this, but I will find out, I guess.
That would be indeed interesting to find out.
> Since these files were located in /usr/share/emacs/29.4/lisp/textmodes
> I had to sudo a fair amount of things, which made me uncomfortable.
> There ought to be a way to do this in my .emacs file.
You can use the advise facility provided by Emacs: In your init file,
you first define your own version of `reftex-view-crossref' like this:
(defun my/reftex-view-crossref (&optional arg auto-how fail-quietly)
"View cross reference of macro at point."
(interactive "P")
;; See where we are.
(let* ((macro (car (reftex-what-macro-safe 1)))
(key (reftex-this-word "^{}%\n\r,\t"))
dw)
...
)
And then replace the original function like this:
(advice-add 'reftex-view-crossref :override #'my/reftex-view-crossref)
HTH.
Best, Arash
Footnotes:
[1]
https://git.savannah.gnu.org/cgit/emacs.git/commit/lisp/textmodes/reftex-dcr.el?id=4e33ebe07342950759abe58c2a1828b1d66100e7
- spaces in labels, Sigurd Angenent, 2024/12/09
- Re: spaces in labels,
Arash Esbati <=