(require 'google-weather)
(require 'image)
(require 'format-spec)
+(require 'solar)
(defgroup org-google-weather nil
"Google Weather for Org mode."
:group 'comm)
-(defcustom org-google-weather-location "Paris"
+(defcustom org-google-weather-location calendar-location-name
"Default location for org-google-weather."
:group 'org-google-weather)
-(defcustom org-google-weather-format "%i %c, %l-%h %s"
+(defcustom org-google-weather-format "%i %c, [%l,%h] %s"
"String to return to describe the weather.
Valid %-sequences are:
- %i the icon
(mostly_sunny . "weather-clear.png")
(partly_cloudy . "weather-few-clouds.png")
(rain . "weather-showers.png")
+ (rain_snow . "weather-snow.png")
(sleet . "weather-snow.png")
(smoke . "weather-fog.png")
(snow . "weather-snow.png")
(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."
- (let* ((data (google-weather-get-data (or location
- org-google-weather-location)
- language
- org-google-weather-cache-time))
- (forecast (google-weather-data->forecast-for-date data date)))
+ (let* ((data (ignore-errors
+ (google-weather-get-data (or location
+ org-google-weather-location)
+ language
+ org-google-weather-cache-time)))
+ (forecast (when data (google-weather-data->forecast-for-date data date))))
(when forecast
(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 (when (window-system)
+ (icon (when window-system
(cdr
(assoc
(intern
`((?i . ,(if (and icon org-google-weather-display-icon-p)
(propertize "icon"
'display
- (create-image
- (concat
- org-google-weather-icon-directory
- "/"
- icon))
+ (append
+ (create-image
+ (concat
+ org-google-weather-icon-directory
+ "/"
+ icon)) '(:ascent center))
'rear-nonsticky '(display))
""))
(?c . ,condition)