emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Gustav Wikström" <gustav@whil.se>
To: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Cc: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: RE: attachment: link type export to HTML invalid attach dir
Date: Sat, 8 Feb 2020 15:39:18 +0000	[thread overview]
Message-ID: <HE1PR02MB3033668D1D2CD40DB2C7E932DA1F0@HE1PR02MB3033.eurprd02.prod.outlook.com> (raw)
In-Reply-To: <878sle1ng9.fsf@nicolasgoaziou.fr>

Hi,

> -----Original Message-----
> From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
> Sent: den 7 februari 2020 15:28
> To: Gustav Wikström <gustav@whil.se>
> Cc: emacs-orgmode@gnu.org
> Subject: Re: attachment: link type export to HTML invalid attach dir
> 
> > Hmm, maybe that is so.. Except raw-path is called path (not really an
> > issue though) and there is another property called raw-link. Not sure
> > how to interpret the use of both path and raw-link. And there are
> > things happening between parsing the actual buffer link and storing
> > the raw-link and path parameters.
> 
> There is some normalization involved, indeed. The intent of :raw-link is
> to provide the link almost as it was in the buffer, without any parsing.
> I agree there should not be any `org-link-unescape' and
> `org-link-expand-abbrev' involved there. Something to fix at some point.
> 
> :path, on the contrary is parsed. It is the part of the link between the
> type and the search options, i.e., [[type:path::search]], [[type:path]],
> or [[path]].

Unless search-option applies as a general construct for all link types I don't think it should be in the parser. Given the discussion we've had about design of the parser from before. I.e. if the parser isn't supposed to know anything about the specific types themselves, all properties of the parsed elements have to make sense for all types of links. So either search-option remains but is parsed in exactly the same way for all link types, or it's not there at all. And if it's not available in the parser, the file link interpreters (that still might need to be constructed) gets to parse the :search-option from the raw-link as it wishes itself. 

Given the above paragraph, the :path and :search-option property doesn't make sense in the parser. :raw-link is enough. Less ambiguous names for :path and :search-option would be :file-path and :file-search-option. But that's sub-typing. We've already concluded that that should not belong to the parser.

> > In the end, what made me consider the sub-typing I've been writing
> > about could very well just have been the ambiguities regarding what's
> > what, and the lack of treatment for parts that arguably could be seen
> > as additional parameters to the link-path. For example the
> > "::extra_content" suffix in file links, that by the parser currently
> > is just a part of the path itself.
> 
> In [[file:name::extra_content]] :path is "name", and :search-option is
> "extra_content". As you noted, :search-option is not valid in non-file
> links, so it belongs to the path.
> 
> It seems there is some friction about this search option part. IIUC, you
> want attachment links to support this link-specific syntax. This is
> indeed not possible. As I commented earlier, letting libraries decide
> what the parser should do is not an option. There are a few options,
> though:
> 
> 1. Allow every link with an explicit type (i.e., not internal links) to
>    have a search option, so you can write [[docview:filename::12]] or
>    [[attachment:filename::*Section 2]]. IMO this is a waste, because
>    most links do not need this, and it could become confusing
>    [[https:www.orgmode.org::#sec2]].
> 
> 2. Provide a function in "ol.el" to do the parsing for you, so that
>    every new link library doesn't have to re-invent the wheel. E.g.,
>    (org-link-extract-search-options "foo::bar") => (:path
>    "foo" :search-options "bar").
> 
> 3. Keep that way, i.e., any link library requiring to read the search
>    part can do a dumb `match-string` and, in two or three lines of code,
>    extract it. IOW, since this is so trivial, why bother?
> 
> WDYT?

I agree that option 1 is suboptimal. :search-option isn't obvious as a property for all link types. Since option 3 is fairly trivial, option 2 isn't necessary either. For attachment links to reuse the :search-option semantics, without the hard-coding we're currently doing, I see one option where attachment link higher order functions could reuse file link higher order functions. Those file link higher order functions don't exist yet as far as I know.

> > Maybe clearer documentation in the function of what each part is
> > /supposed/ to be, and the design principle that is applied, i.e. that
> > the path is the raw path with options included can help future me and
> > others who might want to understand. Thoughts on that?
> 
> There is some information in the manual, and the Org Syntax document.
> 
> > Hmm, don't really know if a link description should be regarded as
> > content. I for one hadn't considered it until now when you mentioned
> > it! But it preserves space in the parse tree I suppose.
> 
> This is unrelated to the size of the parse tree.
> 
> A description may contain Org specific markup, e.g., bold, so it needs
> to be parsed further. Therefore, a link with a description is not
> a leaf: it has contents.
> 
> > If the docstring of the link parser would make it clear what each
> > property is supposed to contain, in this case :contents-begin
> > & :contents-end, I'm sure I would have been less confused about this,
> > and wouldn't have had any objections.
> 
> A docstring is not a manual. I explained this in the Org Element API
> documentation, IIRC.

True that. There is a balance to strike. Maybe it's time to pull in the org element document into the manual? I vote for that at least.

> > Ok, got it. You're saying the link interpreter for docview (in this
> > case) have to be able to parse the link one step further, to be able
> > to extract this ":go-to-page" information, before being able to
> > operate on it. Indeed a design decision. Maybe the best one, who am
> > I to say otherwise. It will make the Org link parser leaner for sure.
> 
> Sarcasm?

No, not sarcasm. Sorry for not being more clear. I'm well aware that I'm delving in things quite advanced where my prior experience is thin. I can't cite articles about best way to work with parsers and interpreters. I can only reason to the best of my ability.

> My opinion is the library defining the Org syntax should be a fixed
> point. It is important that the output of the parser does not depend on
> what libraries are currently loaded. It guarantees that if we both open
> the same document, we'll get the same parse tree.
> 
> Of course, this is not exactly true at the moment. For example, we may
> not have the same TODO keywords, or the same item list separator.
> Nevertheless, I see no reason to diverge further from this goal.

Ok, sure. Let the syntax be as rigid as possible, and let extensibility to that be dealt with in auxiliary parsing/interpreting functions. I guess that would be the approach, put in different words. Still correct?

> > Not sure about location. Maybe ol.el? What I'm talking about is
> > a higher order function for the :export property within
> > org-link-parameters. File link exporting would then have to be
> > declared using org-link-set-parameters, just as other link types are
> > supposed to be declared for exporting.
> 
> See above about my suggestion of a generic tool.
> 
> >> As suggested already (I think) we could add a phase in ox.el that would
> >> expand attachment links into their file link counterpart automatically.
> >> This would avoid adding specific code in every export back-end. However,
> >> export back-end would miss the opportunity to handle attachment links
> >> specifically. This is one way or the other.
> >
> > Let's settle with option two for now. As it's defined in the patch.
> 
> Too bad. I still think that first option is more seducing. Transparently
> turning attachment links into file links at export time would prevent
> some headache in exporters out there. It boils down to adding a function
> that transforms "attach" links into "file" links, e.g.,
> `org-export--expand-attachments', and insert it in `org-export-as',
> right after (org-export--remove-uninterpreted-data tree info).

It might be seducing but I'm not sold. I'd rather have an attachment-link exporter explicitly reuse functionality for exporting file links than automatic translation. For that to be possible, there first is a need for a file link exporter function. And the current implementation (since the patch) is good enough imo, for now, and until anyone of us does some file link refactoring.

Kind regards
Gustav

  reply	other threads:[~2020-02-08 15:39 UTC|newest]

Thread overview: 113+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-21  7:53 FW: [RFC] Link-type for attachments, more attach options Gustav Wikström
2018-11-01  1:45 ` tumashu
2018-11-02 22:40   ` Gustav Wikström
2018-11-01 16:00 ` Marco Wahl
2018-11-02 23:07   ` Gustav Wikström
2018-11-03  3:37     ` Ihor Radchenko
2018-11-17 12:13       ` Gustav Wikström
2018-11-18  0:42         ` Ihor Radchenko
2018-11-18  8:57           ` Gustav Wikström
2018-11-20 14:00             ` Ihor Radchenko
2018-11-24 13:56               ` Gustav Wikström
2018-12-14  2:16                 ` Ihor Radchenko
2019-05-26 22:24                   ` Gustav Wikström
2018-11-04 22:37 ` Nicolas Goaziou
2018-11-17 11:58   ` Gustav Wikström
     [not found]     ` <PR1PR02MB47322711B7F7B7142D156F54DADE0@PR1PR02MB4732.eurprd02.prod.outlook.com>
2018-11-19 23:52       ` Nicolas Goaziou
2018-11-25 21:13         ` Gustav Wikström
2018-11-27  9:39           ` Nicolas Goaziou
2019-05-26 23:05             ` Gustav Wikström
2019-06-15 13:29               ` Nicolas Goaziou
2019-06-15 15:38                 ` Bastien
2019-06-30  6:03                 ` Gustav Wikström
2019-07-06 21:46                   ` Nicolas Goaziou
2019-07-07 18:38                     ` Gustav Wikström
2019-07-08 10:47                       ` Marco Wahl
2019-07-09 10:16                       ` Nicolas Goaziou
2019-07-27 14:56                       ` Ihor Radchenko
2019-07-28 20:39                         ` Gustav Wikström
2019-07-28 23:20                           ` Ihor Radchenko
2019-01-04 12:21 ` FW: " Feng Shu
2019-05-26 23:15   ` Gustav Wikström
2019-12-12  5:21 ` stardiviner
2019-12-12  6:12   ` Gustav Wikström
2019-12-12  9:52     ` stardiviner
2019-12-12 19:42       ` Gustav Wikström
2019-12-13 13:38         ` stardiviner
2019-12-13 21:37           ` Gustav Wikström
2019-12-13 22:15             ` Gustav Wikström
2019-12-15  4:14               ` stardiviner
2019-12-15  9:29               ` stardiviner
2019-12-15 10:06                 ` Gustav Wikström
2019-12-15 14:26                   ` stardiviner
2019-12-15 20:41                     ` Gustav Wikström
2019-12-16  3:38                       ` stardiviner
2019-12-16 11:21 ` stardiviner
2019-12-17  4:27   ` stardiviner
2020-01-13 12:24 ` attachment: link type export to HTML invalid attach dir stardiviner
2020-01-14  3:27   ` Gustav Wikström
2020-01-14  5:04     ` stardiviner
2020-01-14 20:58       ` Gustav Wikström
2020-01-15  5:53         ` stardiviner
2020-01-15 19:48           ` Gustav Wikström
2020-01-16 11:06             ` stardiviner
2020-01-16 13:18             ` Nicolas Goaziou
2020-01-16 21:42               ` Gustav Wikström
2020-01-16 23:07                 ` Gustav Wikström
2020-01-17  0:39                   ` Nicolas Goaziou
2020-01-17 14:29                     ` Gustav Wikström
2020-01-17 18:36                       ` Gustav Wikström
2020-01-18  1:13                         ` Gustav Wikström
2020-01-18 11:34                           ` Nicolas Goaziou
2020-01-18 15:14                             ` Gustav Wikström
2020-01-19 21:12                               ` Nicolas Goaziou
2020-01-19 23:29                                 ` Gustav Wikström
2020-01-20  1:25                                   ` Nicolas Goaziou
2020-01-25 11:34                                     ` Gustav Wikström
2020-02-05 16:54                                       ` Nicolas Goaziou
2020-02-06 20:55                                         ` Gustav Wikström
2020-02-07 14:28                                           ` Nicolas Goaziou
2020-02-08 15:39                                             ` Gustav Wikström [this message]
2020-02-13 20:41                                               ` Nicolas Goaziou
2020-02-13 21:11                                                 ` Gustav Wikström
2020-02-13 21:37                                                   ` Nicolas Goaziou
2020-02-13 22:07                                                     ` Gustav Wikström
2020-02-14  0:16                                                       ` Nicolas Goaziou
2020-02-14  7:23                                                         ` Gustav Wikström
2020-02-14  2:42                                                       ` Kyle Meyer
2020-02-14  7:35                                                         ` Gustav Wikström
2020-02-14  7:41                                                         ` Gustav Wikström
2020-02-14 11:06                                                       ` Bastien
2020-02-14 17:12                                                         ` Nicolas Goaziou
2020-02-14 20:33                                                           ` Bastien
2020-02-15 18:08                                                             ` Nicolas Goaziou
2020-02-15 23:04                                                               ` Kyle Meyer
2020-02-16  8:51                                                                 ` Nicolas Goaziou
2020-02-16 23:59                                                                   ` Bastien
2020-02-17  9:37                                                                     ` Nicolas Goaziou
2020-02-17 10:25                                                                       ` Bastien
2020-02-16 23:58                                                               ` Bastien
2020-02-17 10:32                                                                 ` Nicolas Goaziou
2020-02-17 10:53                                                                   ` Bastien
2020-02-20  9:20                                                               ` Nicolas Goaziou
2020-02-20 10:20                                                                 ` Bastien
2020-02-22 12:58                                                                   ` Nicolas Goaziou
2020-02-22 13:32                                                                     ` Bastien
2020-02-25 23:36                                                                       ` Gustav Wikström
2020-02-26 15:22                                                                         ` Nicolas Goaziou
2020-02-27 19:02                                                                           ` Gustav Wikström
2020-02-28  0:37                                                                             ` Nicolas Goaziou
2020-02-13 21:57                                                 ` Gustav Wikström
2020-02-14 10:02                                                 ` Bastien
2020-01-13 13:41 ` FW: [RFC] Link-type for attachments, more attach options stardiviner
2020-01-14 21:17   ` Gustav Wikström
2020-01-15  6:20     ` stardiviner
2020-01-15 22:42       ` Gustav Wikström
2020-01-16 11:15         ` stardiviner
2020-01-18 14:56           ` stardiviner
2020-01-18 15:30             ` Gustav Wikström
2020-01-19  4:28               ` stardiviner
2020-01-19  9:53                 ` Gustav Wikström
2020-01-17  7:39 ` Missing `org-attach-set-inherit' function stardiviner
2020-01-17 16:31   ` Gustav Wikström
2020-01-18 14:54     ` stardiviner

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=HE1PR02MB3033668D1D2CD40DB2C7E932DA1F0@HE1PR02MB3033.eurprd02.prod.outlook.com \
    --to=gustav@whil.se \
    --cc=emacs-orgmode@gnu.org \
    --cc=mail@nicolasgoaziou.fr \
    /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).