6

I have a directory tasks/ in org-agenda-files variable. When i add a file to org-agenda-files variable through C-c [ command (org-agenda-file-to-front), the directory path is replaced by paths of the files, that are currently in that directory. It is bad, because when i add some files to tasks/ later on, they will not contribute to my agenda.

Is there some way to avoid this, or i'm stuck with manually adding files and directories to org-agenda-files?

This problem is acknowledged at Org Mode - Organize Your Life In Plain Text!

Emacs version: 24.0.50.1 Org-mode version: 7.8.09

Mirzhan Irkegulov
  • 17,660
  • 12
  • 105
  • 166
  • 5
    I hope I can fix this issue soon. – bzg May 13 '12 at 11:22
  • No update. But please raise this issue on the Org-mode mailing list, I don't come here very often. – bzg Mar 02 '13 at 08:03
  • Actually I don't understand the problem: the command adds a file to the list of agenda files, not the entire directory. Adding the entire directory is not what most users would want. What I'm missing? – bzg Mar 13 '14 at 15:09
  • @bzg, when you're trying to add a file, if there's already a directory in the list, it is replaced by the list of files in it. – Mirzhan Irkegulov Mar 13 '14 at 19:23
  • And it appears that the explicit filename list is not complete, there are some .org files not included. I've to re-set `org-agenda-files` manually to get those missing entries in my agenda. – Jason Mar 17 '22 at 01:57
  • I arrived at the following solution: `(add-hook 'org-mode-hook (lambda () (setq org-agenda-files (list "~/Notebooks/org"))))`. I guess I am forcing a re-assignment of `org-agenda-files` so the explicit filenames are replaced back by the folder name. – Jason Mar 17 '22 at 02:10

1 Answers1

1

You could define a command that just adds a file to org-agenda-files without calling org-agenda-files-to-front, and then rebing that to C-c [. For example:

(defun my-org-agenda-file-to-front ()
  (interactive)
  (setq org-agenda-files (append org-agenda-files (list (buffer-file-name (current-buffer))))))

(define-key org-mode-map (kbd "C-c [") `my-org-agenda-file-to-front)
Nathaniel Flath
  • 15,477
  • 19
  • 69
  • 94