Closed akashpal-21 closed 4 months ago
Sketch of a proof-of-concept global kill-emacs-hook
(defvar org-transclusion-buffers nil)
(defun org-transclusion-add-to-buffer-list (&rest args)
(add-to-list 'org-transclusion-buffers (current-buffer) t 'equal))
(defun org-transclusion-remove-from-buffer-list (&rest args)
(setq org-transclusion-buffers (delete (current-buffer) org-transclusion-buffers)))
(defun org-transclusion-before-kill-emacs (&rest args)
(when org-transclusion-buffers
(dolist (buffer org-transclusion-buffers)
(with-current-buffer buffer
(funcall #'org-transclusion-before-kill)))))
(advice-add 'org-transclusion-add :after #'org-transclusion-add-to-buffer-list)
(advice-add 'org-transclusion-remove-all :after #'org-transclusion-remove-from-buffer-list)
(add-hook 'kill-emacs-hook #'org-transclusion-before-kill-emacs)
Closing -- not org-transclusion related. But should be kept in mind as a known limitation,
consider the simple case
test2
in your desktopWhen emacs is running in daemon mode - the local hook only runs successfully
iff
when emacs receives the restart signal using
systemctl --user restart emacs
the buffer is currently active and visibleIf user switches to another buffer or closes client the local-hook never runs.
This hook in buffer-local mode is used by org-transclusion when running the
org-transclusion-before-kill
and suffers from the same limitation.