emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [FR] Please add writing to existing heading in org-bibtex
@ 2022-12-27 16:24 Sterling Hooten
  2022-12-27 16:34 ` Ihor Radchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Sterling Hooten @ 2022-12-27 16:24 UTC (permalink / raw)
  To: emacs-orgmode

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



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-01-11  9:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-27 16:24 [FR] Please add writing to existing heading in org-bibtex Sterling Hooten
2022-12-27 16:34 ` Ihor Radchenko
2023-01-06 18:51   ` Sterling Hooten
2023-01-11  9:58     ` 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).