From d6fb7d8ac6f682f6071ca11e2c340774344dc52b Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 31 Jul 2020 15:56:02 -0400 Subject: [PATCH] lang/org: fix mode restart in buried agenda buffers Would formerly only apply when persp-mode was active, but this has nothing to do with persp-mode, specifically. --- modules/lang/org/config.el | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/modules/lang/org/config.el b/modules/lang/org/config.el index 733238650..303e24a19 100644 --- a/modules/lang/org/config.el +++ b/modules/lang/org/config.el @@ -573,24 +573,25 @@ eldoc string." (add-hook! 'org-agenda-finalize-hook (defun +org-exclude-agenda-buffers-from-workspace-h () - "Prevent temporarily-opened agenda buffers from being associated with the -current workspace (and clean them up)." - (when (and org-agenda-new-buffers (bound-and-true-p persp-mode)) - (unless org-agenda-sticky - (let (persp-autokill-buffer-on-remove) - (persp-remove-buffer org-agenda-new-buffers - (get-current-persp) - nil))) - (dolist (buffer org-agenda-new-buffers) - (with-current-buffer buffer - ;; HACK Org agenda opens temporary agenda incomplete org-mode - ;; buffers. These are great for extracting agenda information - ;; from, but what if the user tries to visit one of these - ;; buffers? Then we remove it from the to-be-cleaned queue and - ;; restart `org-mode' so they can grow up to be full-fledged - ;; org-mode buffers. - (add-hook 'doom-switch-buffer-hook #'+org--restart-mode-h - nil 'local)))))) + "Prevent temporary agenda buffers being associated with current +workspace." + (when (and org-agenda-new-buffers + (bound-and-true-p persp-mode) + (not org-agenda-sticky)) + (let (persp-autokill-buffer-on-remove) + (persp-remove-buffer org-agenda-new-buffers + (get-current-persp) + nil)))) + (defun +org-defer-mode-in-agenda-buffers-h () + "Org agenda opens temporary agenda incomplete org-mode buffers. +These are great for extracting agenda information from, but what if the user +tries to visit one of these buffers? Then we remove it from the to-be-cleaned +queue and restart `org-mode' so they can grow up to be full-fledged org-mode +buffers." + (dolist (buffer org-agenda-new-buffers) + (with-current-buffer buffer + (add-hook 'doom-switch-buffer-hook #'+org--restart-mode-h + nil 'local))))) (defadvice! +org--exclude-agenda-buffers-from-recentf-a (orig-fn file) "Prevent temporarily opened agenda buffers from polluting recentf."