From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tassilo Horn Subject: Re: [OT] Icon problem with org-google-weather Date: Mon, 06 Jun 2011 09:38:32 +0200 Message-ID: <871uz7v287.fsf@member.fsf.org> References: <24071.1307320041@alphaville.dokosmarshall.org> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([140.186.70.92]:56704) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QTUOg-0002RQ-60 for emacs-orgmode@gnu.org; Mon, 06 Jun 2011 03:38:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QTUOd-0000Kv-9q for emacs-orgmode@gnu.org; Mon, 06 Jun 2011 03:38:49 -0400 Received: from lo.gmane.org ([80.91.229.12]:57713) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QTUOc-0000KY-GH for emacs-orgmode@gnu.org; Mon, 06 Jun 2011 03:38:46 -0400 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1QTUOb-0007NT-6o for emacs-orgmode@gnu.org; Mon, 06 Jun 2011 09:38:45 +0200 Received: from tsdh.uni-koblenz.de ([141.26.67.142]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 06 Jun 2011 09:38:45 +0200 Received: from tassilo by tsdh.uni-koblenz.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 06 Jun 2011 09:38:45 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Nick Dokos writes: > This is off-topic but it is driving me bananas. I do > > (setq date '(6 5 2011)) > (6 5 2011) > (setq foo (let ((org-google-weather-cache-time 0)) > (org-google-weather))) > (setq bar (org-google-weather)) > (equal foo bar) > (insert foo) > (insert bar) > > in the *scratch* buffer. The idea is that foo is freshly obtained from > google every time: it never goes to cached data since the cache time > is set to 0. bar, otoh, is obtained from cache. I've traced the code > and that's indeed what happens. The two strings compare equal: (equal > foo bar) returns t - just in case, I also displayed them in separate > windows and did a compare-windows: they are the same that way too. > > Nevertheless, when I insert foo, the icon is shown, but when I insert > bar, the icon is an empty box. What am I missing? I have a similar problem. In one of my org files, I have %%(org-google-weather "Montabaur" "de") and since lately, I get only squares. That said, while trying your example, `org-google-weather' always returned nil. The reason is that I don't have `org-google-weather-location' set explicitly to something different as the default value. But that default is a form and it is never evaluated AFAICS. So that seems to be another bug. Ok, so when I change your testcase to this... --8<---------------cut here---------------start------------->8--- (defun foobar () (interactive) (let ((date '(6 6 2011))) (setq bar (org-google-weather "Montabaur" "DE")) (setq foo (let ((org-google-weather-cache-time 0)) (org-google-weather "Montabaur" "DE"))) (string= foo bar) (insert foo) (insert bar))) --8<---------------cut here---------------end--------------->8--- I get an error at the foo value evaluation. The evaluation of bar seems to work fine... --8<---------------cut here---------------start------------->8--- Debugger entered--Lisp error: (error "Data not found") signal(error ("Data not found")) error("Data not found") (if (search-forward "\n\n" nil t) nil (error "Data not found")) (unless (search-forward "\n\n" nil t) (error "Data not found")) (save-current-buffer (set-buffer (google-weather-retrieve-data-raw url org-google-weather-cache-time)) (unless (search-forward "\n\n" nil t) (error "Data not found")) (let ((data (buffer-substring (point) (point-max)))) (kill-buffer (current-buffer)) data)) (with-current-buffer (google-weather-retrieve-data-raw url org-google-weather-cache-time) (unless (search-forward "\n\n" nil t) (error "Data not found")) (let ((data (buffer-substring (point) (point-max)))) (kill-buffer (current-buffer)) data)) org-google-weather-get-icon("http://g0.gstatic.com/images/icons/onebox/weather_scatteredthunderstorms-40.gif") (create-image (org-google-weather-get-icon (cadr (assoc (quote icon) forecast))) nil t) (progn (create-image (org-google-weather-get-icon (cadr (assoc (quote icon) forecast))) nil t)) (if (display-images-p) (progn (create-image (org-google-weather-get-icon (cadr (assoc (quote icon) forecast))) nil t))) (when (display-images-p) (create-image (org-google-weather-get-icon (cadr (assoc (quote icon) forecast))) nil t)) (let ((condition (cadr (assoc (quote condition) forecast))) (low (cadr (assoc (quote low) forecast))) (high (cadr (assoc (quote high) forecast))) (city (google-weather-data->city data)) (icon (when (display-images-p) (create-image (org-google-weather-get-icon (cadr (assoc ... forecast))) nil t))) (temp-symbol (google-weather-data->temperature-symbol data))) (format-spec org-google-weather-format (\` ((105 \, (if (and icon org-google-weather-display-icon-p) (propertize "icon" (quote display) (append icon ...) (quote rear-nonsticky) (quote ...)) "")) (99 \, condition) (76 \, location) (67 \, city) (108 \, low) (104 \, high) (115 \, temp-symbol))))) (progn (let ((condition (cadr (assoc (quote condition) forecast))) (low (cadr (assoc (quote low) forecast))) (high (cadr (assoc (quote high) forecast))) (city (google-weather-data->city data)) (icon (when (display-images-p) (create-image (org-google-weather-get-icon (cadr ...)) nil t))) (temp-symbol (google-weather-data->temperature-symbol data))) (format-spec org-google-weather-format (\` ((105 \, (if (and icon org-google-weather-display-icon-p) (propertize "icon" ... ... ... ...) "")) (99 \, condition) (76 \, location) (67 \, city) (108 \, low) (104 \, high) (115 \, temp-symbol)))))) (if forecast (progn (let ((condition (cadr (assoc (quote condition) forecast))) (low (cadr (assoc (quote low) forecast))) (high (cadr (assoc (quote high) forecast))) (city (google-weather-data->city data)) (icon (when (display-images-p) (create-image (org-google-weather-get-icon ...) nil t))) (temp-symbol (google-weather-data->temperature-symbol data))) (format-spec org-google-weather-format (\` ((105 \, (if ... ... "")) (99 \, condition) (76 \, location) (67 \, city) (108 \, low) (104 \, high) (115 \, temp-symbol))))))) (when forecast (let ((condition (cadr (assoc (quote condition) forecast))) (low (cadr (assoc (quote low) forecast))) (high (cadr (assoc (quote high) forecast))) (city (google-weather-data->city data)) (icon (when (display-images-p) (create-image (org-google-weather-get-icon (cadr ...)) nil t))) (temp-symbol (google-weather-data->temperature-symbol data))) (format-spec org-google-weather-format (\` ((105 \, (if (and icon org-google-weather-display-icon-p) (propertize "icon" ... ... ... ...) "")) (99 \, condition) (76 \, location) (67 \, city) (108 \, low) (104 \, high) (115 \, temp-symbol)))))) (if problem-cause (message "%s: %s" location problem-cause) (when forecast (let ((condition (cadr (assoc (quote condition) forecast))) (low (cadr (assoc (quote low) forecast))) (high (cadr (assoc (quote high) forecast))) (city (google-weather-data->city data)) (icon (when (display-images-p) (create-image (org-google-weather-get-icon ...) nil t))) (temp-symbol (google-weather-data->temperature-symbol data))) (format-spec org-google-weather-format (\` ((105 \, (if ... ... "")) (99 \, condition) (76 \, location) (67 \, city) (108 \, low) (104 \, high) (115 \, temp-symbol))))))) (let* ((location (or location org-google-weather-location)) (data (ignore-errors (google-weather-get-data location language org-google-weather-cache-time))) (problem-cause (when data (google-weather-data->problem-cause data))) (forecast (when (and (null problem-cause) data) (google-weather-data->forecast-for-date data date)))) (if problem-cause (message "%s: %s" location problem-cause) (when forecast (let ((condition (cadr (assoc ... forecast))) (low (cadr (assoc ... forecast))) (high (cadr (assoc ... forecast))) (city (google-weather-data->city data)) (icon (when (display-images-p) (create-image ... nil t))) (temp-symbol (google-weather-data->temperature-symbol data))) (format-spec org-google-weather-format (\` ((105 \, ...) (99 \, condition) (76 \, location) (67 \, city) (108 \, low) ( 104 \, high) (115 \, temp-symbol)))))))) org-google-weather("Montabaur" "DE") (let ((org-google-weather-cache-time 0)) (org-google-weather "Montabaur" "DE")) (setq foo (let ((org-google-weather-cache-time 0)) (org-google-weather "Montabaur" "DE"))) (let ((date (quote (6 6 2011)))) (setq foo (let ((org-google-weather-cache-time 0)) (org-google-weather "Montabaur" "DE"))) (setq bar (org-google-weather "Montabaur" "DE")) (string= foo bar) (insert foo) (insert bar)) eval((let ((date (quote (6 6 2011)))) (setq foo (let ((org-google-weather-cache-time 0)) (org-google-weather "Montabaur" "DE"))) (setq bar (org-google-weather "Montabaur" "DE")) (string= foo bar) (insert foo) (insert bar)) nil) eval-last-sexp-1(nil) eval-last-sexp(nil) call-interactively(eval-last-sexp nil nil) --8<---------------cut here---------------end--------------->8--- Bye, Tassilo