bug#36252: 26.1; bibtex-generate-autokey does not use use date field

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

bug#36252: 26.1; bibtex-generate-autokey does not use use date field

Ryan Kavanagh
Package: emacs
Version: 26.1
Tags: patch

The bibtex.el package will automatically generate a key for a BibTeX
entry when required. To do so, it extracts the year from the 'year'
field. Instead of the 'year' field, the biblatex dialect uses the 'date'
field to record the publication date. The bibtex-generate-autokey
function should fallback to the date field when the year field is
absent. This requires a bit of care because the 'date' field can contain
an arbitrary date satisfying the "ISO8601-2 Extended Format
Specification Level 1". Fortunately, a relatively simple regex can
extract the year from all of the examples listed in the biblatex
manual[0].

Please see attached for a patch adding support for the 'date' field.

[0] http://mirrors.ibiblio.org/CTAN/macros/latex/exptl/biblatex/doc/biblatex.pdf

--
|)|/  Ryan Kavanagh      | GPG: 4E46 9519 ED67 7734 268F
|\|\  https://rak.ac     |      BD95 8F7B F8FC 4A11 C97A

0001-Fallback-to-date-field-when-year-field-is-absent-in-.patch (3K) Download Attachment
signature.asc (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

bug#36252: 26.1; bibtex-generate-autokey does not use use date field

Lars Ingebrigtsen
Ryan Kavanagh <[hidden email]> writes:

> The bibtex.el package will automatically generate a key for a BibTeX
> entry when required. To do so, it extracts the year from the 'year'
> field. Instead of the 'year' field, the biblatex dialect uses the 'date'
> field to record the publication date. The bibtex-generate-autokey
> function should fallback to the date field when the year field is
> absent.

This makes sense to me, but I'm not a bibtex user.  Anybody else that
can take a look at this patch?

--
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



Reply | Threaded
Open this post in threaded view
|

bug#36252: 26.1; bibtex-generate-autokey does not use use date field

Lars Ingebrigtsen
In reply to this post by Ryan Kavanagh
Ryan Kavanagh <[hidden email]> writes:

> This requires a bit of care because the 'date' field can contain
> an arbitrary date satisfying the "ISO8601-2 Extended Format
> Specification Level 1". Fortunately, a relatively simple regex can
> extract the year from all of the examples listed in the biblatex
> manual[0].

(This reminds me -- Emacs should really have a parser that can parse all
ISO8601 variants.  There's parse-iso8601-time-string, but it only
handles the simplest of the formats...)

--
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



Reply | Threaded
Open this post in threaded view
|

bug#36252: 26.1; bibtex-generate-autokey does not use use date field

Ryan Kavanagh
On Sat, Jul 06, 2019 at 04:55:47PM +0200, Lars Ingebrigtsen wrote:
> (This reminds me -- Emacs should really have a parser that can parse
> all ISO8601 variants.  There's parse-iso8601-time-string, but it only
> handles the simplest of the formats...)

Perhaps that should be the first step, and then the committed fix to
this bug can just use that.

I've been using this patch since I submitted it and I've discovered a
slight bug in how date parsing works for bibtex files with this patch.
Please hold off on committing this patch until I've managed to narrow
down the bug and figure out where it is.

Thanks,
Ryan

--
|)|/  Ryan Kavanagh      | GPG: 4E46 9519 ED67 7734 268F
|\|\  https://rak.ac     |      BD95 8F7B F8FC 4A11 C97A

signature.asc (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

bug#36252: 26.1; bibtex-generate-autokey does not use use date field

Lars Ingebrigtsen
Ryan Kavanagh <[hidden email]> writes:

> On Sat, Jul 06, 2019 at 04:55:47PM +0200, Lars Ingebrigtsen wrote:
>> (This reminds me -- Emacs should really have a parser that can parse
>> all ISO8601 variants.  There's parse-iso8601-time-string, but it only
>> handles the simplest of the formats...)
>
> Perhaps that should be the first step, and then the committed fix to
> this bug can just use that.

I've implemented a proper iso8601 parser now, but hasn't merged with the
Emacs trunk yet because I haven't done the entire test suite yet.  It's
on the scratch/iso8601 branch if you want to check it out.

--
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



Reply | Threaded
Open this post in threaded view
|

bug#36252: 26.1; bibtex-generate-autokey does not use use date field

Lars Ingebrigtsen
Lars Ingebrigtsen <[hidden email]> writes:

> Ryan Kavanagh <[hidden email]> writes:
>
>> On Sat, Jul 06, 2019 at 04:55:47PM +0200, Lars Ingebrigtsen wrote:
>>> (This reminds me -- Emacs should really have a parser that can parse
>>> all ISO8601 variants.  There's parse-iso8601-time-string, but it only
>>> handles the simplest of the formats...)
>>
>> Perhaps that should be the first step, and then the committed fix to
>> this bug can just use that.
>
> I've implemented a proper iso8601 parser now, but hasn't merged with the
> Emacs trunk yet because I haven't done the entire test suite yet.  It's
> on the scratch/iso8601 branch if you want to check it out.

The iso8601 parser is in the trunk now, so if you could rework your
patch based on that, that'd be nice.  The function to use is
`iso8601-parse'.

--
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



Reply | Threaded
Open this post in threaded view
|

bug#36252: 26.1; bibtex-generate-autokey does not use use date field

Lars Ingebrigtsen
Lars Ingebrigtsen <[hidden email]> writes:

> Lars Ingebrigtsen <[hidden email]> writes:
>
>> The iso8601 parser is in the trunk now, so if you could rework your
>> patch based on that, that'd be nice.  The function to use is
>> `iso8601-parse'.
>
> Ryan, did you look into redoing this functionality with `iso8601-parse'?

This was five weeks ago, and there was no response, so I'm closing this
bug report.  If progress can be made here, please respond to the debbugs
mail address, and we'll reopen the bug report.

--
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no