Hi. I use Emacs from Guix---package emacs-next installed from Git master (through --with-branch=emacs-next=master) and updated weekly. Org is also from Guix: packages emacs-org{,-contrib,-drill,-pdftools} To reproduce the bug, save the attached file¹ then invoke: emacs -q -l /PATH/TO/org-log-note-clock-out--bug.el --batch - Expected behavior: Org should clock in the first heading, then clock out from it, prompt for a note, and clock in the second heading (in batch mode, Emacs should print some clocking messages and then exit successfully). - What happens: Org errors out: user-error: Before first headline at position 164 in buffer *Org Note* I stepped through the code and verified the error is triggered at line 1726 on file org-clock.el. This is the form (org-back-to-heading t) on function `org-clock-remove-empty-clock-drawer'. That function runs as a hook because of line 1717 on file `org-clock.el': (run-hooks 'org-clock-out-hook) on function `org-clock-out'. Then using git-bisect, I have determined the bug was introduced on commit c670379adfbdc4883d3cfa230289fd2829993265. I am sorry for not providing a patch. As a temporary workaround, I have erased my customization of `org-log-note-clock-out'. Regards ¹ Do you prefer this kind of small file to be attached to the mail message as I have done here or should I have included it in the mail body? Emacs : GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.24, cairo version 1.16.0) Package: Org mode version 9.4.6 (9.4.6-gab9f2a @ /gnu/store/2pny4z6mbi2aybgzzxz0yrzkds7hbpmq-emacs-org-9.4.6/share/emacs/site-lisp/org-9.4.6/) -- - "In Support of Richard Stallman" - I am Brazilian. I hope my English is correct and I welcome feedback. - Free Software Supporter: - If an email of mine arrives at your spam box, please notify me.