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.
This commit is contained in:
Henrik Lissner 2020-07-31 15:56:02 -04:00
parent ff18b1329e
commit d6fb7d8ac6
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -573,24 +573,25 @@ eldoc string."
(add-hook! 'org-agenda-finalize-hook (add-hook! 'org-agenda-finalize-hook
(defun +org-exclude-agenda-buffers-from-workspace-h () (defun +org-exclude-agenda-buffers-from-workspace-h ()
"Prevent temporarily-opened agenda buffers from being associated with the "Prevent temporary agenda buffers being associated with current
current workspace (and clean them up)." workspace."
(when (and org-agenda-new-buffers (bound-and-true-p persp-mode)) (when (and org-agenda-new-buffers
(unless org-agenda-sticky (bound-and-true-p persp-mode)
(let (persp-autokill-buffer-on-remove) (not org-agenda-sticky))
(persp-remove-buffer org-agenda-new-buffers (let (persp-autokill-buffer-on-remove)
(get-current-persp) (persp-remove-buffer org-agenda-new-buffers
nil))) (get-current-persp)
(dolist (buffer org-agenda-new-buffers) nil))))
(with-current-buffer buffer (defun +org-defer-mode-in-agenda-buffers-h ()
;; HACK Org agenda opens temporary agenda incomplete org-mode "Org agenda opens temporary agenda incomplete org-mode buffers.
;; buffers. These are great for extracting agenda information These are great for extracting agenda information from, but what if the user
;; from, but what if the user tries to visit one of these tries to visit one of these buffers? Then we remove it from the to-be-cleaned
;; buffers? Then we remove it from the to-be-cleaned queue and queue and restart `org-mode' so they can grow up to be full-fledged org-mode
;; restart `org-mode' so they can grow up to be full-fledged buffers."
;; org-mode buffers. (dolist (buffer org-agenda-new-buffers)
(add-hook 'doom-switch-buffer-hook #'+org--restart-mode-h (with-current-buffer buffer
nil 'local)))))) (add-hook 'doom-switch-buffer-hook #'+org--restart-mode-h
nil 'local)))))
(defadvice! +org--exclude-agenda-buffers-from-recentf-a (orig-fn file) (defadvice! +org--exclude-agenda-buffers-from-recentf-a (orig-fn file)
"Prevent temporarily opened agenda buffers from polluting recentf." "Prevent temporarily opened agenda buffers from polluting recentf."