0

Each time I launch Emacs, org-agenda-files is reset to nil. I can C-h v org-agenda-files, which confirms that the value of the variable is nil.

I have the following in .emacs.d/package-init.el:

(use-package org
  :ensure t
  :config
  (setq org-agenda-files (quote ("~/org/"))
        org-startup-indented 1
        org-default-notes-file (concat org-directory "/inbox.org")
        org-refile-targets '(
                             (nil :maxlevel . 9)
                             (org-agenda-files :maxlevel . 9)
                             )
        org-agenda-window-setup 'current-window
        org-agenda-restore-windows-after-quit t
        )
  (define-key global-map "\C-cc" 'org-capture)
  (global-set-key (kbd "C-c l") 'org-store-link)
  (global-set-key (kbd "C-c a") 'org-agenda)
  (global-set-key (kbd "C-c c") 'org-capture)
  (add-hook 'org-mode-hook 'turn-on-flyspell)
  )

Everything else under the :config for org mode is getting set correctly.

What’s really strange is that if I open the package config file as a buffer and M-x eval-buffer, org-agenda-files gets set correctly, which I can confirm by using help on the variable.

How is this possible?

  • 1
    Can you try removing some of that code, to get a minimal recipe to repro the problem? And start Emacs using emacs -Q (no init file), to narrow things further. (If you don't see the problem without using your init file, then bisect your init file to find the culprit.) – Drew Feb 19 at 21:28
  • Who loads package-init.el? AFAIK, emacs only loads ~/.emacs or ~/.emacs.d/init.el - right? – NickD Feb 20 at 1:49
  • If you have Emacs 26 put (debug-on-variable-change 'org-agenda-files) before your use-package form and restart Emacs. The debugger should be triggered at least once at the use-package command. You can continue by pressing c. If the debugger is triggered a second time the stack-trace should show you the culprit. Maybe the debugger is never triggered. That would indicate that the variable is never set. Could be because the init file is not loaded or because use-package does not what you expect. – Tobias Feb 20 at 10:03
  • So it looks like there was a line in (custom-set-variables) that was setting the variable to nil. In my init.el, I have a command to load package_init.el... but it was before the block for custom-set-variables I never look at the custom-set-variables chunk because I'm not really sure what it is, and the comments say not to edit it by hand. Thanks for the help though guys. – Joseph Morgan Feb 21 at 21:04
1

Check your custom.el.

I have frequently been caught out with having explicit :custom sections in use-package forms. Often things are saved in groups including these values - and the custom.el values then override your :custom declarations.

Look for custom-set-variables.

| improve this answer | |
  • 1
    edited to specifically mention custom-set-variables as opposed to just custom.el. – RichieHH Feb 21 at 21:56
  • Thanks Richie! I thought that's what you were talking about, but wanted to look into what custom.el was a little bit before marking this answer as correct. Seems like you were totally right though! – Joseph Morgan Feb 22 at 3:36
0

So, it looks like there was a line in (custom-set-variables) in my init.el that was setting (org-agenda-files) to nil. (custom-set-variables) is after the line where I source my package_config.el.

Seems silly that I didn't notice that to begin with, sorry that I wasted anyones time. Honestly, I'm not sure what the (custom-set-variables) chunk in my .init.el is, I'm fairly new to Emacs. The commonts in the chunk say not to edit it by hand, so I just kind of ignore it.

Thanks for all the help everyone!

| improve this answer | |
  • please feel free to make my reply the answer ;) – RichieHH Feb 21 at 21:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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