* [PATCH] ob-tangle: Tangle BibTeX files with the standard .bib file extension
@ 2025-01-05 10:20 Rudolf Adamkovič
2025-01-05 13:15 ` Ihor Radchenko
0 siblings, 1 reply; 4+ messages in thread
From: Rudolf Adamkovič @ 2025-01-05 10:20 UTC (permalink / raw)
To: emacs-orgmode; +Cc: Rudolf Adamkovič
---
etc/ORG-NEWS | 7 +++++++
lisp/ob-tangle.el | 3 ++-
testing/lisp/test-ob-tangle.el | 24 ++++++++++++++++++++++++
3 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 8f266c560..097550805 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -484,6 +484,13 @@ ignored by ~org-babel-tangle-collect-blocks~. Now, if it inherits a
filename), a source block without =language= will get tangled to that
file.
+*** BibTeX is tangled with the standard =.bib= file extension
+
+Previously, =bibtex= source blocks located in a file named =NAME.org=
+were tangled into a file named =NAME.bibtex=. Now, they are tangled
+into a file named =FILE.bib=, using the standard extension =.bib=,
+matching the rest of the ecosystem, including BibTeX and LaTeX.
+
* Version 9.7
** Important announcements and breaking changes
diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el
index 1f5de9250..38cad78ab 100644
--- a/lisp/ob-tangle.el
+++ b/lisp/ob-tangle.el
@@ -58,7 +58,8 @@
(defcustom org-babel-tangle-lang-exts
'(("emacs-lisp" . "el")
- ("elisp" . "el"))
+ ("elisp" . "el")
+ ("bibtex" . "bib"))
"Alist mapping languages to their file extensions.
The key is the language name, the value is the string that should
be inserted as the extension commonly used to identify files
diff --git a/testing/lisp/test-ob-tangle.el b/testing/lisp/test-ob-tangle.el
index 6e95c4c91..4a197f76b 100644
--- a/testing/lisp/test-ob-tangle.el
+++ b/testing/lisp/test-ob-tangle.el
@@ -715,6 +715,30 @@ another block
(funcall count-blocks-in-target-files
(org-babel-tangle-collect-blocks)))))))))
+(ert-deftest ob-tangle/bibtex ()
+ "Tangle BibTeX into a `.bib' file."
+ (let ((file (make-temp-file "org-tangle-" nil ".org"))
+ (bib "@Misc{example,
+ author = {Richard Stallman and {contributors}},
+ title = {{GNU} {Emacs}},
+ publisher = {Free Software Foundation},
+ url = {https://www.emacs.org/},
+}"))
+ (unwind-protect
+ (with-current-buffer (find-file-noselect file)
+ (insert (format "#+begin_src bibtex :tangle yes
+%s
+#+end_src"
+ bib))
+ (org-babel-tangle)
+ (let ((bib-file (file-name-with-extension file "bib")))
+ (should (file-exists-p bib-file))
+ (should (string= (string-trim (org-file-contents bib-file))
+ bib))))
+ (delete-file file))))
+
+(delete-file file)
+
(provide 'test-ob-tangle)
;;; test-ob-tangle.el ends here
--
2.47.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] ob-tangle: Tangle BibTeX files with the standard .bib file extension
2025-01-05 10:20 [PATCH] ob-tangle: Tangle BibTeX files with the standard .bib file extension Rudolf Adamkovič
@ 2025-01-05 13:15 ` Ihor Radchenko
2025-01-05 16:32 ` Rudolf Adamkovič
0 siblings, 1 reply; 4+ messages in thread
From: Ihor Radchenko @ 2025-01-05 13:15 UTC (permalink / raw)
To: Rudolf Adamkovič; +Cc: emacs-orgmode
Rudolf Adamkovič <rudolf@adamkovic.org> writes:
> +*** BibTeX is tangled with the standard =.bib= file extension
> +
> +Previously, =bibtex= source blocks located in a file named =NAME.org=
> +were tangled into a file named =NAME.bibtex=. Now, they are tangled
> +into a file named =FILE.bib=, using the standard extension =.bib=,
> +matching the rest of the ecosystem, including BibTeX and LaTeX.
Thanks!
> +(ert-deftest ob-tangle/bibtex ()
> + "Tangle BibTeX into a `.bib' file."
I think that the test is not necessary here.
We already test `org-babel-tangle-lang-exts' in
`ob-tangle/collect-blocks', I think.
Or do I miss something?
--
Ihor Radchenko // yantar92,
Org mode maintainer,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ob-tangle: Tangle BibTeX files with the standard .bib file extension
2025-01-05 13:15 ` Ihor Radchenko
@ 2025-01-05 16:32 ` Rudolf Adamkovič
2025-01-05 16:48 ` Ihor Radchenko
0 siblings, 1 reply; 4+ messages in thread
From: Rudolf Adamkovič @ 2025-01-05 16:32 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: emacs-orgmode
Ihor Radchenko <yantar92@posteo.net> writes:
>> +(ert-deftest ob-tangle/bibtex ()
>> + "Tangle BibTeX into a `.bib' file."
>
> I think that the test is not necessary here.
> We already test `org-babel-tangle-lang-exts' in
> `ob-tangle/collect-blocks', I think.
> Or do I miss something?
I wanted to make sure this behavior, specifically for BibTeX, will never
get "lost in translation", say when refactoring. I noticed that other
files add to the `org-babel-tangle-lang-exts' list, so I figured that
this code may moved in the future, etc. And we all know how that goes.
More generally, for the end-user, the correct BibTeX file extension is a
crucial requirement, not a cosmetic one, so I wrote a test to make sure
we will never-ever break it.
Rudy
--
"If you're thinking without writing, you only think you're thinking."
--- Leslie Lamport
Rudolf Adamkovič <rudolf@adamkovic.org> [he/him]
http://adamkovic.org
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ob-tangle: Tangle BibTeX files with the standard .bib file extension
2025-01-05 16:32 ` Rudolf Adamkovič
@ 2025-01-05 16:48 ` Ihor Radchenko
0 siblings, 0 replies; 4+ messages in thread
From: Ihor Radchenko @ 2025-01-05 16:48 UTC (permalink / raw)
To: Rudolf Adamkovič; +Cc: emacs-orgmode
Rudolf Adamkovič <rudolf@adamkovic.org> writes:
> I wanted to make sure this behavior, specifically for BibTeX, will never
> get "lost in translation", say when refactoring. ...
Ok.
Applied, onto main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=405787dfbc
--
Ihor Radchenko // yantar92,
Org mode maintainer,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-01-05 16:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-05 10:20 [PATCH] ob-tangle: Tangle BibTeX files with the standard .bib file extension Rudolf Adamkovič
2025-01-05 13:15 ` Ihor Radchenko
2025-01-05 16:32 ` Rudolf Adamkovič
2025-01-05 16:48 ` Ihor Radchenko
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).