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
;;; -*- Mode: Clojure -*- | |
;; This is clojurejs code which is translated to javascript and runs in the browser | |
(defn login-submit! [] | |
(.text ($ ".error") "") | |
(.text ($ "#login-message") "submitting ...")) | |
(defn dialog-close [] (.dialog ($ this) :close)) |
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
(defun tail-f (file) | |
"Create a COMINT mode buffer running the `tail -f` command on | |
specified FILE. If FILE is a ssh/scp style remote file spec, | |
e.g., | |
[email protected]:/path/to/file.txt | |
then a ssh connection is opened to remote.host.com, and `tail -f` | |
is invoked on the remote server." | |
(interactive "fFile: ") |
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
(defvar daily-agenda-timer (parse-relative-time "9:00 am")) | |
;; (decode-time daily-agenda-timer) | |
(defun show-daily-agenda () | |
(unless (time-less-p (current-time) daily-agenda-timer) | |
(setq daily-agenda-timer (time-add daily-agenda-timer | |
(seconds-to-time 86400))) | |
(org-agenda-list))) | |
(add-hook 'display-time-hook 'show-daily-agenda) |
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
(defun parse-relative-time (time-str) | |
(destructuring-bind (sec min hour day month year dow dst zone) | |
(parse-time-string time-str) | |
(destructuring-bind (sec1 min1 hour1 day1 month1 year1 dow1 dst1 zone1) | |
(decode-time) | |
(encode-time (or sec sec1) | |
(or min min1) | |
(or hour hour1) | |
(or day day1) | |
(or month month1) |
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
(destructuring-bind (x y) | |
point | |
(destructuring-bind (x1 y1 w h) | |
frame | |
(let ((x2 (+ x1 w)) | |
(y2 (+ y1 h))) | |
(and (>= x x1) (<= x x2) (>= y y1) (<= y y2))))) |
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
(bind (((x y) point) | |
((x1 y1 w h) frame) | |
(x2 (+ x1 w)) | |
(y2 (+ y1 h))) | |
(and (>= x x1) (<= x x2) (>= y y1) (<= y y2))) |
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
(defmacro bind (clauses &body body) | |
"This macro combines the behaviour of the forms `let*', `destructuring-bind', | |
and `multiple-value-bind', permitting the following style of binding form: | |
(bind (((:values m n) (values 10 20)) | |
((a b &key (c 10)) '(1 2)) | |
(x 5)) | |
(+ x a b c m n)) | |
=> 48 |
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
(defmacro -> (x &rest args) | |
"A Common-Lisp implementation of the Clojure `thrush` operator." | |
(destructuring-bind (form &rest more) | |
args | |
(cond | |
(more `(-> (-> ,x ,form) ,@more)) | |
((and (consp form) | |
(or (eq (car form) 'lambda) | |
(eq (car form) 'function))) | |
`(funcall ,form ,x)) |
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
(in-ns 'user) | |
;; An alternate `defmacro2` definition based on the example from | |
;; "Macros are Hard" presentation by @david_mcneil. This | |
;; implementation defines a macro called `name` and a function | |
;; equivalent called `name+` which still evaluates at compile time as | |
;; opposed to execution time | |
(defmacro defmacro2 [name args & body] | |
`(do | |
(defmacro ~name ~args ~@body) |
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
(in-ns 'user) | |
;; An alternate `defmacro2` definition based on the example from | |
;; "Macros are Hard" presentation by @david_mcneil. This | |
;; implementation defines a macro called `name` and a function | |
;; equivalent called `name+` which still evaluates at compile time as | |
;; opposed to execution time | |
(defmacro defmacro2 [name args & body] | |
`(do | |
(defmacro ~name ~args ~@body) |
OlderNewer