From: "Peter Münster" <pmlists@free.fr>
To: help-gnu-emacs@gnu.org
Subject: Re: kill buffer created by url-retrieve-synchronously
Date: Sat, 27 Feb 2016 18:55:44 +0100 [thread overview]
Message-ID: <87lh66f36n.fsf@roche-blanche.net> (raw)
In-Reply-To: 87lh66ls7n.fsf@gnus.org
On Sat, Feb 27 2016, Lars Magne Ingebrigtsen wrote:
> Slap an `unwind-protect' around the main part of your function, and have
> the `kill-buffer' in the unwind forms.
Thanks. But it still does not work. Just an idea: Is it possible, that
the with-timeout form kills the url-retrieve-synchronously function
because of the timeout, but the buffer has already been created?
Here my new function:
--8<---------------cut here---------------start------------->8---
(defun pm/get-json (url)
"Copied from
http://frozenlock.org/2012/07/07/url-retrieve-and-json-api/."
(let (my-json-buffer)
(unwind-protect
(let ((url-mime-encoding-string "identity"))
(setq my-json-buffer (with-timeout (3 nil)
(url-retrieve-synchronously url)))
(with-current-buffer my-json-buffer
(goto-char (point-min))
(re-search-forward "^$")
(json-read)))
(if my-json-buffer
(kill-buffer my-json-buffer)))))
--8<---------------cut here---------------end--------------->8---
--
Peter
next prev parent reply other threads:[~2016-02-27 17:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.5945.1456485979.843.help-gnu-emacs@gnu.org>
2016-02-27 3:58 ` kill buffer created by url-retrieve-synchronously Lars Magne Ingebrigtsen
2016-02-27 17:55 ` Peter Münster [this message]
[not found] ` <mailman.6062.1456595760.843.help-gnu-emacs@gnu.org>
2016-02-28 3:52 ` Lars Magne Ingebrigtsen
2016-02-26 11:25 Peter Münster
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87lh66f36n.fsf@roche-blanche.net \
--to=pmlists@free.fr \
--cc=help-gnu-emacs@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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.