Skip to content

Instantly share code, notes, and snippets.

Marc Simpson 0branch

Block or report user

Report or block 0branch

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:b4686a397bb18750eb37
### 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:
View interpolate-guarded.el
(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 Dec 6, 2011
Emacs: string interpolation
View interpolate.el
(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 Sep 25, 2011
Format example with interpolate
View format-bound-example.el
(let ((cheers 3) (interpolation "String Interpolation"))
(format "Let's have %d cheers for %s!"
cheers interpolation))
@0branch
0branch / format-interpolate-bound-eg.el
Created Sep 25, 2011
Format example with interpolate
View format-interpolate-bound-eg.el
(let ((cheers 3) (interpolation "String Interpolation"))
(interpolate
"Let's have %{cheers}d cheers for %{interpolation}s!"))
@0branch
0branch / interpolate-bound.el
Created Sep 25, 2011
Emacs: string interpolation of bound variables
View interpolate-bound.el
(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 Sep 24, 2011
Format example with interpolate
View format-interpolate-plist-eg.el
(setplist 'x '())
(put 'x :interpolation "String Interpolation")
(put 'x :cheers 3)
(interpolate-plist
"Let's have %{cheers}d cheers for %{interpolation}s!" 'x)
View format-plist-example.el
(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 Sep 24, 2011
Emacs: string interpolation with property lists
View interpolate-plist.el
(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 Aug 27, 2011
new metatable syntax for Lua: VM patch
View mt.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
You can’t perform that action at this time.