emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Understand the source of "Unable to resolve link"
@ 2018-02-04 15:58 Kaushal Modi
  2018-02-04 16:19 ` Nicolas Goaziou
  0 siblings, 1 reply; 5+ messages in thread
From: Kaushal Modi @ 2018-02-04 15:58 UTC (permalink / raw)
  To: emacs-org list

[-- Attachment #1: Type: text/plain, Size: 762 bytes --]

Hello,

A user needs to support having gopher links in Org document:

 [[gopher://some.gopher.site][Dummy gopher link]]

But the export fails saying that it's unable to resolve the link.

The behavior can be easily recreated by exporting a document containing
that dummy link using C-c C-e h H.

I added "gopher" to the org-html-link function, but that obviously didn't
help.

I traced the error to org-export-data in ox.el, but I cannot edebug that
function; I get:

    edebug-syntax-error: Invalid read syntax: "Failed matching", (&rest
(&define name (&rest arg) cl-declarations-or-string def-body))

(I'll open an emacs bug for that.)

So what needs to be fixed in ox.el (or elsewhere?) so that gopher: protocol
links are allowed?

Thanks.
-- 

Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 1082 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Understand the source of "Unable to resolve link"
  2018-02-04 15:58 Understand the source of "Unable to resolve link" Kaushal Modi
@ 2018-02-04 16:19 ` Nicolas Goaziou
  2018-02-04 16:23   ` Kaushal Modi
  0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Goaziou @ 2018-02-04 16:19 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: emacs-org list

Hello,

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

> A user needs to support having gopher links in Org document:
>
>  [[gopher://some.gopher.site][Dummy gopher link]]
>
> But the export fails saying that it's unable to resolve the link.
>
> The behavior can be easily recreated by exporting a document containing
> that dummy link using C-c C-e h H.
>
> I added "gopher" to the org-html-link function, but that obviously didn't
> help.
>
> I traced the error to org-export-data in ox.el, but I cannot edebug that
> function; I get:
>
>     edebug-syntax-error: Invalid read syntax: "Failed matching", (&rest
> (&define name (&rest arg) cl-declarations-or-string def-body))
>
> (I'll open an emacs bug for that.)
>
> So what needs to be fixed in ox.el (or elsewhere?) so that gopher: protocol
> links are allowed?

I don't think Org defines gopher links. Where is it registered? In
particular, what is the export function associated to the link type?

If you don't tell Org what it a gopher link, e.g., within
`org-link-parameters', Org considers your example above as a fuzzy link,
hence the error.

Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Understand the source of "Unable to resolve link"
  2018-02-04 16:19 ` Nicolas Goaziou
@ 2018-02-04 16:23   ` Kaushal Modi
  2018-02-04 16:31     ` Nicolas Goaziou
  0 siblings, 1 reply; 5+ messages in thread
From: Kaushal Modi @ 2018-02-04 16:23 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-org list

[-- Attachment #1: Type: text/plain, Size: 660 bytes --]

On Sun, Feb 4, 2018 at 11:19 AM Nicolas Goaziou <mail@nicolasgoaziou.fr>
wrote:

> Hello,
>
> I don't think Org defines gopher links. Where is it registered? In
> particular, what is the export function associated to the link type


Looks like[1], gopher: links can behave the same way as https:, http:, etc.

If you don't tell Org what it a gopher link, e.g., within
> `org-link-parameters', Org considers your example above as a fuzzy link,
> hence the error.
>

Thanks. I'll ask the user to update that variable (or can that be updated
in the default value?).

[1]:
https://github.com/kaushalmodi/ox-hugo/issues/132#issuecomment-362854410
-- 

Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 1305 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Understand the source of "Unable to resolve link"
  2018-02-04 16:23   ` Kaushal Modi
@ 2018-02-04 16:31     ` Nicolas Goaziou
  2018-02-04 20:42       ` Kaushal Modi
  0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Goaziou @ 2018-02-04 16:31 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: emacs-org list

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

> Thanks. I'll ask the user to update that variable (or can that be updated
> in the default value?).

Note that you cannot simply copy "http" or "https" types. As default
type links, they are hard-coded in every export back-end. It means they
do not have to set any :export property.

As a user, if you want to export a "gopher" link type, you need to
implement a function exporting it, and register it as the :export value.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Understand the source of "Unable to resolve link"
  2018-02-04 16:31     ` Nicolas Goaziou
@ 2018-02-04 20:42       ` Kaushal Modi
  0 siblings, 0 replies; 5+ messages in thread
From: Kaushal Modi @ 2018-02-04 20:42 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-org list

[-- Attachment #1: Type: text/plain, Size: 941 bytes --]

On Sun, Feb 4, 2018 at 11:31 AM Nicolas Goaziou <mail@nicolasgoaziou.fr>
wrote:

> Note that you cannot simply copy "http" or "https" types. As default
> type links, they are hard-coded in every export back-end. It means they
> do not have to set any :export property.
>
> As a user, if you want to export a "gopher" link type, you need to
> implement a function exporting it, and register it as the :export value.
>

Thank you.

This works.

(defun org-link-gopher-export-link (link desc format)
  "Create export version of LINK and DESC to FORMAT."
  (let ((link (concat "gopher:" link)))
    (cond
     ((eq format 'html)
      (format "<a href=\"%s\">%s</a>" link desc))
     ((eq format 'latex)
      (format "\\href{%s}{%s}" link desc))
     (t                               ;`ascii', `md', `hugo', etc.
      (format "[%s](%s)" desc link)))))
(org-link-set-parameters "gopher" :export #'org-link-gopher-export-link)
-- 

Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 1576 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-02-04 20:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-04 15:58 Understand the source of "Unable to resolve link" Kaushal Modi
2018-02-04 16:19 ` Nicolas Goaziou
2018-02-04 16:23   ` Kaushal Modi
2018-02-04 16:31     ` Nicolas Goaziou
2018-02-04 20:42       ` Kaushal Modi

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).