Org-mode, Magit, and Restclient

Table of Contents

Introduction

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

"Magit is an interface to the version control system Git, implemented as an Emacs package. Magit aspires to be a complete Git porcelain."

"Restclient is a tool to manually explore and test HTTP REST webservices. "

Org-mode

Org-mode is often cited as the main reason to use Emacs, and one of the main reasons that people switch from other editors. If you boil Org down to its simplest form, it's really a plain-text markup system with a large library of interactions that operate on that text.

On top of this markup language is built a large number of features:

  • Great Navigation
  • Export to a myriad of formats
  • TODO lists
  • Replacing Excel spreadsheets
  • Reminders and scheduling with an agenda
  • Project management
  • Websites (see the denver emacs site!)
  • Quick capture of notes
  • Literate programming with org-babel
  • … and more!

We'll be using an example org file to follow along, so check out the example.org (here's an HTMLized version) file. There's no way I can cover everything that org-mode offers in a single session, so we'll start with some of the basics and can elaborate on them in further talks.

People have written whole books in Emacs with org-mode (I wrote a couple of the chapters of Elasticsearch In Action with org-mode), as well as teaching classes and writing/grading assignments with it.

Configuration

Here's the configuration we used for the demo:

(require 'org)
;; Setup C-c c to capture new TODOs
(global-set-key (kbd "C-c c") 'org-capture)
;; Setup a key bind for the agenda
(global-set-key (kbd "C-c a") 'org-agenda)
;; Set up agenda to know about our file, you can use a list of files or
;; directories here
(setq org-agenda-files '("~/todo.org"))
;; A new template
(setq org-capture-templates
      '(("t" "Todo" entry (file "~/todo.org")
         "* TODO %?\n%U\n")))

Some other template ideas:

Taking quick notes

(setq org-capture-templates
      '(("t" "Todo" entry (file "~/todo.org")
         "* TODO %?\n%U\n")
        ("n" "Notes" entry (file+headline "~/notes.org" "Notes")
         "* %? :NOTE:\n%U\n")))

Collecting a "here's what I did today" journal

(setq org-capture-templates
      '(("t" "Todo" entry (file "~/todo.org")
         "* TODO %?\n%U\n")
        ("n" "Notes" entry (file+headline "~/notes.org" "Notes")
         "* %? :NOTE:\n%U\n")
        ("j" "Journal" entry (file+datetree "~/journal.org")
         "* %?\n%U\n")))

More resources

Magit

Magit is Git power x 1000. Hard to type this one, a live demonstration is necessary. If you are unable to see my live demonstration, check out the exhaustive manual Magit provides.

Installation:

M-x package-install RET magit

The recommended way to set up Magit is to globally bind it to C-x g in your emacs init, like so:

(global-set-key (kbd "C-x g") 'magit-status)

When invoked, if you are editing a file from a project it will automatically determine the git repository you are working with.

DEMO - Lee

More resources

Here's a nice visual introduction to Magit if you didn't get a chance to see my demo: https://www.youtube.com/watch?v=vQO7F2Q9DwA

Restclient

Restclient lets you explore HTTP APIs by providing a nice interface for typing and executing requests as well as pretty-printing the responses that come back.

Installation:

M-x package-install RET restclient

Some of the basic keybindings:

Key Action
C-c C-c Execute the request
C-c C-r Execute the request without a fancy buffer
C-c C-v Execute the request and don't switch to the buffer
C-c C-p/n Jump to the previous/next request
C-c C-. Mark request under the cursor
C-c C-u Copy the currently marked request as a curl command

Let's start with an example of interacting with the Elasticsearch API using restclient: files/elasticsearch.rest

More resources

Here's a demonstration of restclient mode: http://emacsrocks.com/e15.html

Author: Lee Hinman

Created: 2015-11-06 Fri 15:04

Emacs 24.5.2 (Org mode 8.2.10)

Validate