Skip to content

Instantly share code, notes, and snippets.

### Keybase proof
I hereby claim:
* I am 0branch on github.
* I am marcs (https://keybase.io/marcs) on keybase.
* I have a public key whose fingerprint is 0839 E1C9 FF90 1E41 FB1A 0EF7 7F47 6083 7774 14BC
To claim this, I am signing this object:
@0branch
0branch / interpolate-guarded.el
Created January 20, 2012 11:47
interpolate test
(defun interpolate- (interpolate-str interpolate-pl interpolate-f)
(if (string-match interpolate-capture interpolate-str 0)
(let* ((interpolate-key (match-string 1 interpolate-str))
(interpolate-new-str (replace-match "%" t nil interpolate-str))
(interpolate-new-key (funcall interpolate-f interpolate-key)))
(interpolate- interpolate-new-str
(cons interpolate-new-key interpolate-pl) interpolate-f))
(cons interpolate-str (reverse interpolate-pl))))
(defun interpolate (interpolate-str)
@0branch
0branch / interpolate.el
Created December 6, 2011 23:19
Emacs: string interpolation
(defvar interpolate-capture "%{\\([^}]+\\)}")
(defun interpolate-wrap-key (str sym)
(get sym (intern (concat ":" str))))
(defun interpolate- (str pl f)
(if (string-match interpolate-capture str 0)
(let* ((key (match-string 1 str))
(new-str (replace-match "%" t nil str))
(new-key (funcall f key)))
@0branch
0branch / format-bound-example.el
Created September 25, 2011 11:01
Format example with interpolate
(let ((cheers 3) (interpolation "String Interpolation"))
(format "Let's have %d cheers for %s!"
cheers interpolation))
@0branch
0branch / format-interpolate-bound-eg.el
Created September 25, 2011 10:49
Format example with interpolate
(let ((cheers 3) (interpolation "String Interpolation"))
(interpolate
"Let's have %{cheers}d cheers for %{interpolation}s!"))
@0branch
0branch / interpolate-bound.el
Created September 25, 2011 10:48
Emacs: string interpolation of bound variables
(defvar interpolate-capture "%{\\([^}]+\\)}")
(defun interpolate- (str pl)
(if (string-match interpolate-capture str 0)
(let* ((key (match-string 1 str))
(new-str (replace-match "%" t nil str))
(new-key (eval (intern key))))
(interpolate- new-str (cons new-key pl)))
(cons str (reverse pl))))
@0branch
0branch / format-interpolate-plist-eg.el
Created September 24, 2011 16:37
Format example with interpolate
(setplist 'x '())
(put 'x :interpolation "String Interpolation")
(put 'x :cheers 3)
(interpolate-plist
"Let's have %{cheers}d cheers for %{interpolation}s!" 'x)
@0branch
0branch / format-plist-example.el
Created September 24, 2011 16:34
Format examples
(setplist 'x '())
(put 'x :interpolation "String Interpolation")
(put 'x :cheers 3)
(format "Let's have %d cheers for %s!"
(get 'x :cheers) (get 'x :interpolation))
@0branch
0branch / interpolate-plist.el
Created September 24, 2011 16:29
Emacs: string interpolation with property lists
(defvar interpolate-capture "%{\\([^}]+\\)}")
(defun interpolate-wrap-key (str sym)
(get sym (intern (concat ":" str))))
(defun interpolate- (str pl sym)
(if (string-match interpolate-capture str 0)
(let* ((key (match-string 1 str))
(new-str (replace-match "%" t nil str))
(new-key (interpolate-wrap-key key sym)))
@0branch
0branch / mt.patch
Created August 27, 2011 16:10
new metatable syntax for Lua: VM patch
diff --git a/src/Makefile b/src/Makefile
index e4a3cd6..9a29e1e 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -8,7 +8,7 @@
PLAT= none
CC= gcc
-CFLAGS= -O2 -Wall $(MYCFLAGS)
+CFLAGS= -O2 -Wall $(MYCFLAGS) -DMT_PATCH