From 9cd7ce58757bdc1db466c89976bdac75884800d4 Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Mon, 12 Jun 2017 14:50:32 +0100 Subject: Allow wttrin to be called with a city as an argument This means it can be easily called from other code, with the city passed as an argument. --- wttrin.el | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/wttrin.el b/wttrin.el index c92ff1d..72c024c 100644 --- a/wttrin.el +++ b/wttrin.el @@ -66,10 +66,10 @@ (setq buffer-read-only t))))) ;;;###autoload -(defun wttrin () - "Display weather information." - (interactive) - (wttrin-query (completing-read "City name: " wttrin-default-cities nil nil))) +(defun wttrin (city) + "Display weather information for CITY." + (interactive (list (completing-read "City name: " wttrin-default-cities nil nil))) + (wttrin-query city)) (provide 'wttrin) -- cgit v1.2.3 From 3f5de24334a7edcaa7f67738be26540b42441621 Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Mon, 12 Jun 2017 14:54:06 +0100 Subject: Default the city name if only one city is defined. If wttrin-default-cities only has the one city in it, default the input to wttrin to that so that it's easier and faster to get the weather. --- wttrin.el | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/wttrin.el b/wttrin.el index 72c024c..512b6a7 100644 --- a/wttrin.el +++ b/wttrin.el @@ -68,7 +68,11 @@ ;;;###autoload (defun wttrin (city) "Display weather information for CITY." - (interactive (list (completing-read "City name: " wttrin-default-cities nil nil))) + (interactive + (list + (completing-read "City name: " wttrin-default-cities nil nil + (when (= (length wttrin-default-cities) 1) + (car wttrin-default-cities))))) (wttrin-query city)) (provide 'wttrin) -- cgit v1.2.3