emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: Kaushal Modi <kaushal.modi@gmail.com>
Cc: emacs-org list <emacs-orgmode@gnu.org>
Subject: Re: Allow #+SETUPFILE to point to an URL for the org file
Date: Tue, 13 Jun 2017 14:43:10 +0200	[thread overview]
Message-ID: <877f0grrc1.fsf@nicolasgoaziou.fr> (raw)
In-Reply-To: <CAFyQvY3BhJbYXR7GkGAYZgaqbxKyRaTLdg_BN9RC7GeT0NCENA@mail.gmail.com> (Kaushal Modi's message of "Mon, 12 Jun 2017 19:32:28 +0000")

Hello,

Kaushal Modi <kaushal.modi@gmail.com> 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

  reply	other threads:[~2017-06-13 12:43 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-03 17:23 Allow #+SETUPFILE to point to an URL for the org file Kaushal Modi
2016-12-08 11:51 ` Kaushal Modi
2016-12-08 14:22   ` John Kitchin
2016-12-08 14:31   ` Nicolas Goaziou
2016-12-08 14:44     ` Kaushal Modi
2016-12-08 21:48       ` Nicolas Goaziou
2016-12-08 22:07         ` Kaushal Modi
2016-12-08 22:40           ` Nicolas Goaziou
2017-03-13 17:37             ` Kaushal Modi
2017-03-30  7:43               ` Nicolas Goaziou
2017-05-23 19:07                 ` Kaushal Modi
2017-05-25 10:13                   ` Nicolas Goaziou
2017-05-25 10:18                     ` Nicolas Goaziou
2017-05-25 11:43                     ` Kaushal Modi
2017-05-25 15:15                       ` Kaushal Modi
2017-05-26  7:47                         ` Nicolas Goaziou
2017-05-26 20:24                           ` Kaushal Modi
2017-05-28  7:35                             ` Nicolas Goaziou
2017-05-28 10:04                               ` Kaushal Modi
2017-06-09 16:59                               ` Kaushal Modi
2017-06-12 19:32                                 ` Kaushal Modi
2017-06-13 12:43                                   ` Nicolas Goaziou [this message]
2017-06-13 15:45                                     ` Kaushal Modi
2017-06-13 21:32                                       ` Nicolas Goaziou
2017-06-13 21:42                                         ` Kaushal Modi

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=877f0grrc1.fsf@nicolasgoaziou.fr \
    --to=mail@nicolasgoaziou.fr \
    --cc=emacs-orgmode@gnu.org \
    --cc=kaushal.modi@gmail.com \
    /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).