;;; davep-wx.el - Display current weather at davep.org. ;; Copyright 2006-2008 by Dave Pearson ;; $Revision: 1.2 $ ;; davep-wx.el is free software distributed under the terms of the GNU ;; General Public Licence, version 2. For details see the file COPYING. ;;; Code: ;; Things we need: (require 'xml) (require 'cl) ;; Customize options. (defvar dpwx-current-host "wxw.davep.org" "*Host that holds the current weather data.") (defvar dpwx-current-location "/xml/" "*Location of the current weather data.") ;; Main code. (defun dpwx-get-current () "Downlods the current weather from `dpwx-current'." (with-output-to-string (let ((s (open-network-stream (format "dpwx-%s" dpwx-current-host) nil dpwx-current-host "http"))) (when s (unwind-protect (progn (set-process-filter s (lambda (o p) (princ (delete 13 p)))) (process-send-string s (format "GET /%s HTTP/1.1\r\nHost: %s\r\nConnection: close\r\n\r\n" dpwx-current-location dpwx-current-host)) (while (eq (process-status s) 'open) (sit-for 0.01))) (delete-process s)))))) (defun dpwx-read-current () "Read the current weather readings for davep.org." (with-temp-buffer (insert (dpwx-get-current)) (setf (point) (point-min)) (when (search-forward "