emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: Michael Dauer <mick.dauer@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: [org-export] Linking inlinetasks (was: BUG?: Link to inline-task not working)
Date: Wed, 05 Oct 2022 11:23:50 +0800	[thread overview]
Message-ID: <871qrnar7d.fsf@localhost> (raw)
In-Reply-To: <87ee6p4zhn.fsf@localhost>

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

Ihor Radchenko <yantar92@gmail.com> writes:

> Michael Dauer <mick.dauer@gmail.com> writes:
>> Shouldn't be org-export-resolve-fuzzy-link the relevant function, at least
>> for my use case?
>> But there it looks like it is searching through all elements including
>> inlinetasks, which is in org-element-all-elements:
>> (append pseudo-types '(target) org-element-all-elements)
> Maybe. Further it also calls org-export-search-cells, which does not
> consider inlinetasks even if they are matched.

I have investigated further.
In addition to inlinetasks not being taken into account by
`org-export-search-cells', `org-export-resolve-fuzzy-link', and
`org-export-resolve-id-link', there is no export backend support for
linking inlinetasks.

In order to have full support for inlinetasks during export, we need to
modify export backends to be able to link to the inlinetasks.

For example,
- ox-html.el does not associate ID anchor in
- ox-latex.el also does not provide any label in
- ox-ascii.el does not assign a number to be referred to in

I did not check other backends.

Note that changing only ox.el without altering the individual backends
can break export in unexpected ways.

I am attaching a simple patch changing the generic link resolution
machinery. If one applies the patch, **export will be broken**.
In particular, exporting to ASCII (C-c C-e t U) will straight throw
an error.

The same may happen in third-party export backends even if we alter the
all built-in export backends appropriately.

Thus, supporting links to inlinetasks will be a breaking change and such
support should be shielded behind a user customization, not be enabled
by default.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-ox.el-Allow-links-to-inlinetasks.patch --]
[-- Type: text/x-patch, Size: 2173 bytes --]

From c6737633b12b8f9de1a240b2f32f52d54e1c14a1 Mon Sep 17 00:00:00 2001
Message-Id: <c6737633b12b8f9de1a240b2f32f52d54e1c14a1.1664939959.git.yantar92@gmail.com>
From: Ihor Radchenko <yantar92@gmail.com>
Date: Wed, 5 Oct 2022 11:17:55 +0800
Subject: [PATCH] lisp/ox.el: Allow links to inlinetasks

* lisp/ox.el (org-export-search-cells):
(org-export-resolve-id-link): Resolve links to inlinetasks.

**This is not a proper commit**
Applying it will not make inlinetask links work during export.
Backend-specific support will be required.
 lisp/ox.el | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lisp/ox.el b/lisp/ox.el
index 51145acaa..6090d1ecd 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -4313,7 +4313,7 @@ (defun org-export-search-cells (datum)
 A search cell is the internal representation of a fuzzy link.  It
 ignores white spaces and statistics cookies, if applicable."
   (pcase (org-element-type datum)
-    (`headline
+    ((or `headline `inlinetask)
      (let ((title (split-string
 		    "\\[[0-9]*\\(?:%\\|/[0-9]*\\)\\]" " "
@@ -4408,7 +4408,8 @@ (defun org-export-resolve-fuzzy-link (link info &rest pseudo-types)
 	 ;; Matching both a name and a target is not valid, and
 	 ;; therefore undefined.
 	 (or (cl-some (lambda (datum)
-			(and (not (eq (org-element-type datum) 'headline))
+			(and (not (memq (org-element-type datum)
+                                      '(headline inlinetask)))
 	     (car matches))
@@ -4428,7 +4429,7 @@ (defun org-export-resolve-id-link (link info)
                              (let ((table (make-hash-table :test #'equal)))
                                    (plist-get info :parse-tree)
-                                   'headline
+                                   '(headline inlinetask)
                                  (lambda (headline)
                                    (let ((id (org-element-property :ID headline))
                                          (custom-id (org-element-property :CUSTOM_ID headline)))

[-- Attachment #3: Type: text/plain, Size: 207 bytes --]

Ihor Radchenko,
Org mode contributor,
Learn more about Org mode at https://orgmode.org/.
Support Org development at https://liberapay.com/org-mode,
or support my work at https://liberapay.com/yantar92

      reply	other threads:[~2022-10-05  3:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-03  8:30 BUG?: Link to inline-task not working Michael Dauer
2021-12-03 10:51 ` Ihor Radchenko
2021-12-03 14:20   ` Michael Dauer
2021-12-04  3:19     ` Ihor Radchenko
2021-12-06 13:14       ` Michael Dauer
2021-12-06 13:47         ` Ihor Radchenko
2022-10-05  3:23           ` Ihor Radchenko [this message]

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:

  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=871qrnar7d.fsf@localhost \
    --to=yantar92@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=mick.dauer@gmail.com \


* 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


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