Skip to content

Instantly share code, notes, and snippets.

(defn in-context
"rebind a var, expecations are run in the defined context"
{:expectations-options :in-context}
[work]
(with-redefs [some-src/a-fn-to-be-rebound (constantly :a-rebound-val)]
(work)))
(defun char-at-point ()
(interactive)
(buffer-substring-no-properties (point) (+ 1 (point))))
(defun clj-string-name (s)
(substring s 1 -1))
(defun clj-keyword-name (s)
(substring s 1))
;;;; created by David Chelimsky
(ns leiningen.hooks.expand-resource-paths
(:use [clojure.java.io :only [as-file]])
(:import [java.io File])
(:require [robert.hooke]
[leiningen.javac]
[org.satta.glob :as glob]))
;;; justification: http://en.wikipedia.org/wiki/%E2%88%98
(eval-after-load 'clojure-mode
'(font-lock-add-keywords
'clojure-mode `(("(\\(comp\\)[[:space:]]"
(0 (progn (compose-region (match-beginning 1)
(match-end 1) "∘")
nil))))))
(doseq [[printer {:keys [id sub-ids]}] {(partial println "sub1") {:id :A :sub-ids [11 12 13 14]}
(partial println "sub2") {:id :B :sub-ids [21 22 23 24]}}]
(let [id-str (name id)]
(doseq [sub-id sub-ids]
(printer id-str sub-id))))
;;; -output-
;;; sub1 A 11
;;; sub1 A 12
;;; sub1 A 13
(doseq [[printer {:keys [id sub-ids]}] {(partial println "sub1") {:id :A :sub-ids [11 12 13 14]}
(partial println "sub2") {:id :B :sub-ids [21 22 23 24]}}
sub-id sub-ids]
(let [id-str (name id)]
(printer id-str sub-id)))
(doseq [[printer {:keys [id sub-ids]}] {(partial println "sub1") {:id :A :sub-ids [11 12 13 14]}
(partial println "sub2") {:id :B :sub-ids [21 22 23 24]}}
:let [id-str (do (println id) (name id))]
sub-id sub-ids]
(printer id-str sub-id))
;;; :A
;;; sub1 A 11
;;; sub1 A 12
;;; sub1 A 13
(doseq [[printer {:keys [id sub-ids]}] {(partial println "sub1") {:id :A :sub-ids [11 12 13 14]}
(partial println "sub2") {:id :B :sub-ids []}}
sub-id sub-ids
:let [sub-id-times-2 (do (println "binding occured") (* sub-id 2))]]
(printer id sub-id))
;;; binding occured
;;; sub1 :A 11
;;; binding occured
;;; sub1 :A 12
@jaycfields
jaycfields / e.el
Last active December 18, 2015 00:59
;; clojure.core
;; 141 false greek: ⊥ - http://en.wikipedia.org/wiki/Tautology_(logic)
;; 163 -> key-chord: kl
;; 217 true greek: ⊤ - http://en.wikipedia.org/wiki/Tautology_(logic)
;; 255 nil greek: ∅ - http://en.wikipedia.org/wiki/Null_(mathematics)
;; 316 :keys key-chord: kk, greek: ӄ
;; testing
;; 224 interaction greek: ι
;; 265 no-op greek: ⒩
(define-clojure-indent
(expect 'defun)
(expect-let 'defun)
(given 'defun)
(context 1)
(freeze-time 1)
(redef-state 1)
(from-each 1))