From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?utf-8?Q?Peter_M=C3=BCnster?= Newsgroups: gmane.emacs.help Subject: Re: kill buffer created by url-retrieve-synchronously Date: Sat, 27 Feb 2016 18:55:44 +0100 Message-ID: <87lh66f36n.fsf@roche-blanche.net> References: <87lh66ls7n.fsf@gnus.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1456595778 4616 80.91.229.3 (27 Feb 2016 17:56:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 27 Feb 2016 17:56:18 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Feb 27 18:56:09 2016 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aZj69-0003hg-Fg for geh-help-gnu-emacs@m.gmane.org; Sat, 27 Feb 2016 18:56:09 +0100 Original-Received: from localhost ([::1]:55742 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aZj68-0006tX-Uq for geh-help-gnu-emacs@m.gmane.org; Sat, 27 Feb 2016 12:56:08 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47284) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aZj5x-0006t5-RC for help-gnu-emacs@gnu.org; Sat, 27 Feb 2016 12:55:58 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aZj5u-0008AT-LG for help-gnu-emacs@gnu.org; Sat, 27 Feb 2016 12:55:57 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:51600) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aZj5u-0008AN-Ec for help-gnu-emacs@gnu.org; Sat, 27 Feb 2016 12:55:54 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1aZj5s-0003bD-Q2 for help-gnu-emacs@gnu.org; Sat, 27 Feb 2016 18:55:52 +0100 Original-Received: from arennes-651-1-330-45.w2-14.abo.wanadoo.fr ([2.14.65.45]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 27 Feb 2016 18:55:52 +0100 Original-Received: from pmlists by arennes-651-1-330-45.w2-14.abo.wanadoo.fr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 27 Feb 2016 18:55:52 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 30 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: arennes-651-1-330-45.w2-14.abo.wanadoo.fr User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) Cancel-Lock: sha1:JrwFjYsEWr3GO8eY/e6MVgTusWE= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:109340 Archived-At: 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