08965030b28b

Roswellize the lispindent thing, unfuck paredit, and more
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Wed, 20 Apr 2016 10:38:25 +0000
parents f13a2b1ddedf
children 9bead8a9b435
branches/tags (none)
files .hgignore bin/lisp bin/lispindent bin/lispindent.lisp bin/lispindentclean lispwords roswell/lispindent.ros userContent.css vim/after/plugin/paredit.vim vim/bundle/ooze/plugin/ooze.vim vim/ftplugin/lisp/lispfolding.vim vim/vimrc

Changes

--- a/.hgignore	Fri Apr 15 18:06:03 2016 +0000
+++ b/.hgignore	Wed Apr 20 10:38:25 2016 +0000
@@ -39,3 +39,4 @@
 weechat/certs/ca-bundle.crt
 
 roswell/clhs
+roswell/lispindent
--- a/bin/lisp	Fri Apr 15 18:06:03 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-#!/usr/bin/env bash
-
-set -e
-
-rlwrap-sbcl "$@"
--- a/bin/lispindent	Fri Apr 15 18:06:03 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,222 +0,0 @@
-#!/usr/local/bin/sbcl --script
-
-;Dorai Sitaram
-;Oct 8, 1999
-;last change 2014-09-16
-
-;this script takes lines of Lisp or Scheme code from its
-;stdin and produces an indented version thereof on its
-;stdout
-
-(defun safe-read (stream)
-  (let ((*read-eval* nil))
-    (read stream nil)))
-
-(defun safe-read-from-string (string)
-  (let ((*read-eval* nil))
-    (read-from-string string)))
-
-
-(defvar *lisp-keywords* '())
-
-(defun define-with-lisp-indent-number (n syms)
-  (dolist (sym syms)
-    (let* ((x (symbol-name sym))
-           (c (assoc x *lisp-keywords* :test #'string-equal)))
-      (unless c
-        (push (setq c (cons x nil)) *lisp-keywords*))
-      (setf (cdr c) n))))
-
-(define-with-lisp-indent-number 0
-  '(block
-    handler-bind
-    loop))
-
-(define-with-lisp-indent-number 1
-  '(case
-    defpackage do-all-symbols do-external-symbols dolist do-symbols dotimes
-    ecase etypecase eval-when
-    flet
-    handler-case
-    labels lambda let let* let-values
-    macrolet
-    prog1
-    typecase
-    unless unwind-protect
-    when with-input-from-string with-open-file with-open-socket
-    with-open-stream with-output-to-string))
-
-(define-with-lisp-indent-number 2
-  '(assert
-    defun destructuring-bind do do*
-    if
-    multiple-value-bind
-    with-slots))
-
-(defparameter *config-files*
-  (list (merge-pathnames ".lispwords" (user-homedir-pathname))
-        ".lispwords" ))
-
-(dolist (path *config-files*)
-  (with-open-file (i path :if-does-not-exist nil)
-    (when i
-      (loop
-        (let ((w (or (safe-read i) (return))))
-          (define-with-lisp-indent-number (car w) (cdr w)))))))
-
-(defun past-next-token (s i n)
-  (let ((escapep nil))
-    (loop
-      (when (>= i n) (return i))
-      (let ((c (char s i)))
-        (cond (escapep (setq escapep nil))
-              ((char= c #\\) (setq escapep t))
-              ((char= c #\#)
-               (let ((j (+ i 1)))
-                 (if (>= j n) (return i)
-                   (let ((c (char s j)))
-                     (cond ((char= c #\\) (setq escapep t i j))
-                           (t (return i)))))))
-              ((member c '(#\space #\tab #\( #\) #\[ #\] #\" #\' #\` #\, #\;))
-               (return i))))
-      (incf i))))
-
-(defun lisp-indent-number (s &optional (possible-keyword-p t))
-  (or (cdr (assoc s *lisp-keywords* :test #'string-equal))
-      (if (zerop (or (search "def" s :test #'char-equal) -1))
-          0
-        (if possible-keyword-p
-            (let ((p (position #\: s :from-end t)))
-              (if p
-                  (lisp-indent-number (subseq s (1+ p)) nil)
-                -1))
-          -1))))
-
-(defun literal-token-p (s)
-  (let ((colon-pos (position #\: s)))
-    (if colon-pos
-        (if (= colon-pos 0) t nil)
-      (let ((s (safe-read-from-string s)))
-        (or (eql t s) (characterp s) (numberp s) (stringp s))))))
-
-;(trace lisp-indent-number literal-token-p read-from-string past-next-token)
-
-(defstruct lparen
-  word
-  spaces-before
-  num-aligned-subforms
-  (num-finished-subforms 0)
-  (num-processed-subforms 0))
-
-(defun current-word (s i n)
-  (let ((j (past-next-token s i n)))
-    (when (not (= i j))
-      (subseq s i j))))
-
-(defvar *labels-keywords* '(labels flet))
-
-(defun in-labels-p (stack w)
-  ; (format t "~%")
-  ; (format t "WORD: ~S~%" w)
-  ; (format t "STACK: ~S~%" stack)
-  (let ((target (cadr stack)))
-    ; (format t "TARGET: ~S~%" target)
-    (and target
-         (member (lparen-word target) *labels-keywords*
-                 :key #'symbol-name :test #'string-equal)
-         (= (lparen-num-processed-subforms target) 0))))
-
-(defun calc-subindent (stack s i n)
-  (let* ((j (past-next-token s i n))
-         (num-aligned-subforms 0)
-         (left-indent
-          (if (= j i) 1
-            (let ((w (subseq s i j)))
-              (if (and (>= i 2) (member (char s (- i 2)) '(#\' #\`))) 1
-                (let ((nas (if (in-labels-p stack w)
-                             1
-                             (lisp-indent-number w))))
-                  (cond ((>= nas 0) (setq num-aligned-subforms nas)
-                         2)
-                        ((literal-token-p w) 1)
-                        ((= j n) 2)
-                        (t (+ (- j i) 2)))))))))
-    (values left-indent num-aligned-subforms (1- j))))
-
-(defun num-leading-spaces (s)
-  (let ((n (length s))
-        (i 0) (j 0))
-    (loop
-      (when (>= i n) (return 0))
-      (case (char s i)
-        (#\space (incf i) (incf j))
-        (#\tab (incf i) (incf j 8))
-        (t (return j))))))
-
-(defun string-trim-blanks (s)
-  (string-trim '(#\space #\tab #\newline #\return) s))
-
-
-(defun indent-lines ()
-  (let ((left-i 0) (paren-stack '()) (stringp nil))
-    (loop
-      (let* ((curr-line (or (read-line nil nil) (return)))
-             (leading-spaces (num-leading-spaces curr-line))
-             (curr-left-i
-              (cond (stringp leading-spaces)
-                    ((null paren-stack)
-                     (when (= left-i 0) (setq left-i leading-spaces))
-                     left-i)
-                    (t (let* ((lp (car paren-stack))
-                              (nas (lparen-num-aligned-subforms lp))
-                              (nfs (lparen-num-finished-subforms lp))
-                              (extra-w 0))
-                         (when (< nfs nas) ;(and (>= nas 0) (< nfs nas))
-                           (incf (lparen-num-finished-subforms lp))
-                           (setq extra-w 2))
-                         (+ (lparen-spaces-before lp)
-                            extra-w))))))
-        (setq curr-line (string-trim-blanks curr-line))
-        (dotimes (k curr-left-i) (write-char #\space))
-        ; (princ paren-stack)
-        (princ curr-line) (terpri)
-        ;
-        (let ((i 0) (n (length curr-line)) (escapep nil)
-              (inter-word-space-p nil))
-          (loop
-            (when (>= i n) (return))
-            (let ((c (char curr-line i)))
-              (cond (escapep (setq escapep nil))
-                    ((char= c #\\) (setq escapep t))
-                    (stringp (when (char= c #\") (setq stringp nil)))
-                    ((char= c #\;) (return))
-                    ((char= c #\") (setq stringp t))
-                    ((member c '(#\space #\tab) :test #'char=)
-                     (unless inter-word-space-p
-                       (setq inter-word-space-p t)
-                       (let ((lp (car paren-stack)))
-                         (when lp
-                           (incf (lparen-num-finished-subforms lp))))))
-                    ((member c '(#\( #\[) :test #'char=)
-                     (setq inter-word-space-p nil)
-                     (multiple-value-bind (left-indent num-aligned-subforms j)
-                         (calc-subindent paren-stack curr-line (1+ i) n)
-                       (push
-                        (make-lparen :word (current-word curr-line (1+ i) n)
-                                     :spaces-before (+ i curr-left-i left-indent)
-                                     :num-aligned-subforms num-aligned-subforms)
-                        paren-stack)
-                       (setq i j)))
-                    ((member c '(#\) #\]) :test #'char=)
-                     (setq inter-word-space-p nil)
-                     (cond (paren-stack (pop paren-stack))
-                           (t (setq left-i 0)))
-                     (let ((lp (car paren-stack)))
-                       (when lp
-                         (incf (lparen-num-processed-subforms lp)))))
-                    (t (setq inter-word-space-p nil)))
-              (incf i))))))))
-
-(indent-lines)
-
-;eof
--- a/bin/lispindent.lisp	Fri Apr 15 18:06:03 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-./lispindent
\ No newline at end of file
--- a/bin/lispindentclean	Fri Apr 15 18:06:03 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-#!/usr/bin/env bash
-
-LISP=sbcl lispindent | sed -e 's/ *$//'
--- a/lispwords	Fri Apr 15 18:06:03 2016 +0000
+++ b/lispwords	Wed Apr 20 10:38:25 2016 +0000
@@ -1,6 +1,11 @@
 ; unfuck normal shit
 (1 if)
 (-1 loop)
+(2 defmethod)
+(2 with-accessors)
+
+; my own weird things
+(1 make-array)
 
 ; fiveam
 (1 test)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/roswell/lispindent.ros	Wed Apr 20 10:38:25 2016 +0000
@@ -0,0 +1,253 @@
+#!/bin/sh
+#|-*- mode:lisp -*-|#
+#|
+exec ros -Q -- $0 "$@"
+|#
+
+#|
+
+Roswell version of my fork of lispindent
+https://github.com/ds26gte/scmindent
+
+Some day I need to rewrite this with smug or something, jesus.
+
+|#
+
+;Dorai Sitaram
+;Oct 8, 1999
+;last change 2014-09-16
+
+;this script takes lines of Lisp or Scheme code from its
+;stdin and produces an indented version thereof on its
+;stdout
+
+(defun safe-read (stream)
+  (let ((*read-eval* nil))
+    (read stream nil)))
+
+(defun safe-read-from-string (string)
+  (let ((*read-eval* nil))
+    (read-from-string string)))
+
+
+(defvar *lisp-keywords* '())
+(defvar *labels-keywords* '(labels flet macrolet))
+(defvar *lambda-list-keywords* '(defun defmethod))
+
+
+(defun define-with-lisp-indent-number (n syms)
+  (dolist (sym syms)
+    (let* ((x (symbol-name sym))
+           (c (assoc x *lisp-keywords* :test #'string-equal)))
+      (unless c
+        (push (setq c (cons x nil)) *lisp-keywords*))
+      (setf (cdr c) n))))
+
+(define-with-lisp-indent-number 0
+  '(block
+    handler-bind
+    loop))
+
+(define-with-lisp-indent-number 1
+  '(case
+    defpackage do-all-symbols do-external-symbols dolist do-symbols dotimes
+    ecase etypecase eval-when
+    flet
+    handler-case
+    labels lambda let let* let-values
+    macrolet
+    prog1
+    typecase
+    unless unwind-protect
+    when with-input-from-string with-open-file with-open-socket
+    with-open-stream with-output-to-string))
+
+(define-with-lisp-indent-number 2
+  '(assert
+    defun destructuring-bind do do*
+    if
+    multiple-value-bind
+    with-slots))
+
+
+(defparameter *config-files*
+  (list (merge-pathnames ".lispwords" (user-homedir-pathname))
+        ".lispwords" ))
+
+
+(defun source-config-files ()
+  (dolist (path *config-files*)
+    (with-open-file (i path :if-does-not-exist nil)
+      (when i
+        (loop
+          (let ((w (or (safe-read i) (return))))
+            (define-with-lisp-indent-number (car w) (cdr w))))))))
+
+
+(defstruct lparen
+  word
+  spaces-before
+  num-aligned-subforms
+  (num-finished-subforms 0)
+  (num-processed-subforms 0))
+
+
+(defun past-next-token (s i n)
+  (let ((escapep nil))
+    (loop
+      (when (>= i n) (return i))
+      (let ((c (char s i)))
+        (cond (escapep (setq escapep nil))
+              ((char= c #\\) (setq escapep t))
+              ((char= c #\#)
+               (let ((j (+ i 1)))
+                 (if (>= j n) (return i)
+                   (let ((c (char s j)))
+                     (cond ((char= c #\\) (setq escapep t i j))
+                           (t (return i)))))))
+              ((member c '(#\space #\tab #\( #\) #\[ #\] #\" #\' #\` #\, #\;))
+               (return i))))
+      (incf i))))
+
+(defun lisp-indent-number (s &optional (possible-keyword-p t))
+  (or (cdr (assoc s *lisp-keywords* :test #'string-equal))
+      (if (zerop (or (search "def" s :test #'char-equal) -1))
+          0
+        (if possible-keyword-p
+            (let ((p (position #\: s :from-end t)))
+              (if p
+                  (lisp-indent-number (subseq s (1+ p)) nil)
+                -1))
+          -1))))
+
+(defun literal-token-p (s)
+  (let ((colon-pos (position #\: s)))
+    (if colon-pos
+        (if (= colon-pos 0) t nil)
+      (let ((s (safe-read-from-string s)))
+        (or (eql t s) (characterp s) (numberp s) (stringp s))))))
+
+;(trace lisp-indent-number literal-token-p read-from-string past-next-token)
+
+(defun current-word (s i n)
+  (let ((j (past-next-token s i n)))
+    (when (not (= i j))
+      (subseq s i j))))
+
+
+(defun in-labels-p (stack)
+  (let ((target (cadr stack)))
+    (and target
+         (member (lparen-word target) *labels-keywords*
+                 :key #'symbol-name :test #'string-equal)
+         (= (lparen-num-processed-subforms target) 0))))
+
+(defun in-lambda-list-p (stack)
+  (let ((target (car stack)))
+    (and target
+         (member (lparen-word target) *lambda-list-keywords*
+                 :key #'symbol-name :test #'string-equal)
+         (= (lparen-num-processed-subforms target) 0))))
+
+
+(defun calc-subindent (stack s i n)
+  (let* ((j (past-next-token s i n))
+         (num-aligned-subforms 0)
+         (left-indent
+          (if (= j i) 1
+            (let ((w (subseq s i j)))
+              (if (and (>= i 2) (member (char s (- i 2)) '(#\' #\`))) 1
+                (let ((nas (if (in-labels-p stack)
+                             1
+                             (lisp-indent-number w))))
+                  (cond ((in-lambda-list-p stack) 1)
+                        ((>= nas 0) (setq num-aligned-subforms nas)
+                         2)
+                        ((literal-token-p w) 1)
+                        ((= j n) 2)
+                        (t (+ (- j i) 2)))))))))
+    (values left-indent num-aligned-subforms (1- j))))
+
+(defun num-leading-spaces (s)
+  (let ((n (length s))
+        (i 0) (j 0))
+    (loop
+      (when (>= i n) (return 0))
+      (case (char s i)
+        (#\space (incf i) (incf j))
+        (#\tab (incf i) (incf j 8))
+        (t (return j))))))
+
+
+(defun string-trim-blanks (s)
+  (string-trim '(#\space #\tab #\newline #\return) s))
+
+
+(defun indent-lines ()
+  (let ((left-i 0)
+        (paren-stack '())
+        (stringp nil))
+    (loop
+      (let* ((curr-line (or (read-line nil nil) (return)))
+             (leading-spaces (num-leading-spaces curr-line))
+             (curr-left-i
+               (cond (stringp leading-spaces)
+                     ((null paren-stack)
+                      (when (= left-i 0) (setq left-i leading-spaces))
+                      left-i)
+                     (t (let* ((lp (car paren-stack))
+                               (nas (lparen-num-aligned-subforms lp))
+                               (nfs (lparen-num-finished-subforms lp))
+                               (extra-w 0))
+                          (when (< nfs nas) ;(and (>= nas 0) (< nfs nas))
+                            (incf (lparen-num-finished-subforms lp))
+                            (setq extra-w 2))
+                          (+ (lparen-spaces-before lp)
+                             extra-w))))))
+        (setq curr-line (string-trim-blanks curr-line))
+        (when (not (string= curr-line "")) ; don't add "trailing" whitespace
+          (dotimes (k curr-left-i) (write-char #\space)))
+        (princ curr-line)
+        (terpri)
+        ;
+        (let ((i 0) (n (length curr-line)) (escapep nil)
+              (inter-word-space-p nil))
+          (loop
+            (when (>= i n) (return))
+            (let ((c (char curr-line i)))
+              (cond (escapep (setq escapep nil))
+                    ((char= c #\\) (setq escapep t))
+                    (stringp (when (char= c #\") (setq stringp nil)))
+                    ((char= c #\;) (return))
+                    ((char= c #\") (setq stringp t))
+                    ((member c '(#\space #\tab) :test #'char=)
+                     (unless inter-word-space-p
+                       (setq inter-word-space-p t)
+                       (let ((lp (car paren-stack)))
+                         (when lp
+                           (incf (lparen-num-finished-subforms lp))))))
+                    ((member c '(#\( #\[) :test #'char=)
+                     (setq inter-word-space-p nil)
+                     (multiple-value-bind (left-indent num-aligned-subforms j)
+                         (calc-subindent paren-stack curr-line (1+ i) n)
+                       (push
+                         (make-lparen :word (current-word curr-line (1+ i) n)
+                                      :spaces-before (+ i curr-left-i left-indent)
+                                      :num-aligned-subforms num-aligned-subforms)
+                         paren-stack)
+                       (setq i j)))
+                    ((member c '(#\) #\]) :test #'char=)
+                     (setq inter-word-space-p nil)
+                     (cond (paren-stack (pop paren-stack))
+                           (t (setq left-i 0)))
+                     (let ((lp (car paren-stack)))
+                       (when lp
+                         (incf (lparen-num-processed-subforms lp)))))
+                    (t (setq inter-word-space-p nil)))
+              (incf i))))))))
+
+
+(defun main (&rest argv)
+  (declare (ignore argv))
+  (source-config-files)
+  (indent-lines))
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/userContent.css	Wed Apr 20 10:38:25 2016 +0000
@@ -0,0 +1,21 @@
+body.sjl-unstyled {
+  width: 800px; margin: 50px auto 200px;
+  font-family: Georgia;
+  font-size: 16px;
+  line-height: 1.4;
+}
+body.sjl-unstyled pre,code {
+  font-family: menlo !important;
+  font-size: 14px;
+  line-height: 1.4;
+}
+body.sjl-unstyled code {
+  background: #eee;
+  padding: 1px 4px;
+}
+body.sjl-unstyled pre {
+  padding: 15px;
+  overflow-x: scroll;
+}
+body.sjl-unstyled h3 { text-decoration: none; }
+body.sjl-unstyled h4 { text-decoration: none; }
--- a/vim/after/plugin/paredit.vim	Fri Apr 15 18:06:03 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-augroup unmap_paredit_bullshit
-    au!
-
-    " Quit fucking with my split-line mapping, paredit.
-    au Filetype lisp,clojure,gdl,scheme nnoremap <buffer> S i<cr><esc>^mwgk:silent! s/\v +$//<cr>:noh<cr>`w
-
-    " Also quit fucking with my save file mapping.
-    au FileType lisp,clojure,gdl,scheme nunmap <buffer> s
-
-    " Oh my god will you fuck off already
-    au FileType lisp,clojure,gdl,scheme nnoremap <buffer> dp :diffput<cr>
-    au FileType lisp,clojure,gdl,scheme nnoremap <buffer> do :diffobtain<cr>
-augroup END
--- a/vim/bundle/ooze/plugin/ooze.vim	Fri Apr 15 18:06:03 2016 +0000
+++ b/vim/bundle/ooze/plugin/ooze.vim	Wed Apr 20 10:38:25 2016 +0000
@@ -127,6 +127,25 @@
     let @z = z
 endfunction " }}}
 
+function! OozeQuickload(system) " {{{
+    let msg = {"op": "eval", "code": "(ql:quickload :" . a:system . ")"}
+    call OozeSendMessage(msg)
+endfunction " }}}
+function! OozeQuickloadCurrent() " {{{
+    let systems = split(system('ls -1 *.asd | grep -v test'))
+    if len(systems) == 0
+        echom "Could not find any .asd files..."
+        return
+    elseif len(systems) > 1
+        echom "Found too many any .asd files..."
+        return
+    endif
+
+    let system = split(systems[0], '[.]')[0]
+
+    call OozeQuickload(system)
+endfunction " }}}
+
 function! OozeDocument(symbol) " {{{
     let msg = {"op": "documentation", "symbol": a:symbol}
     call OozeSendMessage(msg)
@@ -159,6 +178,12 @@
     let @z = z
 endfunction " }}}
 function! OozeArglistFormHead() " {{{
+    if synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") == "Comment"
+        " bail if we're in a comment
+        " TODO: make this suck less
+        return
+    endif
+
     let view = winsaveview()
     execute "normal v\<plug>(sexp_inner_list)o\<plug>(sexp_inner_element)"
     call OozeArglistSelection()
@@ -207,6 +232,9 @@
     nnoremap <buffer> <localleader>C :call OozeConnect()<cr>
     nnoremap <buffer> <localleader>K :call OozeDisconnect()<cr>
 
+    nnoremap <buffer> <localleader>q :call OozeQuickloadCurrent()<cr>
+    nnoremap <buffer> <localleader>Q :call OozeQuickload(input("? "))<cr>
+
     nnoremap <buffer> <localleader>h :call OozeHyperspecForm()<cr>
     nnoremap <buffer> <localleader>H :call OozeHyperspec(input("? "))<cr>
 
--- a/vim/ftplugin/lisp/lispfolding.vim	Fri Apr 15 18:06:03 2016 +0000
+++ b/vim/ftplugin/lisp/lispfolding.vim	Wed Apr 20 10:38:25 2016 +0000
@@ -119,51 +119,58 @@
 endfunction
 
 function! GetLispFold(lnum)
+    let save_cursor = getpos('.')
+    let save_search = @/
     let inline_fn_comment_re = '\v^ *;;( .*)?$'
 
-    if getline(a:lnum) =~ '^;;;; '
-        " Never fold top-level header comments
-        return "0"
-    elseif getline(a:lnum) =~ '^;;; '
-        " Subheader top level comments should get folded together in level 1
-        return "1"
-    elseif getline(a:lnum) =~ inline_fn_comment_re
-        " Inline function comments should increment the fold level
-        let prev = getline(a:lnum - 1) =~ inline_fn_comment_re
-        let next = getline(a:lnum + 1) =~ inline_fn_comment_re
+    try
+        if getline(a:lnum) =~ '^;;;; '
+            " Never fold top-level header comments
+            return "0"
+        elseif getline(a:lnum) =~ '^;;; '
+            " Subheader top level comments should get folded together in level 1
+            return "1"
+        elseif getline(a:lnum) =~ inline_fn_comment_re
+            " Inline function comments should increment the fold level
+            let prev = getline(a:lnum - 1) =~ inline_fn_comment_re
+            let next = getline(a:lnum + 1) =~ inline_fn_comment_re
 
-        if (!prev) && next
-            return "a1"
-        elseif prev && (!next)
-            return "s1"
+            if (!prev) && next
+                return "a1"
+            elseif prev && (!next)
+                return "s1"
+            else
+                return "="
+            endif
+        elseif getline(a:lnum) =~ '^; '
+            " don't include commentary-commented lines in deeper folds than necessary
+            return "-1"
+        elseif getline(a:lnum) =~ '^(test '
+            " (test ...) folds at the top level
+            return ">1"
+        elseif getline(a:lnum) =~ '^(def\S\+ '
+            " fuck it just fold everything that looks kinda deffy
+            return ">1"
+        elseif getline(a:lnum) =~ '^$' && getline(a:lnum - 1) =~ '^$'
+            return "0"
+        elseif getline(a:lnum) =~ '^$'
+            " Single blank lines fold along with the previous line, so that the
+            " blank line after a defun gets folded into the defun.
+            return "="
+        " elseif LispFoldingStartFlet(a:lnum) == 1
+        "     " if this is a function definition in a labels/flet/etc, we want to
+        "     " start a new deeper fold
+        "     return ">2"
+        " elseif LispFoldingEndFlet(a:lnum)
+        "     " if this is the END of a flet definition, we should pop a foldlevel
+        "     return "<2"
         else
             return "="
         endif
-    elseif getline(a:lnum) =~ '^; '
-        " don't include commentary-commented lines in deeper folds than necessary
-        return "-1"
-    elseif getline(a:lnum) =~ '^(test '
-        " (test ...) folds at the top level
-        return ">1"
-    elseif getline(a:lnum) =~ '^(def\S\+ '
-        " fuck it just fold everything that looks kinda deffy
-        return ">1"
-    elseif getline(a:lnum) =~ '^$' && getline(a:lnum - 1) =~ '^$'
-        return "0"
-    elseif getline(a:lnum) =~ '^$'
-        " Single blank lines fold along with the previous line, so that the
-        " blank line after a defun gets folded into the defun.
-        return "="
-    elseif LispFoldingStartFlet(a:lnum) == 1
-        " if this is a function definition in a labels/flet/etc, we want to
-        " start a new deeper fold
-        return ">2"
-    elseif LispFoldingEndFlet(a:lnum)
-        " if this is the END of a flet definition, we should pop a foldlevel
-        return "<2"
-    else
-        return "="
-    endif
+    finally
+        call setpos('.', save_cursor)
+        let @/ = save_search
+    endtry
 endfunction
 
 function! TurnOnLispFolding()
--- a/vim/vimrc	Fri Apr 15 18:06:03 2016 +0000
+++ b/vim/vimrc	Wed Apr 20 10:38:25 2016 +0000
@@ -298,6 +298,9 @@
 nnoremap <leader>( :tabprev<cr>
 nnoremap <leader>) :tabnext<cr>
 
+" My garbage brain can't ever remember digraph codes
+inoremap <c-k><c-k> <esc>:help digraph-table<cr>
+
 " Wrap
 nnoremap <leader>W :set wrap!<cr>
 
@@ -1012,16 +1015,20 @@
 augroup ft_commonlisp
     au!
 
-    au BufNewFile,BufRead *.asd set filetype=lisp
+    au BufNewFile,BufRead *.asd,*.ros set filetype=lisp
 
     au FileType lisp call SetLispWords()
 
     au FileType lisp RainbowParenthesesActivate
     au syntax lisp RainbowParenthesesLoadRound
 
+    au FileType lisp call EnableParedit()
     au FileType lisp silent! call TurnOnLispFolding()
-
     au FileType lisp setlocal iskeyword+=!,?,%
+    au FileType lisp setlocal equalprg=lispindent
+
+    " scratch buffer
+    au FileType lisp nnoremap <buffer> <leader><tab> :e scratch.lisp<cr>
 
     " Paredit mappings
     au FileType lisp noremap <buffer> () :<c-u>call PareditWrap("(", ")")<cr>
@@ -1032,12 +1039,8 @@
     au FileType lisp noremap <buffer> (s :<c-u>call PareditSplit()<cr>
     au FileType lisp noremap <buffer> )j :<c-u>call PareditJoin()<cr>
     au FileType lisp noremap <buffer> )s :<c-u>call PareditSplit()<cr>
-    au FileType lisp noremap <buffer> [[ :<c-u>call PareditSmartJumpOpening(0)<cr>
-    au FileType lisp noremap <buffer> ]] :<c-u>call PareditSmartJumpClosing(0)<cr>
     " ))
 
-    au FileType lisp setlocal equalprg=lispindentclean
-
     " s/it/happening/
     "
     " Map the Ooze keys, then add a few extra on top to work with the REPL.
@@ -2313,6 +2316,25 @@
 let g:paredit_smartjump = 1
 let g:paredit_shortmaps = 0
 let g:paredit_electric_return = 1
+let g:paredit_disable_lisp = 1
+
+function! EnableParedit()
+    call PareditInitBuffer()
+
+    " Quit fucking with my split-line mapping, paredit.
+    nunmap <buffer> S
+
+    " Also quit fucking with my save file mapping.
+    nunmap <buffer> s
+
+    " Oh my god will you fuck off already
+    " nnoremap <buffer> dp :diffput<cr>
+    " nnoremap <buffer> do :diffobtain<cr>
+
+    " Eat shit
+    nunmap <buffer> [[
+    nunmap <buffer> ]]
+endfunction
 
 " }}}
 " Python-Mode {{{
@@ -2390,22 +2412,28 @@
 " Sexp {{{
 
 function! s:vim_sexp_mappings() " {{{
-    xmap <silent><buffer> af              <Plug>(sexp_outer_list)
-    omap <silent><buffer> af              <Plug>(sexp_outer_list)
-    xmap <silent><buffer> if              <Plug>(sexp_inner_list)
-    omap <silent><buffer> if              <Plug>(sexp_inner_list)
-    xmap <silent><buffer> aF              <Plug>(sexp_outer_top_list)
-    omap <silent><buffer> aF              <Plug>(sexp_outer_top_list)
-    xmap <silent><buffer> iF              <Plug>(sexp_inner_top_list)
-    omap <silent><buffer> iF              <Plug>(sexp_inner_top_list)
-    xmap <silent><buffer> as              <Plug>(sexp_outer_string)
-    omap <silent><buffer> as              <Plug>(sexp_outer_string)
-    xmap <silent><buffer> is              <Plug>(sexp_inner_string)
-    omap <silent><buffer> is              <Plug>(sexp_inner_string)
-    xmap <silent><buffer> ae              <Plug>(sexp_outer_element)
-    omap <silent><buffer> ae              <Plug>(sexp_outer_element)
-    xmap <silent><buffer> ie              <Plug>(sexp_inner_element)
-    omap <silent><buffer> ie              <Plug>(sexp_inner_element)
+    xmap <silent><buffer>   af   <Plug>(sexp_outer_list)
+    omap <silent><buffer>   af   <Plug>(sexp_outer_list)
+    xmap <silent><buffer>   if   <Plug>(sexp_inner_list)
+    omap <silent><buffer>   if   <Plug>(sexp_inner_list)
+    xmap <silent><buffer>   aF   <Plug>(sexp_outer_top_list)
+    omap <silent><buffer>   aF   <Plug>(sexp_outer_top_list)
+    xmap <silent><buffer>   iF   <Plug>(sexp_inner_top_list)
+    omap <silent><buffer>   iF   <Plug>(sexp_inner_top_list)
+    xmap <silent><buffer>   as   <Plug>(sexp_outer_string)
+    omap <silent><buffer>   as   <Plug>(sexp_outer_string)
+    xmap <silent><buffer>   is   <Plug>(sexp_inner_string)
+    omap <silent><buffer>   is   <Plug>(sexp_inner_string)
+    xmap <silent><buffer>   ae   <Plug>(sexp_outer_element)
+    omap <silent><buffer>   ae   <Plug>(sexp_outer_element)
+    xmap <silent><buffer>   ie   <Plug>(sexp_inner_element)
+    omap <silent><buffer>   ie   <Plug>(sexp_inner_element)
+
+    nmap <silent><buffer>   [[   <Plug>(sexp_swap_element_backward)
+    xmap <silent><buffer>   [[   <Plug>(sexp_swap_element_backward)
+    nmap <silent><buffer>   ]]   <Plug>(sexp_swap_element_forward)
+    xmap <silent><buffer>   ]]   <Plug>(sexp_swap_element_forward)
+
     " nmap <silent><buffer> (               <Plug>(sexp_move_to_prev_bracket)
     " xmap <silent><buffer> (               <Plug>(sexp_move_to_prev_bracket)
     " omap <silent><buffer> (               <Plug>(sexp_move_to_prev_bracket)
@@ -2473,10 +2501,6 @@
     " xmap <silent><buffer> <M-k>           <Plug>(sexp_swap_list_backward)
     " nmap <silent><buffer> <M-j>           <Plug>(sexp_swap_list_forward)
     " xmap <silent><buffer> <M-j>           <Plug>(sexp_swap_list_forward)
-    " nmap <silent><buffer> <M-h>           <Plug>(sexp_swap_element_backward)
-    " xmap <silent><buffer> <M-h>           <Plug>(sexp_swap_element_backward)
-    " nmap <silent><buffer> <M-l>           <Plug>(sexp_swap_element_forward)
-    " xmap <silent><buffer> <M-l>           <Plug>(sexp_swap_element_forward)
     " nmap <silent><buffer> <M-S-j>         <Plug>(sexp_emit_head_element)
     " xmap <silent><buffer> <M-S-j>         <Plug>(sexp_emit_head_element)
     " nmap <silent><buffer> <M-S-k>         <Plug>(sexp_emit_tail_element)