## Create a new config/initialisation file
Create a user-level initialisation file init.el
:
touch .emacs.d/init.el
Add the following to the init.el
file:
;; init.el --- Emacs configuration
;; Set OSX function key as Meta
;; INSTALL PACKAGES
;; --------------------------------------
(require 'package)
(add-to-list 'package-archives
'("elpy" . "http://jorgenschaefer.github.io/packages/"))
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/") t)
;; activate all packages
(package-initialize)
;; fetch the list of packages available
(unless package-archive-contents
(package-refresh-contents))
;; define list of packages to install
(defvar myPackages
'(better-defaults
material-theme
exec-path-from-shell
elpy
pyenv-mode))
;; install all packages in list
(mapc #'(lambda (package)
(unless (package-installed-p package)
(package-install package)))
myPackages)
;; Use shell's $PATH
(exec-path-from-shell-copy-env "PATH")
;; init.el ends here
Here, better-defaults
is a set of minor changes to Emacs defaults, and material-theme
is an Emacs display theme.
We have to use the GitHub repo for elpy
, or else an error is thrown with a variable xref-location
1
If, on startup, packages can't be found, try M-x pacakge-refresh-contents
.
Add the following to the init.el
file, after the INSTALL PACKAGES
section:
;; BASIC CUSTOMIZATION
;; --------------------------------------
(setq inhibit-startup-message t) ;; hide the startup message
(load-theme 'material t) ;; load material theme
(global-linum-mode t) ;; enable line numbers globally
(setq linum-format "%4d \u2502 ") ;; format line number spacing
;; Allow hash to be entered
(global-set-key (kbd "M-3") '(lambda () (interactive) (insert "#")))
This loads the material
theme, turns off the startup message, and enables line numbering in all buffers.
Extend the list of packages to install, by adding elpy:
;; define list of packages to install
(defvar myPackages
'(better-defaults
material-theme
elpy))
and add the commands to enable elpy
and its interactions:
(elpy-enable)
(pyenv-mode)
(setq python-shell-interpreter "ipython"
python-shell-interpreter-args "-i --simple-prompt")
To help elpy
out, provide autocompletion and syntax checking/linting, install the following at the command-line (e.g. with pip
):
jedi
autopep8
flake8
ipython
importmagic
yapf
M-x pyvenv-activate
Then enter the name/location of the venv
good