From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kaushal Modi Subject: Re: Allow #+SETUPFILE to point to an URL for the org file Date: Sun, 28 May 2017 10:04:37 +0000 Message-ID: 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: multipart/alternative; boundary="f403045fb6d66a520b055092b306" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:33834) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dEv48-0000V4-Jr for emacs-orgmode@gnu.org; Sun, 28 May 2017 06:04:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dEv47-0006Sl-7D for emacs-orgmode@gnu.org; Sun, 28 May 2017 06:04:52 -0400 Received: from mail-lf0-x22b.google.com ([2a00:1450:4010:c07::22b]:35330) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dEv46-0006S8-Ro for emacs-orgmode@gnu.org; Sun, 28 May 2017 06:04:51 -0400 Received: by mail-lf0-x22b.google.com with SMTP id a5so22655381lfh.2 for ; Sun, 28 May 2017 03:04:50 -0700 (PDT) In-Reply-To: <87o9ud77s2.fsf@nicolasgoaziou.fr> 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: Nicolas Goaziou Cc: emacs-org list --f403045fb6d66a520b055092b306 Content-Type: text/plain; charset="UTF-8" On Sun, May 28, 2017, 3:36 AM Nicolas Goaziou wrote: > Hello, > > Kaushal Modi writes: > > > I have attached a patch, rebased to master and with all suggestions > > implemented. > > Thank you. > > > There are some additional changes in the patch this time: > > - Prevent org-edit-special from attempting to open the "file" for editing > > if the value is a URL. > > This is a good idea. We could even display a read-only buffer with the > contents of the document, using new `org-file-contents'. > > Anyway, this can be done in a different patch. > > > I liked your C-c C-c idea below! :) > > Great! > > > +indirectly through a file included using @samp{#+SETUPFILE: > filename/URL} > > filename/URL > file name or URL > > > +@item #+SETUPFILE: file/URL > > file/URL > file name or URL > > > +The setup file or a URL pointing to such file is for additional > in-buffer > > +settings. Org loads this file and parses it for any settings in it > only when > > +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. Org also parses and loads the file/URL > > file/URL > document > > > +during normal exporting process. Org parses the contents of this > > file/URL as > > file/URL document > > > +if it was included in the buffer. It can be another Org file. To > visit the > > +file (not a URL), @kbd{C-c '} while the cursor is on the line with the > file > > name. > > @item #+STARTUP: > > @cindex #+STARTUP > > @@ -17395,7 +17398,9 @@ If any highlights shown in the buffer from the > creation of a sparse tree, or > > from clock display, remove such highlights. > > @item > > If the cursor is in one of the special @code{#+KEYWORD} lines, scan the > > -buffer for these lines and update the information. > > +buffer for these lines and update the information. Also reset the org > file > > org > Org > > > +(defvar ffap-url-regexp) ;Silence byte-compiler > > I think this can go at the beginning of the "org.el". > > > + ;; Reset the cache of files downloaded by `org-file-contents'. > > + (clrhash org--file-cache)) > > Note that we can still implement a non-interactive > `org-reset-setupfile-cache' function and call it here instead. (clrhash > org--file-cache) may be a bit low level at this point. > > Otherwise, LGTM. Would you want to throw in some tests? You can use > cl-letf to bind `url-retrieve-synchronously' to a function returning > a buffer containing some dumb (valid or invalid) output. > Thanks. I'll get back to this in 8 days; I'm going offline (vacation). > -- Kaushal Modi --f403045fb6d66a520b055092b306 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Sun, May 28, 2017, 3:36 AM N= icolas Goaziou <mail@nicolasgo= aziou.fr> wrote:
Hello,

Kaushal Modi <kaushal.modi@gmail.com> writes:

> I have attached a patch, rebased to master and with all suggestions > implemented.

Thank you.

> There are some additional changes in the patch this time:
> - Prevent org-edit-special from attempting to open the "file"= ; for editing
> if the value is a URL.

This is a good idea. We could even display a read-only buffer with the
contents of the document, using new `org-file-contents'.

Anyway, this can be done in a different patch.

> I liked your C-c C-c idea below! :)

Great!

> +indirectly through a file included using @samp{#+SETUPFILE: filename/= URL}

filename/URL > file name or URL

> +@item #+SETUPFILE: file/URL

file/URL > file name or URL

> +The setup file or a URL pointing to such file is for additional in-bu= ffer
> +settings.=C2=A0 Org loads this file and parses it for any settings in= it only when
> +Org opens the main file.=C2=A0 If URL is specified, the contents are = downloaded
> +and stored in a temporary cache.=C2=A0 @kbd{C-c C-c} on the settings = line will
> +also parse and load.=C2=A0 @kbd{C-c C-c} on the @code{#+SETUPFILE:} l= ine will also
> +reset the temporary file cache.=C2=A0 Org also parses and loads the f= ile/URL

file/URL > document

> +during normal exporting process.=C2=A0 Org parses the contents of thi= s
> file/URL as

file/URL document

> +if it was included in the buffer.=C2=A0 It can be another Org file.= =C2=A0 To visit the
> +file (not a URL), @kbd{C-c '} while the cursor is on the line wit= h the file
>=C2=A0 name.
>=C2=A0 @item #+STARTUP:
>=C2=A0 @cindex #+STARTUP
> @@ -17395,7 +17398,9 @@ If any highlights shown in the buffer from the= creation of a sparse tree, or
>=C2=A0 from clock display, remove such highlights.
>=C2=A0 @item
>=C2=A0 If the cursor is in one of the special @code{#+KEYWORD} lines, s= can the
> -buffer for these lines and update the information.
> +buffer for these lines and update the information.=C2=A0 Also reset t= he org file

org > Org

> +(defvar ffap-url-regexp)=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0;Silence byte-compiler

I think this can go at the beginning of the "org.el".

> +=C2=A0 =C2=A0 ;; Reset the cache of files downloaded by `org-file-con= tents'.
> +=C2=A0 =C2=A0 (clrhash org--file-cache))

Note that we can still implement a non-interactive
`org-reset-setupfile-cache' function and call it here instead. (clrhash=
org--file-cache) may be a bit low level at this point.

Otherwise, LGTM. Would you want to throw in some tests? You can use
cl-letf to bind `url-retrieve-synchronously' to a function returning a buffer containing some dumb (valid or invalid) output.

Thanks. I'll get back to this in 8 days; I'= m going offline (vacation).
--

Kaushal Modi

--f403045fb6d66a520b055092b306--