This repo contains my (semi) organised .emacs.d configuration. When initialising, Emacs looks for:
~/.emacs
(which I do not use)~/.emacs.el
(which I do not use)~/.emacs.d/init.el
(which is contained in this repo)
I’ve tried to be organised by using org mode to document everything. There is still some cruft
left over from before I used a ~.emacs.d
directory and was using a .emacs
file but
essentially the control flow is as follows:
~/.emacs.d/init.el
is loaded~/.emacs.d/init.el
contains the following emacs lisp:(setq custom-file (expand-file-name "custom.el" user-emacs-directory)) (load custom-file)
custom.el
contains the emacs-lisp that is output when you use emacs’ own UI to customise variables. This code just loads that file.
~/.emacs.d/init.el
also contains the following emacs lisp:;; load the Emacs Lisp source code blocks in the given Org-mode <file>. (org-babel-load-file (concat user-emacs-directory "config.org"))
- This essentially loads
config.org
, extracts all source blocks which are labeled as having the languageemacs-lisp
, puts them into a file,config.el
, and runs the code in that file.
- This essentially loads
That’s basically it.
This usually relates to the first time you use this config or if you are using it from scratch. Basically in init.el there are a number of lines which need to be uncommented if it is the first time you are using this config:
;; (Start) Uncomment this if it is the first time using the config
(unless (package-installed-p 'use-package) ;; use-package used to isolate
(package-refresh-contents) ;; and configure packages in
(package-install 'use-package)) ;; a friendly and tidy manner.
(unless (package-installed-p 'bind-key)
(package-refresh-contents)
(package-install 'use-package))
(unless (package-installed-p 'diminish) ;; For reducing the minor modes which
(package-refresh-contents) ;; appear in the mode line.
(package-install 'use-package))
;; (End) Uncomment this if it is the first time using the config
Make sure they are uncommented and reopen emacs.
To solve this issue run the following commands from within emacs:
M-x package-reinstall RET pyvenv
M-x package-reinstall RET elpy
This will install the packages required for Python.
Using compiled .elc
files which were compiled for a previous/different version of emacs may
result in issues. This is because “packages are all bytecode compiled upon installation, so
it’s not so far fetched that they are bound to a particular version of Emacs after that.” So we
need to make sure the byte compiled files (i.e. .elc) are removed from the .emacs.d folder the
first time you initialise the config on a new machine.
Steps:
- Copy the .emacs.d folder from the old home directory to the new.
- Remove the byte compiled files from the .emacs.d directory (example script below)
# To remove the .elc files from the .emacs.d directory
cd ~/.emacs.d
find ./ -name "*.elc" -delete
On Windows you can search the .emacs.d folder for “*.elc”, sort by file type and delete all entries for elc file.
M-x package-install
diminish