Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Python and Life Hacking with Emacs

Python and Life Hacking with Emacs

This is a bit overloaded presentation. This is a internal presentation where I show how to use Emacs to hack python code and to organize your life a-la GTD. Link to my configuration:

https://github.com/mfcabrera/dotemacs

Miguel Cabrera

October 09, 2015
Tweet

More Decks by Miguel Cabrera

Other Decks in Technology

Transcript

  1. Python and Life
    Hacking with Emacs
    Miguel Cabrera
    [email protected]

    View full-size slide

  2. Table of Contents
    Intro
    Hacking Python with Emacs
    Life Hacking or Intro to OrgMode
    Final Thoughts

    View full-size slide

  3. What is GNU Emacs?
    Emacs is the extensible, customizable, self-documenting real-
    time display editor. –– the EmacsManual
    Text editor with more 30 years of development.
    Comes from the Emacs family of Editors developed at MIT AI Lab.
    Started by Richard Stallman in the 70's.

    View full-size slide

  4. Emacs characteristics
    Extensible
    Modern
    Customizable
    Multiplatform
    Support of many programming languages and format
    Integrates with external tools (i.e. Latex, compilers, etc…)

    View full-size slide

  5. Why not Emacs

    View full-size slide

  6. Editor Wars
    Editor war is the common name for the rivalry between users of
    the Emacs and Vi (Vim) text editors. The rivalry has become a
    lasting part of hacker culture and the free software community.
    – https://en.wikipedia.org/wiki/Editor_war

    View full-size slide

  7. The Emacs terminology and principles

    View full-size slide

  8. Sample Emacs Window

    View full-size slide

  9. Everything is a command
    Eveything is a command (i.e. a function)
    Command can be link to keyboard-shortcut
    For example C
    t
    r
    l
    -
    x C
    t
    r
    l
    -
    s will execute s
    a
    v
    e
    -
    b
    u
    f
    f
    e
    r
    Abbreviated to C
    -
    x C
    -
    s
    .
    Other keys: M
    e
    t
    a (A
    l
    t
    ) -> M
    Search and execute using M
    -
    x (e.g M
    -
    x s
    e
    a
    r
    c
    h
    -
    f
    o
    r
    w
    a
    r
    d
    )

    View full-size slide

  10. Modes
    Emacs contain editing modes that alter its basic behaviour
    Syntax highlighting
    Keyboard shortcut
    Autocompletion / Snippets
    Interaction with the Text
    Divided into major and minor modes
    1 major mode and many minor modes.
    e.g. p
    y
    t
    h
    o
    n
    -
    m
    o
    d
    e is a m
    a
    j
    o
    r mode and f
    l
    y
    m
    a
    k
    e and p
    r
    o
    j
    e
    c
    t
    i
    l
    e are minor
    modes.

    View full-size slide

  11. Configuring Emacs
    Emacs is fully customizable
    But sometimes it has too many parameters
    Too many modules doing similar things
    Might get frustrating…

    View full-size slide

  12. Emacs Packaging System
    Starting with E
    m
    a
    c
    s 2
    4
    .
    x
    , Emacs comes with a standard
    package system.
    It is now heavily used to create distributions.

    View full-size slide

  13. Popular Emacs Distributions
    (I use this one)
    Emacs Starter Kit
    Prelude Emacs
    Emacs Cabbage

    View full-size slide

  14. Spacemacs and Evilmode
    EvilMode
    Spacemacs

    View full-size slide

  15. Hacking Python with Emacs

    View full-size slide

  16. python.el
    Comes with Emacs by default
    Basic facilities to browse data and interact with python shell.
    When in doubt C
    -
    h m

    View full-size slide

  17. Anaconda Mode
    Context-sensitive code completion
    Jump to definitions
    Find references
    Diew documentation
    Virtual environment

    View full-size slide

  18. Complimentary Modes
    w
    h
    i
    t
    e
    s
    p
    a
    c
    e
    -
    m
    o
    d
    e
    F
    l
    y
    m
    a
    k
    e / F
    l
    y
    c
    h
    e
    c
    k
    Y
    a
    s
    n
    i
    p
    p
    e
    t
    s
    P
    r
    o
    j
    e
    c
    t
    i
    l
    e

    View full-size slide

  19. Elpy
    IDE Like environment in python.
    Use either J
    e
    d
    i or R
    o
    p
    e as backend.
    Integrates or replace previously mentioned modes.
    Custom project support
    Refactoring powers (imports, autopep8)
    Demo

    View full-size slide

  20. Doing Ma(Git)
    Emacs offers a great major-mode for dealing with Git

    View full-size slide

  21. Life Hacking or Intro to OrgMode

    View full-size slide

  22. My Personal History
    Looking for ways to organize my mental flow
    Tried different technologies.
    Todo Applications (Things, TimeTo, Things, etc)
    Note Taking applications (Tomboy, NotationalVelocity, etc)

    View full-size slide

  23. Gettings Things Done

    View full-size slide

  24. Getting Things Done (Workflow)

    View full-size slide

  25. Enter Org-Mode
    Org mode is for keeping notes, maintaining TODO lists,
    planning projects, and authoring documents with a fast and
    effective plain-text system.

    View full-size slide

  26. Basic concepts and usage
    Plain Text
    Note Taking
    Task Management
    Project Planning
    Authoring and Publishing
    Mobile Support

    View full-size slide

  27. Notes
    Headlines
    Levels
    Formatting
    Checklist
    Properties

    View full-size slide

  28. Tags and Properties
    Headlines can have:
    Associated dates: deadlines, schedule dates, timestamps
    Tags
    Properties

    View full-size slide

  29. Tags and Properties

    View full-size slide

  30. Getting Things Done
    TODO Keywords
    Worfklows
    File wide properties
    Dates and Timestamps

    View full-size slide

  31. Querying the data
    Sparse tree query
    Agenda views

    View full-size slide

  32. Sample Personal Workflow
    Org-Mode adapts to your mental model

    View full-size slide

  33. Interactive (org-babel)
    Literate programming in many languages
    Supports Python, Ruby, Perl, Bash
    Store small script
    Create Notebooks for any technology.
    The Babel Fish is small, yellow, and simultaneously translates
    from one spoken language to another. – The Hitchhiker's Guide
    to the Galaxy, Douglas Adams

    View full-size slide

  34. Export and Publishing
    org-mode is a light way publishing format
    supported by Github
    Export to many formats including (HTML, PDF, Markdown, Texinfo, Man, etc..)
    This presentation (using o
    r
    g
    -
    r
    e
    v
    e
    a
    l
    )
    Org-Mode is Awesome!

    View full-size slide

  35. Some Nice Integrations

    View full-size slide

  36. It is just text
    Dropbox
    NotationalVelocity
    SimpleNote
    Drafts
    Etc…

    View full-size slide

  37. Jira
    Org-jira allows to fetch, create and update Jira tasks.

    View full-size slide

  38. And more, much more…:
    Calendar sysmtes (iCal, Google Calendar)
    Outlook
    Webbrowsers
    Github
    Sublime (Org-mode plugin)
    Trello and similars
    40+ programming languages (org-babel)
    More….

    View full-size slide

  39. Final Thoughts
    Emacs provide an nice environment to code in Python.
    Emacs/Org-mode can act as a powerful Personal Information Management
    It adapts to your workflow and not the opposite
    Also can be used as a publishing tool and documentation format.

    View full-size slide

  40. Created by Miguel.

    View full-size slide