Posts Tagged by Emacs

Emacs Paredit Notes for OSX

Some notes on Emacs’ Paredit mode. More so I can stop fighting with Paredit and do some Clojure programming than show any expertise – see Mudphone’s Paredit Preso for the real deal, as well as hagelb’s Paredit screencast notes and the Paredit Cheat Sheet.

  • M-(  wrap parens around something. Also for { [ “
  • M-s  remove parens from something
  • M-S-s  split sexpr into two
  • M-S-j  join sexprs
  • C-q ♦  just do what I say, dammit! force insert of paren or bracket ♦
  • C-u DEL  force delete paren or bracket

“Barfage and slurpage” ie moving parens left and right.  I had some trouble getting this going on OSX, as the terminal doesn’t seem to map control key sequences correctly. After modifying emacs (see below), I got these going:

  • C-<right>, C-<left>  move right paren right or left
  • ESC C-<right>, ESC C-<left> move left paren right or left

I wrote this elisp for my ~/.emacs.d/sonia.el (I’m using Technomancy’s Emacs Starter Kit):

(when (eq system-type 'darwin)
  (eval-after-load 'paredit
    '(progn
       ;; C-left
       (define-key paredit-mode-map (kbd "M-[ 5 d")
                   'paredit-forward-barf-sexp)
       ;; C-right
       (define-key paredit-mode-map (kbd "M-[ 5 c")
                   'paredit-forward-slurp-sexp)
       ;; ESC-C-left
       (define-key paredit-mode-map (kbd "ESC M-[ 5 d")
                   'paredit-backward-slurp-sexp)
       ;; ESC-C-right
       (define-key paredit-mode-map (kbd "ESC M-[ 5 c")
                   'paredit-backward-barf-sexp)
     )))

Lisp Parens

Vim Buffers Cheatsheet

A small Vim Buffers cheatsheet:

:bu <tab>    - select a buffer
:buN         - select buffer N
:ls          - list buffers
:sb tab      - split screen on another buffer
:sbN         - split screen on buffer N
:only        - make this the only buffer (ie maximise)
^w^o         - make this the only buffer (ie maximise)
:ball        - split screen on all buffers
:hide        - hide this buffer
:bdel        - remove buffer from list

Vim buffers don’t seem as flexible as the Emacs equivalent, but then nothing is as flexible as Emacs:

Xkcd Emacs

http://xkcd.com/378/