Created
May 21, 2010 10:48
-
-
Save michalmarczyk/408702 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 -> (e &rest es) | |
(if (and (consp es) (not (consp (cdr es)))) | |
(if (consp (car es)) | |
`(,(caar es) ,e ,@(cdar es)) | |
`(,(car es) ,e)) | |
(if (consp es) | |
`(-> (-> ,e ,(car es)) ,@(cdr es)) | |
e))) | |
(defmacro ->> (e &rest es) | |
(if (and (consp es) (not (consp (cdr es)))) | |
(if (consp (car es)) | |
`(,@(car es) ,e) | |
`(,(car es) ,e)) | |
(if (consp es) | |
`(->> (->> ,e ,(car es)) ,@(cdr es)) | |
e))) | |
;;; stolen from Lau Jensen, rewritten using ->> | |
;;; http://www.bestinclass.dk/index.clj/2010/03/approaching-productivity.html | |
(defun my-erc-clean-message (s) | |
(->> s | |
(replace-regexp-in-string "'" "'") | |
(replace-regexp-in-string "\"" """) | |
(replace-regexp-in-string "&" "&") | |
(replace-regexp-in-string "<" "<") | |
(replace-regexp-in-string ">" ">"))) | |
(defun my-erc-match-call-libnotify (matched-type nick msg) | |
(let* ((cmsg (split-string (my-erc-clean-message msg))) | |
(nick (first (split-string nick "!"))) | |
(msg (mapconcat #'identity (rest cmsg) " "))) | |
(shell-command-to-string | |
(format "notify-send -u critical '%s says:' '%s'" nick msg)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment