It seems to be possible with an extra package.
Initsplit (initially written by John Wiegley — one of the co-maintainers of Emacs) was designed for exactly this purpose. Unfortunately, it doesn't seem to be actively maintained, but it still works and appears to be used by people. Also unfortunately it's not on ELPA or MELPA, so you'll need to download it manually.
In a terminal:
mkdir -p ~/.emacs.d/lisp/
git clone https://github.com/dabrahams/initsplit
and add the following to your
(add-to-list 'load-path "~/.emacs.d/lisp/initsplit/")
(Obviously, you could download
initsplit.el by some other method and you could place it wherever you wish.)
Now you need to configure
initsplit to place your
org-related customisations in the right place, which is done by setting the value of
initsplit-customizations-alist (it has a relatively comprehensive docstring). This can be done either with
setq or via
customize, as for most variables.
As stated in the docstring,
initsplit-customizations-alist should be a list of lists of the form:
'((REGEXP1 FILE1 BYTECOMP PRE-LOAD)
(REGEXP2 FILE2 BYTECOMP PRE-LOAD)
I haven't managed to get the automatic "pre-load" to work and byte-compiling "customize" is probably overkill, so I recommend setting the two last elements to nil. In your case, assuming that you only want to separate out
org-related customizations, and that you used customize, you should have the following lines in your main
(("\\`org-" "~/.emacs.d/lisp/org-settings.el" nil nil))))
(The escaped backquote in the "\\`org-" regexp is used for matching only the start of the variable name, so that, say
foobar-org-variable isn't matched.)
Finally, you need to ensure that
lisp/org-settings.el is loaded (though again obviously you can use whatever paths you wish):
(add-to-list 'load-path "~/.emacs.d/lisp/")
If you use
use-package, you could try moving the relevant variables to a section of the form:
(org-agenda-span (quote day)))
However, this has the considerable disadvantage that if you make further customisations, with
customize-variable, these will still be added to the main
custom-set-variables block (and these changes might not have a permanent effect...).
Here there is some discussion on combining
initsplit, to overcome the disadvantage, but it hasn't been integrated into
You may already be aware of this, but there's an option to save all (unfortunately) your customizations in a file other than
(setq custom-file "~/.emacs-custom.el")
In this case, your customizations would be sourced from and saved to
~/.emacs-custom.el, rather than from the init file. (Example taken from the manual, which has some further details.)
This has the advantage that your init file would be kept clean, but the disadvantage that your customizations would not be grouped by package/mode/topic but still clumped all together.