%%
%% Paredit Reference Card.
%%
%% Dan Cross <net!gajendra!cross>
%%
\documentclass[landscape,8pt]{scrartcl}

\usepackage{color}
\usepackage{fullpage}
\usepackage[margin={1cm,1cm}]{geometry}
\usepackage{multicol}

\newenvironment{function}[2]{
  \noindent\begin{minipage}{\textwidth}\textbf{#1}~~\texttt{#2}\par\smallskip}{\end{minipage}}
\newcommand{\cursor}{{\color{red}\vline height 6pt width 1pt}}
\newcommand{\example}[1]{\texttt{#1}\par\smallskip}
\newcommand{\spaces}[1]{\hspace*{0pt}#1}
\newcommand{\tbs}{\textbackslash}

\title{\vspace{-1cm}Paredit Reference Card}
\subtitle{(for version 22)}
\date{}
\author{}

\begin{document}
  \begin{multicols}{4}
    \maketitle
    \thispagestyle{empty}
    \vspace{-2cm}

    \section*{Basic Insertion Commands}

    \begin{function}{paredit-open-round}{(}
      \example{(a b \cursor c d)\\*
               (a b (\cursor) c d)}
      \example{(foo "bar \cursor baz" quux)\\*
               (foo "bar (\cursor baz" quux)}
    \end{function}

    \begin{function}{paredit-close-round}{)}
      \example{(a b \cursor c \ )\\*
               (a b c)\cursor}
      \example{; Hello,\cursor{} world!\\*
               ; Hello,)\cursor{} world!}
    \end{function}

    \begin{function}{paredit-close-round-and-newline}{M-)}
      \example{(defun f (x\cursor~~))\\*
               (defun f (x)\\*\spaces{~~}\cursor)}
      \example{; (Foo.\cursor\\*
               ; (Foo.)\cursor}
    \end{function}

    \begin{function}{paredit-open-square}{[}
      \example{(a b \cursor c d)\\*
               (a b [\cursor] c d)}
      \example{(foo "bar \cursor baz" quux)\\*
               (foo "bar [\cursor baz" quux)}
    \end{function}

    \begin{function}{paredit-close-square}{]}
      \example{(define-key keymap [frob\cursor~~] 'frobnicate)\\*
               (define-key keymap [frob]\cursor{} 'frobnicate)}
      \example{; [Bar.\cursor\\*
               ; [Bar.]\cursor}
    \end{function}

    \begin{function}{paredit-doublequote}{"}
      \example{(frob grovel \cursor full lexical)\\*
               (frob grovel "\cursor" full lexical)}
      \example{(foo "bar \cursor baz" quux)\\*
               (foo "bar \tbs"\cursor baz" quux)}
    \end{function}

    \begin{function}{paredit-meta-doublequote}{M-"}
      \example{(foo "bar \cursor baz" quux)\\*
               (foo "bar baz"\\*\spaces{~~~~~}{\cursor}quux)}
      \example{(foo \cursor{} (bar \#\tbs{}x "baz \tbs\tbs{} quux") zot)\\*
               (foo "\cursor{} (bar \#\tbs\tbs{}x \tbs"baz \tbs\tbs\tbs\tbs{} quux\tbs")" zot)}
      \end{function}

    \begin{function}{paredit-backslash}{\tbs}
      \example{(string \#\cursor)\\*
               \spaces{~}Escaping character... (x)\\*
               (string \#\tbs{}x\cursor)}
      \example{"foo\cursor{} bar"\\*\spaces{~}Escaping character... (")\\*
               "foo\tbs"\cursor{} bar"}
    \end{function}

    \begin{function}{paredit-comment-dwim}{M-;}
      \example{(foo \cursor{}bar)\spaces{~~~}; baz\\*
               (foo bar)\spaces{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}; \cursor{}baz}
      \example{(frob grovel)\cursor\\*
               (frob grovel)\spaces{~~~~~~~~~~~~~~~~~~~~~~~~~~~};\cursor}
      \example{\cursor{}(defun hello-world ...)\\*
               ;;; \cursor\\*(defun hello-world ...)}
    \end{function}

    \begin{function}{paredit-newline}{C-j}
      \example{(let ((n frobbotz)) \cursor{} (display (+ n 1)\\*\spaces{~}port))\\*
               (let ((n frobbotz))\\*\spaces{~~}\cursor(display (+ n 1)\\*\spaces{~~~~~~~~~~~}port))}
    \end{function}

    \section*{Deleting \& Killing}

    \begin{function}{paredit-forward-delete}{\\* C-d, <delete>, <deletechar>}
      \example{(quu\cursor{}x "zot")\\*
               (quu\cursor{} "zot")}
      \example{(quux \cursor"zot")\\*
               (quux "\cursor{}zot")\\*(quux "\cursor{}ot")}
      \example{(foo (\cursor) bar)\\*
               (foo \cursor{} bar)}
      \example{\cursor(foo bar)\\*
               (\cursor{}foo bar)}
    \end{function}

    \begin{function}{paredit-backward-delete}{DEL}
      \example{("zot" q\cursor{}uux)\\*
               ("zot" uux)}
      \example{("zot"\cursor{} quux)\\*
               ("zot\cursor" quux)\\*("zo\cursor" quux)}
      \example{(foo (\cursor) bar)\\*
               (foo \cursor{} bar)}
      \example{(foo bar)\cursor\\*
               (foo bar\cursor)}
    \end{function}

    \begin{function}{paredit-kill}{C-k}
      \example{(foo bar)\cursor\spaces{~~~~~}; Useless comment!\\*
               (foo bar)\cursor}
      \example{(\cursor{}foo bar)\spaces{~~~~~}; Useless comment!\\*
               (\cursor)\spaces{~~~~~}; Useless comment!}
      \example{\cursor(foo bar)\spaces{~~~~~}; Useless line!\\*
               \cursor}
      \example{(foo "\cursor{}bar baz"\\*\spaces{~~~~~}quux)\\*
               (foo "\cursor"\\*\spaces{~~~~~}quux)}
    \end{function}

    \begin{function}{paredit-forward-kill-word}{M-d}
      \example{\cursor(foo bar)\spaces{~~~~}; baz\\*
              (\cursor{} bar)\spaces{~~~~; baz}\\*
              (\cursor)\spaces{~~~~}; baz\\*
              ()\spaces{~~~~}; \cursor}
      \example{;;;\cursor{} Frobnicate\\*(defun frobnicate ...)\\*
               ;;;\cursor\\*(defun frobnicate ...)\\*
               ;;;\\*(\cursor{} frobnicate ...)}
    \end{function}

    \begin{function}{paredit-backward-kill-word}{M-DEL}
      \example{(foo bar)\spaces{~~~~}; baz\\*(quux)\cursor\\*
               (foo bar)\spaces{~~~~}; baz\\*(\cursor)\\*
               (foo bar)\spaces{~~~~}; \cursor\\*()\\*
               (foo \cursor)\spaces{~~~~}; \\*()\\*
               (\cursor)\spaces{~~~~}; \\*()}
    \end{function}

    \section*{Movement \& Navigation}

    \begin{function}{paredit-forward}{C-M-f}
      \example{(foo \cursor(bar baz) quux)\\*
               (foo (bar baz)\cursor{} quux)}
      \example{(foo (bar baz)\cursor)\\*
               (foo (bar baz))\cursor}
    \end{function}

    \begin{function}{paredit-backward}{C-M-b}
      \example{(foo (bar baz)\cursor{} quux)\\*
               (foo \cursor(bar baz) quux)}
      \example{(\cursor(foo) bar)\\*
               \cursor((foo) bar)}
    \end{function}

    \section*{Depth-Changing Commands}

    \begin{function}{paredit-wrap-round}{M-(}
      \example{(foo \cursor{}bar baz)\\*
               (foo (\cursor{}bar) baz)}
    \end{function}

    \begin{function}{paredit-splice-sexp}{M-s}
      \example{(foo (bar\cursor{} baz) quux)\\*
               (foo bar\cursor{} baz quux)}
    \end{function}

    \begin{function}{paredit-splice-sexp-killing-backward}{\\*M-<up>, ESC <up>}
      \example{(foo (let ((x 5)) \cursor(sqrt n)) bar)\\*
               (foo \cursor(sqrt n) bar)}
    \end{function}

    \begin{function}{paredit-splice-sexp-killing-forward}{\\*M-<down>, ESC <down>}
      \example{(a (b c\cursor{} d e) f)\\*
               (a b c\cursor{} f)}
    \end{function}

    \begin{function}{paredit-raise-sexp}{M-r}
      \example{(dynamic-wind in (lambda () \cursor{}body) out)\\*
               (dynamic-wind in \cursor{}body out)\\*
               \cursor{}body}
    \end{function}

    \section*{Barfage \& Slurpage}

    \begin{function}{paredit-forward-slurp-sexp}{\\*C-), C-<right>}
      \example{(foo (bar \cursor{}baz) quux zot)\\*
               (foo (bar \cursor{}baz quux) zot)}
      \example{(a b ((c\cursor{} d)) e f)\\*
               (a b ((c\cursor{} d) e) f)\\*
               (a b ((c\cursor{} d e)) f)}
    \end{function}

    \begin{function}{paredit-forward-barf-sexp}{\\*C-\}, C-<left>}
      \example{(foo (bar \cursor{}baz quux) zot)\\*
               (foo (bar \cursor{}baz) quux zot)}
    \end{function}

    \begin{function}{paredit-backward-slurp-sexp}{\\*C-(, C-M-<left>, ESC C-<left>}
      \example{(foo bar (baz\cursor{} quux) zot)\\*
               (foo (bar baz\cursor{} quux) zot)}
      \example{(a b ((c\cursor{} d)) e f)\\*
               (a (b (c\cursor{} d)) e f)\\*
               (a ((b c\cursor{} d)) e f)}
    \end{function}

    \begin{function}{paredit-backward-barf-sexp}{\\*C-\{, C-M-<right>, ESC C-<right>}
      \example{(foo (bar baz\cursor{} quux) zot)\\*
               (foo bar (baz\cursor{} quux) zot)}
    \end{function}

    \section*{Miscellaneous Commands}

    \begin{function}{paredit-split-sexp}{M-S}
      \example{(hello\cursor{} world)\\*
               (hello)\cursor{} (world)}
      \example{"Hello, \cursor{}world!"\\*
               "Hello, " \cursor"world!"}
    \end{function}

    \begin{function}{paredit-join-sexp}{M-J}
      \example{(hello)\cursor{} (world)\\*
               (hello\cursor{} world)}
      \example{"Hello, "\cursor{} "world!"\\*
               "Hello, \cursor{}world!"}
      \example{hello-\\*
               \cursor\spaces{~~}world\\*
               hello-\cursor{}world}
    \end{function}

    \begin{function}{paredit-recentre-on-sexp}{C-c C-M-l}
      \example{No examples}
    \end{function}

    \begin{function}{paredit-reindent-defun}{M-q}
      \example{No examples}
    \end{function}
  \end{multicols}
\end{document}
