I've noticed that "org-bibtex-import-from-file" will not import from bib files which begin with the standard bibtex mode-line heading of @Comment -*- mode: bibtex; -*- Bib files with any @Comment line are similarly rejected. This is rather unfortunate.
[-- Attachment #1: Type: text/plain, Size: 389 bytes --] Colin Baxter <m43cap@yandex.com> writes: > I've noticed that "org-bibtex-import-from-file" will not import from bib files > which begin with the standard bibtex mode-line heading of > > @Comment -*- mode: bibtex; -*- Well. It will import the files. However, org-bibtex-write will indeed fail. If I got it wrong, please provide more details. Confirmed The fix is attached. Best, Ihor [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-org-bibtex-read-Do-not-add-nil-when-there-is-no-entr.patch --] [-- Type: text/x-diff, Size: 1326 bytes --] From 248a594fb89820a6ee2ca5782f98502851c9a315 Mon Sep 17 00:00:00 2001 Message-Id: <248a594fb89820a6ee2ca5782f98502851c9a315.1630157370.git.yantar92@gmail.com> From: Ihor Radchenko <yantar92@gmail.com> Date: Sat, 28 Aug 2021 21:23:43 +0800 Subject: [PATCH] org-bibtex-read: Do not add nil when there is no entry at point * lisp/ol-bibtex.el (org-bibtex-read): Previously, when there is no entry at point, `nil' would be added to `org-bibtex-entries' causing errors later, i.e. upon calling org-bibtex-write. Now, nil is never pushed to `org-bibtex-entries'. Fixes https://orgmode.org/list/874kd3288n.fsf@yandex.com --- lisp/ol-bibtex.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lisp/ol-bibtex.el b/lisp/ol-bibtex.el index 4970be9c4..e70d847b4 100644 --- a/lisp/ol-bibtex.el +++ b/lisp/ol-bibtex.el @@ -677,7 +677,8 @@ (defun org-bibtex-read () (_ field))) (funcall clean-space (funcall strip-delim (cdr pair))))) (save-excursion (bibtex-beginning-of-entry) (bibtex-parse-entry))) - org-bibtex-entries))) + org-bibtex-entries) + (unless (car org-bibtex-entries) (pop org-bibtex-entries)))) (defun org-bibtex-read-buffer (buffer) "Read all bibtex entries in BUFFER and save to `org-bibtex-entries'. -- 2.31.1
Hello Ihor,
>>>>> Ihor Radchenko <yantar92@gmail.com> writes:
> Colin Baxter <m43cap@yandex.com> writes:
>> I've noticed that "org-bibtex-import-from-file" will not import
>> from bib files which begin with the standard bibtex mode-line
>> heading of
>>
>> @Comment -*- mode: bibtex; -*-
> Well. It will import the files. However, org-bibtex-write will
> indeed fail. If I got it wrong, please provide more details.
> Confirmed
> The fix is attached.
I've applied your patch to my local git branch of org-mode and it works
very nicely. I can live with the write fail you mentioned. Will you
apply it to the master branch of org-mode?
Thank you.
Best wishes,
Colin.
Colin Baxter <m43cap@yandex.com> writes: > > Well. It will import the files. However, org-bibtex-write will > > indeed fail. If I got it wrong, please provide more details. > > > Confirmed > > > The fix is attached. > > I've applied your patch to my local git branch of org-mode and it works > very nicely. I can live with the write fail you mentioned. Let me clarify. On my side, org-bibtex-read-file did not throw any error on a .bib file with comment. Is it any different for you? The patch is supposed to fix org-bibtex-write -- the only problem I was able to see following your email. > Will you apply it to the master branch of org-mode? Nope. We need to wait for the maintainers with write access to apply it. Best, Ihor
>>>>> Ihor Radchenko <yantar92@gmail.com> writes:
> Colin Baxter <m43cap@yandex.com> writes:
>> > Well. It will import the files. However, org-bibtex-write will
>> > indeed fail. If I got it wrong, please provide more details.
>>
>> > Confirmed
>>
>> > The fix is attached.
>>
>> I've applied your patch to my local git branch of org-mode and it
>> works very nicely. I can live with the write fail you mentioned.
> Let me clarify. On my side, org-bibtex-read-file did not throw any
> error on a .bib file with comment. Is it any different for you?
Sorry, my first reply was garbled. No there is no difference,
org-bibtex-read-file and org-bibtex-import-from-file now do not give any
errors for me.
Thanks again.
Hi Ihor,
Ihor Radchenko <yantar92@gmail.com> writes:
> Colin Baxter <m43cap@yandex.com> writes:
>
>> I've noticed that "org-bibtex-import-from-file" will not import from bib files
>> which begin with the standard bibtex mode-line heading of
>>
>> @Comment -*- mode: bibtex; -*-
>
> Well. It will import the files. However, org-bibtex-write will indeed
> fail. If I got it wrong, please provide more details.
Applied, thanks!
--
Bastien
>>>>> Bastien <bzg@gnu.org> writes:
> Hi Ihor, Ihor Radchenko <yantar92@gmail.com> writes:
>> Colin Baxter <m43cap@yandex.com> writes:
>>
>>> I've noticed that "org-bibtex-import-from-file" will not import
>>> from bib files which begin with the standard bibtex mode-line
>>> heading of
>>>
>>> @Comment -*- mode: bibtex; -*-
>>
>> Well. It will import the files. However, org-bibtex-write will
>> indeed fail. If I got it wrong, please provide more details.
> Applied, thanks!
> -- Bastien
Great! Thanks Bastien.