Skip to content

Instantly share code, notes, and snippets.

@wllhf
Last active May 20, 2016 12:18
Show Gist options
  • Save wllhf/22f8e308ec9b05b1eb0e to your computer and use it in GitHub Desktop.
Save wllhf/22f8e308ec9b05b1eb0e to your computer and use it in GitHub Desktop.
Emacs as Python IDE for Emacs >= 24.3
;; Emacs as Python IDE for Emacs >= 24.3
;; Copy this file in your .emacs.d to setup emacs as a Python IDE.
;; If you want to integrate this into your existing configuration,
;; of course, you should put the seperate parts of this code in the
;; appropriate files.
;; Credits, documentation and further reading:
;; Jorgen Schaefers elpy - https://github.com/jorgenschaefer/elpy
;; elpy doc - http://elpy.readthedocs.org/en/latest/introduction.html
;; Yusuke Tsutsumis blog : http://y.tsutsumi.io/emacs-from-scratch-part-2-package-management.html
;; Package management
;; Require package manager (build in manager is called package)
(require 'package)
(require 'cl)
;; Add package sources: Jorgen Schaefers archive for elpy
(add-to-list 'package-archives
'("elpy" . "https://jorgenschaefer.github.io/packages/"))
;; Initalize package system
(package-initialize)
;; List of emacs packages we want to be installed
;; Required system packages:
;; - elpy: rope jedi flake8 importmagic autopep8 yapf
;; install system packages e.g. via apt-get for ubuntu or via pip)
(defvar required-packages
'(
elpy ; Python editing and IDE features for emacs.
) "List of required emacs packages." )
;; method to check if all required packages (the ones in required-packages variable) are installed
(defun packages-installed-p ()
(cl-every 'package-installed-p required-packages))
;; if there are packages that are not yet installed, check one by one and install the missing ones.
(unless (packages-installed-p)
; check for new packages (package versions)
(message "%s" "Refreshing package database...")
(package-refresh-contents)
(message "%s" " done.")
; install the missing packages
(dolist (p required-packages)
(when (not (package-installed-p p))
(package-install p))))
; require and enable installed packages
(elpy-enable)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment