Skip to content

Instantly share code, notes, and snippets.

@sachac
Created March 31, 2013 00:04
Show Gist options
  • Save sachac/5278905 to your computer and use it in GitHub Desktop.
Save sachac/5278905 to your computer and use it in GitHub Desktop.
Source code for my Emacs conference talk

Comments? [email protected]

  • Emacs learning curve?

Meta information

Assumptions

  • Mix of Emacs geeks skewed towards people who’ve been using this for a while (after all, takes a certain commitment to come all the way to an Emacs conference!)

Outcomes

  • Get people excited about Emacs and the conference
  • People have the feeling of “Wow, this is an amazing platform and we can make cool stuff with it”
  • “Oh, I didn’t know Emacs could do that!” (especially for people who don’t read Planet Emacsen all the time)
  • “Hmm, what can we do to make Emacs even awesomer?”

Code for presentation

(defvar sacha/org-show-presentation-file "~/Dropbox/Emacs Conference/public.org" "File containing the presentation.")
(defvar sacha/org-show-slide-tag "slide" "Tag that marks slides.")
(defvar sacha/org-show-slide-tag-regexp (concat ":" (regexp-quote sacha/org-show-slide-tag) ":"))
(require 'eimp)
  
;; From org-pres--eimp-fit
(defun sacha/org-show-eimp-fit ()
  "Function used as a hook, fits the image found to the window."
  (when (eq major-mode 'image-mode)
    (eimp-fit-image-to-window nil)))
(add-hook 'find-file-hook 'sacha/org-show-eimp-fit)

(defun sacha/org-show-execute-slide ()
  "Process slide at point.
  If it contains an Emacs Lisp source block, evaluate it.
  If it contains an image, view it and switch to that buffer.
  Else, focus on that buffer.
  Hide all drawers."
  (interactive)
  (find-file sacha/org-show-presentation-file)
  (org-narrow-to-subtree)
  (visual-line-mode)
  (let ((heading-text (nth 4 (org-heading-components))))
    (cond
     ;; view images
     ((and (goto-char (point-min))
           (re-search-forward "\\[\\[.*\\.\\(jpg\\|gif\\|png\\)" nil t))
      (delete-other-windows)
      (let ((org-link-frame-setup '((file . find-file))))
        (org-open-at-point))
      (delete-other-windows)
      (goto-char (point-min)))
     ;; find and execute source code blocks
     ((and (goto-char (point-min))
           (re-search-forward "#\\+begin_src" nil t))
      (let ((info (org-babel-get-src-block-info)))
        (unwind-protect
            (eval (read (concat "(progn " (nth 1 info) ")"))))))
     (t
      (switch-to-buffer (current-buffer))
      (text-scale-set 4)
      (org-show-subtree)
      (org-cycle-hide-drawers t)
      (org-display-inline-images)
      (delete-other-windows)))
    (set-frame-name heading-text)))

(defun sacha/org-show-next-slide ()
  "Show the next slide."
  (interactive)
  (find-file sacha/org-show-presentation-file)
  (widen)
  (goto-char (line-end-position))
  (when (re-search-forward sacha/org-show-slide-tag-regexp nil t)
    (sacha/org-show-execute-slide)))

(defun sacha/org-show-previous-slide ()
  "Show the next slide."
  (interactive)
  (find-file sacha/org-show-presentation-file)
  (widen)
  (goto-char (line-beginning-position))
  (when (re-search-backward sacha/org-show-slide-tag-regexp nil t)
    (sacha/org-show-execute-slide)))

(global-set-key '[f5] 'sacha/org-show-previous-slide)
(global-set-key '[f6] 'sacha/org-show-execute-slide)
(global-set-key '[f7] 'sacha/org-show-next-slide)

Preparation

(menu-bar-mode 1)
(delete-other-windows)
(unless keywiz-global-map
  (keywiz 1))

Welcome!

Welcome to Emacs Conference 2013! =)

Wireless: Forward Stage: f0rw4rdst4g3

While we wait for the conference to begin (9:30), please feel free to mingle with other people / steal interesting configuration snippets / do any last-minute presentation hacking.

There are drinks in the kitchen. (Leave some for the rest. =) )

Thanks to Forward for the great venue!

9:30Sacha Chua & John Wiegley - Keynote
10:20Joakim Verona - XWidgets
11:00Nic Ferrier - Emacsing the EmacsWiki
12:00Joe Corneli - project Arxana
lunch - 12:30-14:00
14:00Sam Aaron - Title: Emacs Live - Hacking as Performance
14:20Dimitri Fontaine - El-get
15:15Michael Olson - From Marmalade To Emacs
15:45John Wiegley - Emacs Lisp Development
16:15Panel on Emacs Packaging - Marmelade, El-get, MELPA
16:45Luke Gorrie - SLIME
17:10Steve Yegge - Project Grok
18:10lightning talks/surgery

Timing

15 minutes - Present - whirlwind tour of interesting things that people are doing with Emacs (Sacha) 15 minutes - Past - how did we get here? (John) 10-13 minutes - Future (Technical) - new developments (John) 7-10 minutes - Future (Community) - how people can get deeper into the Emacs community; call to action (what’s next after this conference?) (Sacha)

Present

Emacs: Present, Past, and Future

(require 'animate)
(switch-to-buffer (get-buffer-create
                     (or animation-buffer-name
                         "*Animation*")))
(erase-buffer)
(text-scale-set 6)
(let* ((strings (list "Emacs: Present, Past, and Future" "Sacha Chua (@sachac) and" "John Wiegley (@jwiegley)" "" "March 30, 2013" "Emacs Conference (London)"))
       (vpos (/ (- 20
                   1 ;; For the mode-line
                   (1- (length strings)) 
                   (length strings))
                2))
       (width 43)
       hpos)
  (while strings
    (setq hpos (/ (- width (length (car strings))) 2))
    (animate-string (car strings) vpos hpos)
    (setq vpos (1+ vpos))
    (setq strings (cdr strings))))

My story

Unix Power Tools

When I leafed through the library’s copy of Unix Power Tools in 1997, I had no idea that I’d come across something that would change my life and warp my brain. It seemed so innocuous. In Part V, which was about Text Editing, chapter 32 was about GNU Emacs. Section 32.13 was called “An Absurd Amusement”, and it said:

‘If you have time to waste (and I mean really waste ), Emacs has things to keep you occupied. ’

The book went on to include some output from psychoanalyze-pinhead, which feeds Zippy the Pinhead to M-x doctor, the Emacs psychotherapist.

That was more than fifteen years ago, and I still feel like such an Emacs newbie.

Written 559 blog posts about Emacs

Why Emacs?

./images/dinosaur.png

Why, Emacs!

./images/why-emacs.png

Emacs is huge. There is a mind-boggling amount of stuff in here.

But it’s fun exploring Emacs, so here’s a whirlwind tour of some of the amazing things people are doing with Emacs.

Games and other amusements

Snake

(snake)

Tetris

(when (and (boundp 'snake-buffer-name) (get-buffer snake-buffer-name))
  (kill-buffer snake-buffer-name))
(delete-other-windows)
(tetris)

Dunnet

(when (and (boundp 'tetris-buffer-name) (get-buffer tetris-buffer-name))
  (kill-buffer tetris-buffer-name))
(when (get-buffer "*dungeon*")
  (kill-buffer "*dungeon*"))
(progn
  (load-library "dunnet")
  (dunnet)
  (delete-other-windows)
  (text-scale-increase 5)
  (mapcar
   (lambda (move)
     (sit-for 1)
     (insert " " move)
     (dun-parse (point)))
   '("get shovel" "look at shovel" "east" "look at boulder" "east" "dig" "look" "get card" "look at card")))
An adventure game.

Nethack

The adventure game. ./images/nethack.png

Screenshot from http://www.nongnu.org/nethack-el/nethack.png

Emacs Chess can actually talk to electronic chessboards

(or at least johnw has coded the interface for it!)

./images/novag-chess.jpg

Image from http://www.amazon.com/Novag-Carnelian-II-Chess-Computer/dp/B004G0S2WI

org-sudoku

(progn
  (load-library "~/elisp/org-mode/contrib/lisp/org-sudoku.el")
  (switch-to-buffer (get-buffer-create "*sudoku demo*"))
  (erase-buffer)
  (org-mode)
  (org-sudoku-create 50)
  (text-scale-set 6)
  (sit-for 2)
  (org-sudoku-solve))

keywiz

(keywiz (null keywiz-global-map))
(text-scale-set 4)
(delete-other-windows)
One of the promising games is keywiz, which will prompt you for Emacs keybindings

This totally needs a way to limit it to a particular package, though.

artist-mode

You can draw graphics in Emacs. This gets pretty cool with a tablet or tablet PC. Artist-mode. That could come in handy when drawing ASCII art diagrams.
(progn
  (switch-to-buffer (get-buffer-create "*artist*"))
  (erase-buffer)
  (artist-mode 1)
  (menu-bar-mode 1)
  (text-scale-set 0)
  (artist-select-op-spray-can))

artist-mode lines!

(progn
  (switch-to-buffer (get-buffer-create "*artist*"))
  (artist-select-op-line))
All kidding aside, people actually do real work with Emacs, of course.

Programming and system administration

Tramp

Many Emacs geeks are developers or system administrators, so being able to edit remote files is really cool.

Tramp: What other people have to deal with

./images/tramp01.png

Tramp: SSH

./images/tramp02.png

Tramp: SSH - SSH

./images/tramp03.png

Tramp: SSH - SSH - Sudo

./images/tramp04.png

Magit

./images/magit.png

While other people have to deal with commmand-line source code repository browsing or clunky interfaces, we’ve got things like magit that integrate into the way we work.

Screenshot from http://philjackson.github.com/magit/img/screenshot.png

Javascript REPL skewer-mode

(browse-url "http://youtube.googleapis.com/v/4tyTgyzUJqM?start=210&autoplay=1")

Programming by voice (Tavis Rudd)

(browse-url "http://www.youtube.com/v/8SkdfdXWYaI?start=547&autoplay=1")

http://puntoblogspot.blogspot.ca/2013/03/keyboardless-programming.html Pycon 2013

multiple cursors / iedit

(switch-to-buffer (get-buffer-create "*iedit demo*"))
(erase-buffer)
(when iedit-mode
  (iedit-mode))
(text-scale-set 4)
(insert "
You are in a maze of twisty little passages, all different.
You are in a little maze of twisting passages, all different.
You are in a maze of twisting little passages, all different.
You are in a little maze of twisty passages, all different.
You are in a twisting maze of little passages, all different.
You are in a twisting little maze of passages, all different.
You are in a twisty little maze of passages, all different.
You are in a twisty maze of little passages, all different.
You are in a little twisty maze of passages, all different.
You are in a maze of little twisting passages, all different.
You are in a maze of little twisty passages, all different.
")
(sit-for 1)
(re-search-backward "twisty")
(sit-for 1)
(iedit-mode 1)

Writing

Basically, org-mode bends the definition of outliners until you realise that outlines are text and text is outline and now you’re a babbling lunatic who no longer makes sense.

… And it worked. I made a ginormous table with plot summaries and I was able to chart the story pretty well and design a plot that actually makes some sense and is even more complex than the plot in the last year’s novel.

Reproducible research

./images/reproducible-research.png

https://github.com/tsdye/hawaii-colonization

Reading

Dictionary

(dictionary-search "hello")
(text-scale-set 4)
(delete-other-windows)

Flashcards with org-drill

(delete-other-windows)
(find-file "flashcards.org")
(text-scale-set 4)
(require 'org-drill)
(org-drill)

Science and math

dna-mode.el A collection of functions for editing DNA sequences. It provides functions to make editing dna in Emacs easier.

Dna-mode will:

  • Fontify keywords and line numbers in sequences.
  • Fontify bases when font-lock-mode is disabled.
  • Incrementally search dna over pads and numbers.
  • Complement and reverse complement a region.
  • Move over bases and entire sequences.
  • Detect sequence files by content.

LaTeX

./images/preview-latex.png

http://www.gnu.org/software/auctex/screenshots.html

ESS

./images/ess.png

From http://tm.r-forge.r-project.org/images/PrincipalComponentAnalysis.png

Grab-bag of other things

Remembering things

Deft

Command frequency with keyfreq

(keyfreq-show)
(other-window 1)
(text-scale-set 4)
(delete-other-windows)

Play music with EMMS

./images/emms.png

From http://www.gnu.org/software/emms/screenshots.html

… control it with your phone :slide: https://github.com/sabof/emms-mobile-remote

This one uses elnode

./images/emms-mobile.png

Helm

(helm-mini)

Gnus

./images/gnus.png

http://en.wikipedia.org/wiki/File:Gnus-reading-news.png (GPL)

Presentations

Like this one!

Collaborative editing

./images/rudel.png

http://emacswiki.org/emacs/Rudel

Emacspeak: The Complete Audio Desktop

Which is awesome!

  • Read and write (code, words, etc.)
  • Browse the web
  • Read e-books
  • Search Google Maps
  • … more!

(Doesn’t work on Windows)

Emacs Starter Kit: literate configuration

(find-file "~/.emacs.d/Sacha.org")
(text-scale-set 4)
(goto-char (point-min))

Past

(switch-to-buffer (get-buffer-create
                     (or animation-buffer-name
                         "*Animation*")))
(erase-buffer)
(text-scale-set 6)
(let* ((strings (list "How did we get here?" "John Wiegley"))
       (vpos (/ (- 20
                   1 ;; For the mode-line
                   (1- (length strings)) 
                   (length strings))
                2))
       (width 43)
       hpos)
  (while strings
    (setq hpos (/ (- width (length (car strings))) 2))
    (animate-string (car strings) vpos hpos)
    (setq vpos (1+ vpos))
    (setq strings (cdr strings))))

Future

The future

What’s next?

Planet Emacsen

(browse-url "http://planet.emacsen.org")

Channel, Usenet, mailing list…

#emacs on irc.freenode.net help.gnu.emacs various mailing lists

EmacsWiki (random is fun)

(browse-url "http://www.emacswiki.org/")

Twitter

(browse-url "https://twitter.com/search?q=emacs")

Screencasts

(browse-url "http://emacsrocks.com/e14.html")

Reddit/r/emacs

(browse-url "http://www.reddit.com/r/emacs/")

More!

  • More literate configuration and sharing!
  • More blog posts and tweets!
  • More screencasts!
  • More looking over people’s shoulders!
  • More conversations and connections!
  • More fun!

Sacha Chua - LivingAnAwesomeLife.com John Wiegley - newartisans.com

@ipstone
Copy link

ipstone commented Apr 3, 2013

awesome!

@sachac
Copy link
Author

sachac commented Apr 13, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment