3

So i've put this in my emacs.org:

(setq org-agenda-files (list
        "~/todo.org"))

But whenever i close and reopen Emacs, my org-agenda is empty until i reload my config-File. Is there anything that i've missed? Also i've tried some "eval-after-load 'org" combinations but none of them have worked for me so far. Some help or guidance in the right direction would be appreciated.

4
  • 1
    You should put that into your .emacs or .emacs.d/init.el.
    – choroba
    Commented Mar 17, 2018 at 8:55
  • Alright, i will try that out as soon as i get back to my Computer! Can you explain why this is actually relevant?
    – Tim Hilt
    Commented Mar 17, 2018 at 13:36
  • Unless configured to do so, emacs doesn't inspect emacs.org, but it inspects the files I mentioned.
    – choroba
    Commented Mar 17, 2018 at 13:50
  • Well, i actually have the init.el-file parse emacs.org. However the problem was on my side of the table: init.el is only parsed once per session; namely on startup, whereas emacs.org is set up to be manually reloaded. In my init.el file, under the custom-set-variables there was a line saying (setq 'org-agenda-files nil) which disabled all org-agenda-files on startup! No idea where this was coming from, but that explains why manually reloading emacs.org did the trick. Removed the nil-line from init.el, now everything is working fine.
    – Tim Hilt
    Commented Mar 19, 2018 at 10:27

3 Answers 3

4

@Tim Hilt, thank you! Your own answer was the answer to my problem as well, so I'm making a real answer out of it for others. Apparently you and I both must have set the Org Agenda Files entry in the Custom (M-x customize) menu.

The solution is to erase this entry in the Custom menu so that your intended value in your startup file is not erased.

There are two ways to do this:

A) From @Stefan, to get to the Custom GUI menu in question quickly:

M-x customize-variable RET org-agenda-files RET

then click on the button State and choose Erase Customization.

B)

Before @Stefan cued me to (A), the easiest way I found was to find the custom set values which looks like this in my .emacs file (it might be elsewhere for you):

(custom-set-variables
 ;; custom-set-variables was added by Custom.

then below that find the line

'(org-agenda-files nil)

And delete that sucker! Restart emacs and you should be golden!

2
  • 1
    M-x customize-variable RET org-agenda-files RET should do the trick without having to edit the auto-generated code.
    – Stefan
    Commented Jun 18, 2019 at 12:49
  • Great tip @Stefan thanks! I'll edit.
    – Reed Spool
    Commented Jun 18, 2019 at 23:12
1

I have this in my init.el

(defun my-find-org-agenda-files ()
"Find all agenda files."
(interactive)
(require 'org)
(dolist (f org-agenda-files)
  (find-file-noselect f)))

In my case call it manually when I want to, but you could call it as part of your init.el. of you want to call it automatically, add:

(my-find-org-agenda-files)

Afterwards.

Note that this loads the files into buffers without switching to any of the buffers.

3
  • When you open the agenda (C-c a a if you use the suggested key bindings ), then org opens all the agenda files in any case, so I'm not sure why you have to open them manually.
    – NickD
    Commented Jun 19, 2019 at 20:49
  • That is fine of you want to see the agenda, which I rarely do. Partly because it can be slow to bring up (I have a number of files with a lot of data). My goal is usually just to start taking more notes and the agenda view doesn't help me with that.
    – Gina White
    Commented Jun 19, 2019 at 20:53
  • Well, we can argue whether that is a proper use of org-agenda-files then (but not here: conversations in comments are discouraged), but please note that your "answer" does not answer the OP's question.
    – NickD
    Commented Jun 19, 2019 at 21:03
0

As you are using org mode for your init/emacs configuration, You can add this entry to the emacs.org , just replace with the actual location of your org file, which should be in the emacs.d (depending on system)

** Load emacs initialization file: 
    #+BEGIN_SRC key emacs-lisp
    (global-set-key (kbd "C-c i")
    (lambda() (interactive)(org-babel-load-file "~/emacs.d/emacs.org")))
    #+END_SRC

It is a babel code block that adds the binding C-c i for loading the emacs.org file.

1
  • Well, thanks for your answer but the expected behavior for me would be to let emacs load my agenda-files on startup! So i'm going with @choroba 's answer, which works great for me.
    – Tim Hilt
    Commented Mar 19, 2018 at 10:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.