This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(setq ss/erc-shorten-links-limit 50) | |
(defun ss/erc-shorten-links () | |
(goto-char (point-min)) | |
(while (re-search-forward url-regexp nil t) | |
(let ((start (match-beginning 0)) | |
(end (match-end 0))) | |
(when (> (- end start) ss/erc-shorten-links-limit) | |
(let* ((url (buffer-substring start end)) | |
(replacement (concat (substring url 0 ss/erc-shorten-links-limit) "..."))) | |
(message "replacing with URL: %s" replacement) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns bsq.arch | |
(:require [dali.io :as dio] | |
[dali.layout :as l] | |
[dali.layout.utils :refer [place-by-anchor bounds->anchor-point]] | |
dali.layout.stack | |
dali.layout.distribute | |
dali.layout.align | |
dali.layout.connect | |
dali | |
[dali.syntax :as d] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;code for "How to use Clojure macros to refactor Clojure code in Emacs" video | |
;; https://www.youtube.com/watch?v=Szu0wNttfek | |
;;function that macroexpands the previous Clojure sexp and | |
;;replaces the expression in the buffer with the macroexpanded version | |
(defun macroexpand-replace () | |
(interactive) | |
(let ((exp | |
(cider-sync-request:macroexpand |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;add this: | |
(ns yada.core | |
... | |
[positano.trace :as tr :refer (deftrace)]) | |
;;instrument all interceptors (there is functionality to do this in a | |
;;less invasive way with trace-var*, but it may require changing | |
;;default-interceptor-chain to contain vars (#'available? etc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;This says: I'm looking for a :text "tag" whose direct parent is a :p | |
;;the ^= ensures that the rule matches at the level of the :text not at the level of the :p | |
[:p ^= [:text & =content]] | |
;;I'm looking for a :text in the among the children of :p that has | |
;;a subsequent :text2 sibling whose content I'd like to also | |
;;capture | |
[:p | |
^* _ | |
^= [:text & =content] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;this is a theoretical re-implementation of https://github.com/stathissideris/dali/blob/master/src/cljx/dali/syntax.clj#L78 | |
;;to explore the different ways to implement the bonjai syntax | |
(def v vector) | |
;;right part is provided with the captured vars "anaphorically". | |
;;I think = is a good alternative to ?, looks a bit cleaner | |
;;and it conveys the meaning of capturing | |
(def dali->hiccup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn zipify [value pattern] | |
(loop [[value-zipper pattern-zipper :as both-zippers] (map #(z/zipper coll? seq {} [%]) [value pattern]) | |
result (transient {})] | |
(let [[value-node pattern-node :as both-nodes] (map z/node both-zippers)] | |
(condp apply [z/end? both-zippers] | |
every? (when (seq both-zippers) (persistent! result)) ;;both zippers exhausted at the same time, result! | |
some nil ;;reached the end of one of the zippers when the other one still had stuff left | |
(recur | |
(cond |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(unify-let [[?a _ & ?more] [1 5 6 7]] [a more]) | |
;=> [1 (6 7)] | |
(unify-let [[{:a 6}] []] :yes :no) | |
;=> :no | |
(unify-let [{?key 8} {:a 8}] key) | |
;=> :a | |
;;*SADTROMBONE* http://soundbible.com/1830-Sad-Trombone.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn generic-zip | |
"Works on maps and vectors. Any other seq is treated as a vector." | |
[root] | |
(zip/zipper | |
(some-fn map? vector?) | |
seq | |
(fn [node children] | |
(-> | |
(cond | |
(instance? clojure.lang.MapEntry node) [(first children) (second children)] |