View sexp.go
// Compiler from Go types to an S-Expression representation. | |
// | |
// The output a drop-in replacement for the Elisp JSON parser output, and can be | |
// consumed directly with `read`. | |
package main | |
import ( | |
"strconv" | |
"strings" |
View Learn Emacs in 7 days.el
(url-copy-file "http://ulrichdesign.ca/wp-content/uploads/2011/11/YOU-LACK-discipline.jpg" | |
"~/discipline.jpg") | |
(defun you-lack-discipline () | |
(interactive) | |
(insert-image (create-image "~/discipline.jpg"))) | |
(dolist (k '([up] [left] [down] [right])) | |
(global-set-key k 'you-lack-discipline)) |
View cal-usage.el
; Infix algebra in Lisp because yolo | |
(cal | |
sin(2) * ([1,2,3] + [4,5,6]) | |
) | |
; => [0.174497483513, 0.244296476918, 0.314095470323] |
View cal.el
(defmacro cal (&rest expression) | |
"Evaluate algebraic EXPRESSION using calc." | |
(let* | |
((expr (with-temp-buffer | |
(lisp-mode) | |
(insert (->> expression | |
(-map 'pp-to-string) | |
(apply 'concat) | |
(s-replace (rx space) ""))) | |
;; Unpack unquote forms applied by the lisp reader. |
View c_obj_usage.c
#include <stdio.h> | |
#include "array_obj.h" | |
int main() | |
{ | |
// Allocate an array of 5 ints. | |
Array_new(xs, int, 5); | |
// Initialize elements using their indices. | |
xs.each_i(^(int x, int i) { xs.set(i, i); }); | |
// Print elements. |
View array_obj.h
#include <assert.h> | |
#include <stdlib.h> | |
#define Array_new(name, type, len) \ | |
typedef void(^name##_each)(type); \ | |
typedef void(^name##_each_i)(type, int); \ | |
\ | |
struct { \ | |
type *data; \ | |
size_t length; \ |
View ruby-hideshow.el
(eval-after-load "hideshow" | |
'(add-to-list 'hs-special-modes-alist | |
`(ruby-mode | |
,(rx (or "def" "class" "module" "{" "[")) ; Block start | |
,(rx (or "}" "]" "end")) ; Block end | |
,(rx (or "#" "=begin")) ; Comment start | |
ruby-forward-sexp nil))) |
View emr-binding.el
;;; Let-bind variable | |
(emr-declare-action emr-extract-to-let emacs-lisp-mode "let-bind" | |
:predicate (not (or (emr--looking-at-definition?) | |
(emr--looking-at-decl?) | |
(emr--looking-at-let-binding-symbol?))) | |
:description "let") |
View init.el
;; Initialize packages. | |
(require 'package) | |
(dolist (source '(("melpa" . "http://melpa.milkbox.net/packages/") | |
("marmalade" . "http://marmalade-repo.org/packages/"))) | |
(add-to-list 'package-archives source)) | |
(package-initialize) | |
(unless package-archive-contents |