After I first saw libnotify with ircII, I thought “I can do that in Emacs!” This past weekend, I finally got around to doing it. (Note that for this demonstration, I send myself a stupid message from… ircII.) Here’s the magical bits:
(defvar mah/erc-nick-notify-last '(0 0 0)) (defvar mah/erc-nick-ntify-delay '(0 5 0)) (defvar mah/erc-nick-notify-cmd "notify-send") (defvar mah/erc-nick-notify-icon "/usr/share/icons/default.kde/48x48/apps/edu_languages.png") (defvar mah/erc-nick-notify-timeout 10000) (defvar mah/erc-nick-notify-urgency "low"); (defvar mah/erc-nick-notify-category "im.received"); (defun mah/erc-nick-notify () "Notify me when my nick shows up. This function should be in the insert-post-hook." (let ((now (current-time))) (when (time-less-p mah/erc-nick-notify-delay (time-since mah/erc-nick-notify-last)) (setq mah/erc-nick-notify-last now) (goto-char (point-min)) (when (re-search-forward (concat "^\\(" "\\(<\\([^>]*\\)\>\\)" ; <someone> "\\|" ;; Don't match if we're saying something "\\(\\* " (regexp-quote (erc-current-nick)) "\\)" "\\)" "\\(.*" (regexp-quote (erc-current-nick)) ".*\\)") nil t) (let ((msg (concat (when (> (length (match-string-no-properties 2)) 0) (concat "<b><" (match-string-no-properties 3) "></b> ")) (match-string-no-properties 5)))) (shell-command (concat mah/erc-nick-notify-cmd " -i " mah/erc-nick-notify-icon " -t " (int-to-string mah/erc-nick-notify-timeout) " -u " mah/erc-nick-notify-urgency " -c " mah/erc-nick-notify-category " -- " "'" (buffer-name) "'" " '" msg "'")))))))
Working for a startup is heads-down work most of the time. I’m in the city often enough, but I stay in just a few places. I’m more familiar with what the subway stops look like than anything above ground. Still, when you’re working on an event search engine, sometimes it is good to get busy at night doing something besides work. It is times like these when we eat our own dogfood. This time, that worked out really well. Steve Wozniak is traveling around promoting his new book iWoz. We found out he would be speaking in the city thanks to the magic of our crawler. Being an office of geeks (and mostly Apple users, at that), we decided this would be one of those rare times we stepped out of the office together. I was hesitant at first. I tend to be a homebody. Stick me in front of a computer and I’ll happily ignore the rest of the world for hours or days, but once I got over my initial inertia and got out the door, I had a fantastic time. I had never read or heard about Woz’s early life, but he talked about how he taught himself to build computers starting in grade school. To me, this was simply amazing. He was able to learn so much because his father (an engineer) would bring home magazines about computers (in the 60s, when such things weren’t common) but ended up teaching himself all this without his father’s knowlege. I look at my own kids and wonder how much creative energy and time is drained away by video games and TV. (Hopefully not too much since I can’t bear to let them do those things for too long, and keeps them off the computer.) I see how much “education” is about spoon feeding kids predigested chunks of information. And then I go listen to someone like the Woz, and it gives me hope. I know my kids are curious, so I hope they’ll find something to explore and love, like he did. I can only imagine the surprise and pride Steve Wozniak’s father must have felt when he found, when the Woz was in college, that he had taught himself to design these systems. I can only hope that my own children delight me in the same way ten years from now.