emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* links are not parsed in keyword context
@ 2020-04-13  8:27 Alan Schmitt
  2020-04-13  9:19 ` Nicolas Goaziou
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Schmitt @ 2020-04-13  8:27 UTC (permalink / raw)
  To: emacs-orgmode

Hello,

If you consider the following line in an org file

#+begin_src org
#+FOO: http://alan.petitepomme.net/
#+end_src

then calling ~org-element-context~ returns

#+begin_src emacs-lisp
(keyword
 (:key "FOO"
  :value "http://alan.petitepomme.net/"
  :begin 1
  :end 38
  :post-blank 1
  :post-affiliated 1
  :parent nil))
#+end_src

If the same link is in the body of the org file, one gets

#+begin_src emacs-lisp
(link
 (:type "http"
  :path "//alan.petitepomme.net/"
  :format plain
  :raw-link "http://alan.petitepomme.net/"
  :application nil
  :search-option nil
  :begin 38
  :end 66
  :contents-begin nil
  :contents-end nil
  :post-blank 0
  :parent (paragraph
           (:begin 38
            :end 68
            :contents-begin 38
            :contents-end 67
            :post-blank 1
            :post-affiliated 38
            :parent nil))))
#+end_src

The link can still be opened in both cases using ~org-open-at-point~,
but it is a problem for org-ref that relies on the second format to
extract the link information (see
https://github.com/jkitchin/org-ref/blob/master/org-ref-core.el#L2045,
where the link is set to ~nil~ because there is no ~:path~ property).

I see that orgmode uses a workaround in ~org-return~ when
~org-return-follows-link~ is set to true, to detect if there is a link
using a regexp
(https://code.orgmode.org/bzg/org-mode/src/maint/lisp/org.el#L18106):
#+begin_src emacs-link
((and org-return-follows-link
  (or (org-in-regexp org-ts-regexp-both nil t)
      (org-in-regexp org-tsr-regexp-both nil  t)
      (org-in-regexp org-any-link-re nil t)))
    (call-interactively #'org-open-at-point))
#+end_src

Could is be possible to parse a link in keyword context? Alternatively,
should I suggest org-ref uses an approach similar to the one in ~org-return~?

Thanks,

Alan



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

* Re: links are not parsed in keyword context
  2020-04-13  8:27 links are not parsed in keyword context Alan Schmitt
@ 2020-04-13  9:19 ` Nicolas Goaziou
  2020-04-13 12:59   ` Alan Schmitt
  0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Goaziou @ 2020-04-13  9:19 UTC (permalink / raw)
  To: Alan Schmitt; +Cc: emacs-orgmode

Hello,

Alan Schmitt <alan.schmitt@polytechnique.org> writes:

> If you consider the following line in an org file
>
> #+begin_src org
> #+FOO: http://alan.petitepomme.net/
> #+end_src
>
>
> then calling ~org-element-context~ returns
>
> #+begin_src emacs-lisp
> (keyword
>  (:key "FOO"
>   :value "http://alan.petitepomme.net/"
>   :begin 1
>   :end 38
>   :post-blank 1
>   :post-affiliated 1
>   :parent nil))
> #+end_src

This is a feature. With a few exception, keyword value is not parsed,
i.e., Org does not need to understand what happens in there.

> Could is be possible to parse a link in keyword context?

That wouldn't make sense in most contexts.

> Alternatively, should I suggest org-ref uses an approach similar to
> the one in ~org-return~?

I think Org Ref can parse the value of the keyword (a string), instead.
There is, for example, `org-element-parse-secondary-string'.

Regards,

-- 
Nicolas Goaziou


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

* Re: links are not parsed in keyword context
  2020-04-13  9:19 ` Nicolas Goaziou
@ 2020-04-13 12:59   ` Alan Schmitt
  0 siblings, 0 replies; 3+ messages in thread
From: Alan Schmitt @ 2020-04-13 12:59 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode

Hello Nicolas,

On 2020-04-13 11:19, Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> This is a feature. With a few exception, keyword value is not parsed,
> i.e., Org does not need to understand what happens in there.

Thank you for the explanation.

>> Alternatively, should I suggest org-ref uses an approach similar to
>> the one in ~org-return~?
>
> I think Org Ref can parse the value of the keyword (a string), instead.
> There is, for example, `org-element-parse-secondary-string'.

I mentioned your suggestion in the issue on the org-ref repo
(https://github.com/jkitchin/org-ref/issues/718). Thanks again.

Best,

Alan



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

end of thread, other threads:[~2020-04-13 13:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-13  8:27 links are not parsed in keyword context Alan Schmitt
2020-04-13  9:19 ` Nicolas Goaziou
2020-04-13 12:59   ` Alan Schmitt

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