Generating today's agenda in Org-Mode (
C-c a a) opens the files in
org-agenda-files. I don't want Emacs to open these extra buffers.
Is there an easy way to tell Emacs not to open these buffers? (or what is the same, to automatically close them if they weren't open before calling the agenda?).
This is a more compact version of the solution provided by @lawlist:
(require 'dash) (defun my-org-keep-quiet (orig-fun &rest args) (let ((buffers-pre (-filter #'get-file-buffer (org-agenda-files)))) (apply orig-fun args) (let* ((buffers-post (-filter #'get-file-buffer (org-agenda-files))) (buffers-new (-difference buffers-post buffers-pre))) (mapcar (lambda (file) (kill-buffer (get-file-buffer file))) buffers-new)))) (advice-add 'org-agenda-list :around #'my-org-keep-quiet) (advice-add 'org-search-view :around #'my-org-keep-quiet) (advice-add 'org-tags-view :around #'my-org-keep-quiet)
Regrettably, this still is not perfect, as now clicking on an event in the agenda does not open the corresponding org file.