From: Don Armstrong Date: Fri, 10 Sep 2010 08:45:43 +0000 (+0000) Subject: update org-google-weather X-Git-Url: https://git.donarmstrong.com/?p=lib.git;a=commitdiff_plain;h=e4ce22ce37d9f75d092d1be3dc721de34ea403c3 update org-google-weather --- diff --git a/emacs_el/org-google-weather.el b/emacs_el/org-google-weather.el index 9961601..e86ec2e 100644 --- a/emacs_el/org-google-weather.el +++ b/emacs_el/org-google-weather.el @@ -36,17 +36,27 @@ (require 'google-weather) (require 'image) +(require 'format-spec) (defgroup org-google-weather nil "Google Weather for Org mode." :group 'comm) -;; Org mode support -(defcustom org-google-weather-location - "Paris" +(defcustom org-google-weather-location "Paris" "Default location for org-google-weather." :group 'org-google-weather) +(defcustom org-google-weather-format "%i %c, %l-%h %s" + "String to return to describe the weather. +Valid %-sequences are: + - %i the icon + - %c means the weather condition + - %L the supplied location + - %C the city the weather is for + - %l the lower temperature + - %h the higher temperature + - %s the temperature unit symbol") + (defcustom org-google-weather-cache-time 43200 "Define for how many seconds we should cache the weather." :group 'org-google-weather) @@ -62,7 +72,8 @@ (defcustom org-google-weather-icon-alist '((chance_of_rain . "weather-showers-scattered.png") (chance_of_snow . "weather-snow.png") - (chance_of_storm "weather-storm.png") + (chance_of_storm . "weather-storm.png") + (cn_heavyrun . "weather-showers.png") (cloudy . "weather-overcast.png") (dust . "weather-fog.png") (flurries . "weather-storm.png") @@ -82,6 +93,7 @@ (sunny . "weather-clear.png")) "Icons to used to illustrate the weather.") +;;;###autoload (defun org-google-weather (&optional location language) "Return Org entry with the weather for LOCATION in LANGUAGE. If LOCATION is not set, use org-google-weather-location." @@ -94,6 +106,7 @@ If LOCATION is not set, use org-google-weather-location." (let ((condition (cadr (assoc 'condition forecast))) (low (cadr (assoc 'low forecast))) (high (cadr (assoc 'high forecast))) + (city (google-weather-data->city data)) ;; But *they* told me it's just about calling functions! (icon (cdr (assoc @@ -103,15 +116,23 @@ If LOCATION is not set, use org-google-weather-location." (cadr (assoc 'icon forecast))))) org-google-weather-icon-alist))) (temp-symbol (google-weather-data->temperature-symbol data))) - (concat - (if org-google-weather-display-icon-p - (concat (propertize "icon" - 'display - (create-image - (concat org-google-weather-icon-directory "/" icon)) - 'rear-nonsticky '(display)) - " ") - "") - condition ", " low "-" high " " temp-symbol))))) + (format-spec org-google-weather-format + `((?i . ,(if org-google-weather-display-icon-p + (concat (propertize "icon" + 'display + (create-image + (concat + org-google-weather-icon-directory + "/" + icon)) + 'rear-nonsticky '(display)) + " ") + "")) + (?c . ,condition) + (?L . ,location) + (?C . ,city) + (?l . ,low) + (?h . ,high) + (?s . ,temp-symbol))))))) (provide 'org-google-weather)