On Sun, Sep 10, 2023 at 08:19:25AM +0000, Ihor Radchenko wrote: > (defun my-org-capture-kill-buffer () > (when (equal current-prefix-arg '(16)) > (save-excursion > (org-capture-goto-last-stored) > (kill-buffer))))
Thanks for the proposed solution. I have tried it and it didn't work for me. Or it worked somehow. If it kills the buffer, then the buffer is opened again right after it is killed, jumping to the last stored position. I think this is because of the way the 'org-capture-finalize' function is implemented: ... (cond (abort-note (cl-case abort-note (clean (message "Capture process aborted and target buffer cleaned up")) (dirty (error "Capture process aborted, but target buffer could not be \ ned up correctly")))) (stay-with-capture ;; <- this cond is executed (org-capture-goto-last-stored))) ... It seems that the 'org-capture-goto-last-stored' function is called after the hooks so the buffer is opened again. This is just my interpretation. I'm not an expert in elisp.