emacs-orgmode
[Top][All Lists]
Advanced

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

[FR] Please add writing to existing heading in org-bibtex


From: Sterling Hooten
Subject: [FR] Please add writing to existing heading in org-bibtex
Date: Tue, 27 Dec 2022 13:24:28 -0300

The default behavior of org-bibtex-write is to insert a new
heading with the bibliographic data in the properties. But an
alternative workflow would just update the properties of the heading at
point, rather than creating a new one. The below patch is a simple
implementation I’ve been using for a month. Would it be possible to
integrate this upstream?

Thanks,
Sterling

diff --git a/lisp/ol-bibtex.el b/lisp/ol-bibtex.el
index 81b99167b..38198eae4 100644
--- a/lisp/ol-bibtex.el
+++ b/lisp/ol-bibtex.el
@@ -703,8 +703,9 @@ Return the number of saved entries."
   (interactive "fFile: ")
   (org-bibtex-read-buffer (find-file-noselect file 'nowarn 'rawfile)))
 
-(defun org-bibtex-write ()
-  "Insert a heading built from the first element of `org-bibtex-entries'."
+(defun org-bibtex-write (&optional no-new)
+  "Insert a heading built from the first element of `org-bibtex-entries'. With 
non-nil optional NO-NEW write to heading at point instead of creating new."
+  ;; SWH 2022-11-22 changes to allow for writing heading at point instead of 
inserting new.
   (interactive)
   (when (= (length org-bibtex-entries) 0)
     (error "No entries in `org-bibtex-entries'"))
@@ -712,8 +713,9 @@ Return the number of saved entries."
         (org-special-properties nil) ; avoids errors with `org-entry-put'
         (val (lambda (field) (cdr (assoc field entry))))
         (togtag (lambda (tag) (org-toggle-tag tag 'on))))
-    (org-insert-heading)
-    (insert (funcall org-bibtex-headline-format-function entry))
+    (unless no-new
+      (org-insert-heading)
+      (insert (funcall org-bibtex-headline-format-function entry)))
     (org-bibtex-put "TITLE" (funcall val :title))
     (org-bibtex-put org-bibtex-type-property-name
                    (downcase (funcall val :type)))




reply via email to

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