emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Rudolf Adamkovič" <rudolf@adamkovic.org>
To: emacs-orgmode@gnu.org
Cc: "Rudolf Adamkovič" <rudolf@adamkovic.org>
Subject: [PATCH] ob-tangle: Tangle BibTeX files with the standard .bib file extension
Date: Sun,  5 Jan 2025 11:20:55 +0100	[thread overview]
Message-ID: <20250105102055.62372-1-rudolf@adamkovic.org> (raw)

---
 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



             reply	other threads:[~2025-01-05 10:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-05 10:20 Rudolf Adamkovič [this message]
2025-01-05 13:15 ` [PATCH] ob-tangle: Tangle BibTeX files with the standard .bib file extension Ihor Radchenko
2025-01-05 16:32   ` Rudolf Adamkovič
2025-01-05 16:48     ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250105102055.62372-1-rudolf@adamkovic.org \
    --to=rudolf@adamkovic.org \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).