I'm trying to add a new file foo.org and delete an old bar.org from the org-refile-target variable. So doing

(setq org-refile-targets   (quote (("~/foo.org" :maxlevel . 2))

should work by replacing the former

(setq org-refile-targets   (quote (("~/bar.org" :maxlevel . 2))

However, if I run the new code (i.e., the first line above), then the fix only works in the current session. Upon re-start changes are lost.

And even in the current session, if I do C-h v org-refile-target I see the changes under the Value heading. But the old settings are under the headings saved-value and theme-value. How come?

By the way, previously I was using

      '(org-refile-targets '(("~/foo.org" :maxlevel . 2)

with the same result. Plus I don't have a custom file that loads on Emacs's startup.

I've tried org-refile-cache-clear to no avail... so where on earth are the old settings stored and how can I override them?? Is setq-default the answer? (just tested and it is not the answer)

  • I don't know about the current session problem, but about the restarting problem: you are probably setting it in your init file ($HOME/.emacs or $HOME/.emacs.d/init.el).
    – NickD
    Commented Nov 13, 2021 at 15:49
  • Hi Nick, sorry, I forgot to mention all of my editings are in init.el, hence my surprise. Thanks for the reply!
    – Daniel
    Commented Nov 13, 2021 at 16:44
  • Why are the parentheses not matching?
    – NickD
    Commented Nov 13, 2021 at 19:31

1 Answer 1


Use M-x customize-option to change the value to whatever you want - and save it. Customize persists your settings; setq does not.

If you don't use a separate custom-file (I recommend you do use one), which you then load from your init file, then Customize saves your settings in your init file.

If you don't want to use the Customize UI then you can use function customize-set-variable or custom-set-variables, instead. They don't persist the settings they make, but you can use them in your init file to set things when it's loaded. (You can also use customize-save-variable or custom-save-variables.)

  • Hi Drew, thanks for your reply. I don't like using any point-and-click solution as in M-x customize-option. setq or setq-default on your init.el should be loaded and applied on startup. However, sometimes one messes up the powers of setq by having a custom-file, which is why I've deleted mine. The question is, How come my settings are not affected completely by my variable definition in my init.el?
    – Daniel
    Commented Nov 13, 2021 at 18:46
  • setq and setq-default do what you expect in your init file, assuming your init file gets loaded (does it?). Put a call to message after your setq in your init file, to see if it took effect properly. It's also possible that something else done after you set it overrides that setting. This message call will tell you about that too. (setq-default is only needed if the variable is sometimes or always buffer-local.)
    – Drew
    Commented Nov 13, 2021 at 19:11
  • I've just checked and the messages I've written before and after my setq org-refile-targets are printed, so the code is run... The only plausible thing is that there is something reverting my changes but I don't find anything obvious... my main suspect was the custom file but I don't have one... uhhhhhmmmm
    – Daniel
    Commented Nov 14, 2021 at 16:10
  • Would someone like to explain the downvote?
    – Drew
    Commented Jan 15 at 16:21

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.