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
(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."