I'd like some kind of visual feedback in the mode-line, saying whether the current buffer is a file that is added to the org-agenda. Is there some way to do that?;)
1 Answer
I recommend always avoiding unnecessary dynamic evaluations in the mode line, so I suggest you do the look-up in find-file-hook
. The simplest approach to that means that you won't automatically see mode line 'corrections' to existing buffers if you update org-agenda-files
(you would need to revisit the file), but the benefit is that the mode line rendering is very cheap.
(require 'org)
(defvar-local my-org-agenda-file-p nil
"Whether this buffer's file is a member of `org-agenda-files'.")
(defun my-org-agenda-file-check ()
"Update `my-org-agenda-file-p'."
(when (member buffer-file-name (org-agenda-files t))
(setq my-org-agenda-file-p t)))
(add-hook 'find-file-hook #'my-org-agenda-file-check)
(add-to-list 'global-mode-string '(my-org-agenda-file-p "Agenda"))
I can't guess whether you want to pass the ARCHIVES argument to org-agenda-files
, so you should check that yourself.
(org-agenda-files &optional UNRESTRICTED ARCHIVES)
-
Instead of the
(mapcar #'expand-file-name org-agenda-files)
, it might be better to use(org-agenda-files)
which expands the variable appropriately in all cases.– NickDApr 6 at 16:21 -
org-agenda-files
" ?