From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: Allow #+SETUPFILE to point to an URL for the org file Date: Tue, 13 Jun 2017 14:43:10 +0200 Message-ID: <877f0grrc1.fsf@nicolasgoaziou.fr> References: <87h96eh4qb.fsf@nicolasgoaziou.fr> <871sxigkhk.fsf@nicolasgoaziou.fr> <87twaef3iq.fsf@nicolasgoaziou.fr> <874lybp5ua.fsf@nicolasgoaziou.fr> <87shjtb5wd.fsf@nicolasgoaziou.fr> <87o9ug83fb.fsf@nicolasgoaziou.fr> <87o9ud77s2.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38072) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dKlAB-0001TM-38 for emacs-orgmode@gnu.org; Tue, 13 Jun 2017 08:43:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dKlA9-00071Y-Sr for emacs-orgmode@gnu.org; Tue, 13 Jun 2017 08:43:15 -0400 Received: from relay4-d.mail.gandi.net ([2001:4b98:c:538::196]:38057) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dKlA9-0006zr-MP for emacs-orgmode@gnu.org; Tue, 13 Jun 2017 08:43:13 -0400 In-Reply-To: (Kaushal Modi's message of "Mon, 12 Jun 2017 19:32:28 +0000") 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" To: Kaushal Modi Cc: emacs-org list Hello, Kaushal Modi writes: > I have attached the same patch with one more test; rebased to master. Great. Thank you. > * lisp/org.el (org--file-cache): New internal variable to store > downloaded files' cache. > > * lisp/org.el (org-reset-file-cache): New function to clear the above > file cache. > > * lisp/org.el (org-mode-restart): Use org-reset-file-cache to clear > the file cache. > > * lisp/org.el (org-file-url-p): New function to test if the input > argument is a URL. It should be something like * lisp/org.el (org--file-cache): New variable (org-reset-file-cache): (org-file-url-p): New function. (org-mode-restart): Use new function. The purpose is to know in what commit the function was introduced, not what it does. > +Org opens the main file. If URL is specified, the contents are downloaded > +and stored in a temporary cache. @kbd{C-c C-c} on the settings line will > +also parse and load. @kbd{C-c C-c} on the @code{#+SETUPFILE:} line will also > +reset the temporary file cache. The last sentence is not correct. C-c C-c on any settings line resets the cache, not specifically on "#+SETUPFILE". > +(ert-deftest test-org/org-file-contents-url () > + "Test `org-file-contents' with a URL as input." > + (should > + (string= "#+BIND: variable value > +#+DESCRIPTION: l2 > +#+LANGUAGE: en > +#+SELECT_TAGS: b > +#+TITLE: b > +#+PROPERTY: a 1 > +" (org-file-contents "http://orgmode.org/cgit.cgi/org-mode.git/plain/testing/examples/setupfile3.org"))) I'm worried about this test, and some other below. They require a proper internet access. Couldn't we fake `url-retrieve-synchronously' using `cl-letf' so as to produce a buffer with appropriate contents and return it? Something (untested) like (should (string= "foo" (let ((buffer (generate-new-buffer "test-ox"))) (unwind-protect (cl-letf (((symbol-function 'url-retrieve-synchronously) (lambda (&rest _) (with-current-buffer buffer (insert "HTTP 200 OK\n\nfoo")) buffer))) (org-file-contents "http://whatever")) (kill-buffer buffer))))) Regards, -- Nicolas Goaziou