bug-auctex
[Top][All Lists]
Advanced

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

bug#38249: 12.2.0; reftex-create-bibtex-file and biblatex


From: gusbrs
Subject: bug#38249: 12.2.0; reftex-create-bibtex-file and biblatex
Date: Thu, 11 Apr 2024 16:35:27 -0300

Hi Arash,

On Thu, 11 Apr 2024 at 12:46, Arash Esbati <arash@gnu.org> wrote:

> I thought you were a nice guy, but that's about to change ;-)
> Persoally, I don't like detached args, but that's only me, and it's a
> matter of taste, so it doesn't really count.

Well, I don't use it everywhere, and not even in most places, but I do
use it whenever I feel it is convenient. And biblatex citation lists
are one case where it is practically a necessity. These macros easily
become very long with no relevant break point, except perhaps an
occasional space in a pre-/postnote, so they quickly become impossible
tasks for paragraph filling functions. Adding some possible breaks
between the arguments makes for much better results.

> Can you please try this on your files:
>
> [...]

My real life documents are not really a good testing ground for this.
For starters, I don't have a list to benchmark the results. I could
produce one with another tool, but on a real document each bibkey is
called multiple times, and we would never really know when or where
the parsing failed.

But I tested this new version on the MWE for the original report, and
it further handles detached arguments. Which is nice. Thank you.

You only did so for the citation lists though. The macros matched in
`re' do not allow detached arguments. It feels to me like it should.

All in all, with perhaps the adjustment of the previous comment, this
looks good to me. It is close to as good as is possible within this
approach and certainly counts as good enough in my view.

> I think in this particular case, we should ignore the value of
> `reftex-allow-detached-macro-args'.

Agreed. Btw, in plenty of places this just works implicitly. I'd only
check/restrict behavior to `reftex-allow-detached-macro-args' if there
is a cost or risk involved.

> > From AUCTeX/RefTeX's sides pretty much everything works, except that
> > you cannot detach the very first argument after the macro. (If I
> > recall correctly, this exception is due to an implementation detail in
> > font-latex.el, but I don't recall if I had filled this as a
> > mal-function or not, I'm just used to it by now. I also don't recall
> > if this exception affects only citation lists or is general, probably
> > general).
>
> Can you show a concrete example?

Mhm, my memory may have betrayed me there, perhaps not. This belongs
to those long term muscle memory things, it is only natural that I
lost track of the origin. I should have something noted somewhere, but
I couldn't find it.

But I won't leave you empty handed either: `reftex-what-macro' fails
to handle a macro where the first argument is detached, regardless of
the value of `reftex-allow-detached-macro-args'.

Try `(reftex-what-macro 1)' on ("|" is point):

    \cite [45] {sig|fridsson}

Result `nil'. On the other hand, on:

    \cite[45] {sig|fridsson}

We now get `("\\cite" . 3654)' (Tested in my own setup, so assuming
`reftex-allow-detached-macro-args' is `t', and possibly other noise,
but the important point is that the first case fails regardless).

This happens because in `reftex-what-macro', after moving backwards
all the arguments of the macro, point is exactly at the first
character of the first argument, and the function then grabs the macro
name with:

    (when (and (memq (following-char) '(?\[ ?\( ?\{))
               (re-search-backward "\\\\[*a-zA-Z]+\\=" nil t))
      (setq cmd (reftex-match-string 0))

There's no accounting for a possible space at this point. Good news,
it is easy to fix, either by allowing for whitespace in the regexp or
perhaps by some backwards version of `(while (and (not (eobp))
(font-latex-forward-comment)))'.

I know, you telling me you want to keep your sanity and me suggesting
you touch this regexp... Sorry, my bad. But, in fairness, I hadn't
even made this a thing. You brought this upon yourself by asking me
for an example.  ;-)

At this point, I'm not sure about similar restrictions stemming from
font-latex.el, as I had initially mentioned. I fought a lot with this
area of functionality, had many incarnations of setups, and am
probably quite detached from the "vanilla" experience here. I'm also
not sure if this issue arises somewhere else or not. But I think this
thing in `reftex-what-macro' would, alone, be sufficient to generate
the muscle memory that I have in this regard.

> > And, as you have noted yourself, a comment between two arguments would
> > also beat it. I'm sure you know much better than me how hard it is to
> > parse TeX arguments solely based on regexps (as opposed to sexp
> > navigation).
>
> Not always: Try "\foo[opti{]}onal]{}" in a .tex file, put point on [ and
> hit 'C-M-f'.

:-)

> > True, `reftex-create-bibtex-file' already exists, so it does pose the
> > question as to whether "let it wane", "marginally improve" or "replace
> > it with something better" is the best option. Not a question for me to
> > answer tough. ;-)
>
> I think AUCTeX/RefTeX are here, if we can improve them, we should do it.
> And if someone wants to replace it with something better, we can do it
> as well.  It is always a matter of "I need that", and best case is one
> implements that as well.

Well, the current version you have is pretty good, and a welcome
improvement. Thank you.

Best,
gusbrs





reply via email to

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