[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: emacs configuration

From: John W Higgins
Subject: Re: emacs configuration
Date: Thu, 30 Sep 2021 09:38:25 -0700

Good Morning,

On Thu, Sep 30, 2021 at 8:44 AM Jude DaShiell <> wrote:

> Has emacs got something like an #include directive that can be used as it
> is in C?  If so, it might be worth using it to tidy up my .emacs file.
This is what I've used for years - I'm sure it's not elegant or anything
else - but it's served me well.

First I use a ~/.emacs.d/init.el file as opposed to a ~/.emacs file - they
are equivalent[1].

;; Starting point is that load-file-name returns the name of the current
file - so again for me this is ~/.emacs.d/init.el as opposed to ~/.emacs
;; Setup the config dir

(setq dev-emacs-init-file load-file-name)
(setq dev-emacs-config-dir
      (file-name-directory dev-emacs-init-file))

;; We now have dev-emacs-config-dir with ~/.emacs.d stored

;; Setup 'init' folder

(setq dev-init-dir
      (expand-file-name "init" dev-emacs-config-dir))

;; Now we have dev-init-dir with ~/.emacs.d/init

;; Load all the custom files inside the init dir

;; This loads any file under the ~/.emacs.d/init folder with a file name of
000_blah.el in numerical order.
;; i.e. 001_blah.el loads before 001_foo.el or 002_blah.el
(if (file-exists-p dev-init-dir)
    (setq init-files (directory-files dev-init-dir t
(dolist (file init-files)
  (load file))

;; This allows me to have as many files as my brain feels is appropriate.


P.S. I'm very certain I copied this from somewhere at some point. I have no
idea where or when however :)

[1] -

reply via email to

[Prev in Thread] Current Thread [Next in Thread]