1d6b60fde7f1

more
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Tue, 23 Aug 2016 22:48:19 +0000
parents 122228d53e7a
children 30edc2f560bf
branches/tags (none)
files bin/code-to-pdf bin/lec bin/lecdown fish/functions/dump.fish lispwords roswell/lispindent.ros vim/bundle/ooze/plugin/ooze.vim vim/ftplugin/lisp/lispfolding.vim vim/vimrc

Changes

--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/code-to-pdf	Tue Aug 23 22:48:19 2016 +0000
@@ -0,0 +1,22 @@
+#!/usr/bin/env bash
+
+TITLE="$1"
+shift
+
+enscript -1 --media=A4 \
+    --toc \
+    --header '%H - $N | | page $% of $= in file $v' \
+    --font "Menlo-Regular@8.5" \
+    --header-font "Menlo-Bold@10" \
+    --margins=60:60:18:60 \
+    --fancy-header=sjl \
+    --title $TITLE \
+    --baselineskip 3 \
+    --line-numbers \
+    --highlight \
+    --color \
+    --mark-wrapped-lines=arrow \
+    -p - \
+    --word-wrap $* \
+    | pstopdf -i -o code.pdf
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/lec	Tue Aug 23 22:48:19 2016 +0000
@@ -0,0 +1,4 @@
+#!/usr/bin/env bash
+
+echo $* | peat "ldown $* > index.html"
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/lecdown	Tue Aug 23 22:48:19 2016 +0000
@@ -0,0 +1,68 @@
+#!/usr/bin/env bash
+
+set -e
+
+echo "<!DOCTYPE html><html><head>"
+
+cat <<EOF
+<meta charset="utf-8" />
+<style media="screen" type="text/css">
+
+body {
+    margin: 50px auto 300px;
+    width: 600px;
+    font: 24px/1.4 "Palatino Linotype";
+    color: #222;
+}
+
+h1, h2, h3, h4, h5, h6 {
+    font-family: "Gill Sans";
+}
+
+code {
+    font: 20px Menlo;
+}
+
+p code {
+    border: 1px solid #ccc;
+    background: #fdfdfd;
+    padding: 1px 5px;
+}
+
+pre {
+    border: 1px solid #ddd;
+    background: #fdfdfd;
+    padding: 10px 10px;
+}
+
+a, a:visited {
+    color: #6A1D18;
+    text-decoration: none;
+}
+
+</style>
+EOF
+
+
+cat <<EOF
+    <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+EOF
+
+cat <<EOF
+<script>
+MathJax.Hub.Config({
+  tex2jax: {
+    inlineMath: [[',,',',,'], ['\\\\(','\\\\)']],
+    processEscapes: true
+  }
+});
+
+</script>
+EOF
+
+echo "</head><body>"
+
+pandoc --from markdown --to html $*
+
+echo "</body></html>"
+
--- a/fish/functions/dump.fish	Sat Aug 20 21:21:56 2016 +0000
+++ b/fish/functions/dump.fish	Tue Aug 23 22:48:19 2016 +0000
@@ -4,8 +4,8 @@
 
     hg -R ~/src/cl-nrepl push
 
-    hg -R ~/src/bones push
-    hg -R ~/src/bones push git
+    hg -R ~/src/temperance push
+    hg -R ~/src/temperance push git
 
     hg -R ~/src/mazes push
     hg -R ~/src/mazes push git
--- a/lispwords	Sat Aug 20 21:21:56 2016 +0000
+++ b/lispwords	Tue Aug 23 22:48:19 2016 +0000
@@ -17,6 +17,7 @@
 (1 dis)
 (1 do-array)
 (1 recursively)
+(2 when-found)
 
 ; fiveam
 (1 test)
@@ -53,3 +54,5 @@
 (1 with-curses)
 
 
+; dissect
+(1 with-capped-stack with-truncated-stack)
--- a/roswell/lispindent.ros	Sat Aug 20 21:21:56 2016 +0000
+++ b/roswell/lispindent.ros	Tue Aug 23 22:48:19 2016 +0000
@@ -113,13 +113,15 @@
 
 (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 (zerop (or (search "def" s :test #'char-equal)
+                     (search "with-" 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))
+          (let ((p (position #\: s :from-end t)))
+            (if p
+              (lisp-indent-number (subseq s (1+ p)) nil)
+              -1))
           -1))))
 
 (defun literal-token-p (s)
--- a/vim/bundle/ooze/plugin/ooze.vim	Sat Aug 20 21:21:56 2016 +0000
+++ b/vim/bundle/ooze/plugin/ooze.vim	Tue Aug 23 22:48:19 2016 +0000
@@ -24,8 +24,11 @@
 endfunction " }}}
 
 let g:ooze_scratch_buffer_name = '__OozeScratch__'
+let g:ooze_traceback_buffer_name = '__OozeTraceback__'
+
 function! s:OpenOozeScratch(contents) " {{{
     if bufname('%') != g:ooze_scratch_buffer_name
+        " TODO: go to the window if it's already showing...
         wincmd s
         execute "edit " . g:ooze_scratch_buffer_name
     endif
@@ -38,16 +41,67 @@
     setlocal buflisted
 
     setlocal noreadonly
-    normal! ggdG
+    normal! gg"_dG
     call append(0, a:contents)
     setlocal readonly
 endfunction " }}}
+function! s:DumpTraceback(frames) " {{{
+    let current = bufnr('%')
+    let bn = bufnr(g:ooze_traceback_buffer_name)
+
+    if bn == -1
+        execute "edit " . g:ooze_traceback_buffer_name
+        setlocal buftype=nofile
+        setlocal bufhidden=hide
+        setlocal noswapfile
+        setlocal buflisted
+    else
+        execute "buffer " . bn
+    endif
+
+    normal! gg"_dG
+
+    for frame in a:frames
+        let call_form = frame[0]
+        let file = frame[1]
+        let line = frame[2]
+
+        call append(line('$'), call_form . "\t" . file . "\t" . line)
+    endfor
+    normal! gg"_dd
+    set errorformat=%m\	%f\	%l,%m\	%f\	
+    execute "cbuffer"
+
+    execute "buffer " . current
+
+    return 1
+endfunction " }}}
+
+function! s:HandleMacroexpand(msg) " {{{
+    let moutput = s:GetString(a:msg, 'macroexpand-1', "")
+    call s:OpenOozeScratch(split(moutput, "\n"))
+endfunction " }}}
+function! s:HandleStackTrace(msg) " {{{
+    call s:DumpTraceback(get(a:msg, 'stack-trace'))
+
+    let output = ''
+
+    let output .= s:GetString(a:msg, 'error', "\n\n")
+    let output .= s:GetString(a:msg, 'original', "\n\n")
+
+    if output != ''
+        echo substitute(output, '\n\+$', '', '')
+    endif
+
+    copen
+endfunction " }}}
 
 function! s:HandleMessage(msg) " {{{
-    let moutput = s:GetString(a:msg, 'macroexpand-1', "")
-    if moutput != ''
-        call s:OpenOozeScratch(split(moutput, "\n"))
-        return
+    if has_key(a:msg, 'macroexpand-1')
+        return s:HandleMacroexpand(a:msg)
+    endif
+    if has_key(a:msg, 'stack-trace')
+        return s:HandleStackTrace(a:msg)
     endif
 
     let output = ''
@@ -55,10 +109,6 @@
     let output .= s:GetString(a:msg, 'stderr', "")
     let output .= s:GetString(a:msg, 'value', "")
 
-    let output .= s:GetString(a:msg, 'error', "\n\n")
-    let output .= s:GetString(a:msg, 'original', "\n\n")
-    let output .= s:GetString(a:msg, 'backtrace', "\n")
-
     let output .= s:GetString(a:msg, 'function-arglist', "\n\n")
     let output .= s:GetString(a:msg, 'function-docstring', "\n")
     if output != ''
@@ -210,8 +260,10 @@
 function! OozeArglistFormHead() " {{{
     let view = winsaveview()
 
-    if synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") == "Comment"
-        " bail if we're in a comment
+    let syntaxElement = synIDattr(synIDtrans(synID(line("."),col("."),1)),"name")
+
+    if syntaxElement == "Comment" || syntaxElement == "String"
+        " bail if we're in a comment or string
         " TODO: make this suck less
     else
         execute "normal v\<plug>(sexp_inner_list)o\<plug>(sexp_inner_element)"
--- a/vim/ftplugin/lisp/lispfolding.vim	Sat Aug 20 21:21:56 2016 +0000
+++ b/vim/ftplugin/lisp/lispfolding.vim	Tue Aug 23 22:48:19 2016 +0000
@@ -164,6 +164,9 @@
         elseif getline(a:lnum) =~ '^(let '
             " let over lambda
             return ">1"
+        elseif getline(a:lnum) =~ '^(adt:defdata'
+            " let over lambda
+            return ">1"
         elseif getline(a:lnum) =~ '^$' && getline(a:lnum - 1) =~ '^$'
             return "0"
         elseif getline(a:lnum) =~ '^$'
--- a/vim/vimrc	Sat Aug 20 21:21:56 2016 +0000
+++ b/vim/vimrc	Tue Aug 23 22:48:19 2016 +0000
@@ -2156,6 +2156,7 @@
 let NERDTreeIgnore = ['\~$', '.*\.pyc$', 'pip-log\.txt$', 'whoosh_index',
                     \ 'xapian_index', '.*.pid', 'monitor.py', '.*-fixtures-.*.json',
                     \ '.*\.o$', 'db.db', 'tags.bak', '.*\.pdf$', '.*\.mid$',
+                    \ '^tags$',
                     \ '.*\.midi$']
 
 let NERDTreeMinimalUI = 1
@@ -2171,6 +2172,7 @@
 let g:paredit_shortmaps = 0
 let g:paredit_electric_return = 1
 let g:paredit_disable_lisp = 1
+let g:paredit_matchlines = 200
 
 function! EnableParedit()
     call PareditInitBuffer()