Emacs As Python IDE

Why Use IDE?

laziness…..

laziness.jpg
Image Credit: https://academichelp.net/
              

Getting Started

Install Emacs

Emacs Tutorial

Moving in a file.

Moving between files.

Package Management

Built in to emacs24

(require 'package)
(package-initialize)

M-x package-list-packages
              

Getting more packages

(setq package-archives
  '(("gnu" . "http://elpa.gnu.org/packages/")
    ("marmalade" . "https://marmalade-repo.org/packages/")
    ("melpa" . "http://melpa.milkbox.net/packages/")))
              

Starter kits

A better way to get started.

git clone https://github.com/bbatsov/prelude ~/.emacs.d/

git clone https://github.com/purcell/emacs.d ~/.emacs.d/

git clone https://github.com/technomancy/emacs-starter-kit ~/.emacs.d/
              

Python Mode

Provided by Emacs itself.

M-x python-mode  ;;  Python-mode
              

elpy

Best package for python development.

Batteries included.

pip install rope
pip install jedi
pip install flake8
pip install importmagic
              
M-x package-install RET elpy
              
(package-initialize)
(elpy-enable)
              

Error Checking

Warning-as-you-type

(i.e. some errors don't even require a compile cycle)

Docs

Shows function signature

Get docs

C-c C-d  ;; elpy-doc
              

Code Navigation.

Navigate code by treating them as hyperlinks.

M-.  ;; elpy-goto-definition
M-*  ;; pop-tag-mark
              

Autocompletion

Autocompletion when you can't remember the all names.

Jedi/Rope - Python specific

Company/Auto-complete - General auto complete

Elpy comes with company-mode

M-<n>  ;; select nth item
              

Snippets

Package: yasnippet

Elpy comes with yasnippet

Debugging

Debug using pdb.

import ipdb
ipdb.set_trace()
              

Test Integration

Configure Your Test Runner.

M-x elpy-set-test-runner
C-c C-t  ;; runs test/ all tests
              

Virtual Environment

Elpy comes with pyvenv

M-x pyvenv-workon

M-x pyvenv-activate

M-x pyvenv-deactivate
              

Web mode

M-x package-install RET web-mode RET
              
(require 'web-mode)
(add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))

(setq web-mode-engines-alist '(("django" . "\\.html\\'")))

(setq web-mode-markup-indent-offset 2)
(setq web-mode-code-indent-offset 2)
(setq web-mode-css-indent-offset 2)

(setq web-mode-enable-auto-pairing t)
(setq web-mode-enable-auto-expanding t)
(setq web-mode-enable-css-colorization t)
              

Auto opening, Auto completion, Auto expanders

Code folding, Navigation

Snippets - HTML/Django

Context aware processing.

Files/Projects

Explore system all files in system. Explore files related to particular project.

Packages: projectile, dired-plus

C-c p p  ;; switch projects
C-c p f  ;; list project files
C-c p g  ;; grep project
              

Source Control Integration

Packages: magit, git-gutter, git-blame

C-x g  ;; starts magit buffer
              

Process

Python process

Terminal

Databases

Useful packages

helm

paredit

ace-jump-mode

multiple-cursors

expand-region

use-package

Beyond IDE

IRC Client.

StackExchange Client.

Read mail, tweets.

Documenting projects.

Todo lists.

Listening music.

Browse web.

Interpret lisp.

News reader.

Terminal multiplexer.

Play games.

Video editor.

Spreadsheet.

Document viewer.

Prepare presentations.

Resources

http://emacswiki.org/

http://melpa.org/

http://ergoemacs.org/

http://masteringemacs.org

http://emacsrocks.com/

https://github.com/jorgenschaefer/elpy

Questions?