emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Tassilo Horn <tassilo@member.fsf.org>
To: emacs-orgmode@gnu.org
Subject: Re: [OT] Icon problem with org-google-weather
Date: Mon, 06 Jun 2011 09:38:32 +0200	[thread overview]
Message-ID: <871uz7v287.fsf@member.fsf.org> (raw)
In-Reply-To: 24071.1307320041@alphaville.dokosmarshall.org

Nick Dokos <nicholas.dokos@hp.com> 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

  reply	other threads:[~2011-06-06  7:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-06  0:27 [OT] Icon problem with org-google-weather Nick Dokos
2011-06-06  7:38 ` Tassilo Horn [this message]
2011-06-06 13:51   ` Nick Dokos
2011-06-06 15:27     ` Tassilo Horn
2011-06-06 15:40       ` Nick Dokos
2011-06-06 16:35         ` Nick Dokos
2011-06-07  4:53 ` Nick Dokos

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871uz7v287.fsf@member.fsf.org \
    --to=tassilo@member.fsf.org \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).