nobiot / org-transclusion

Emacs package to enable transclusion with Org Mode
https://nobiot.github.io/org-transclusion/
GNU General Public License v3.0
919 stars 45 forks source link

org-transclusion-add so that it, optionally would set a link to a file? #104

Open ouboub opened 2 years ago

ouboub commented 2 years ago

Hi I am using using emacs master 846ff294, transclude f89363cd99a6c5a. Maybe I am missing something elementary, but is there any possibility to enhance org-transclusion-add so that it, optionally would set a link to a file?

In my understanding, I need an already valid link to use that function so, if that org-transclusion-add could add that link, would be very convenient. thanks

Uwe Brauer

nobiot commented 2 years ago

Hi Uwe @ouboub

For Org syntax, it's a keyword; I don't think it can be a link at the same time.

Nevertheless, you can click on the link part and navigate to the target. Currently, not all link types are supported -- file: and id: really. Screenshot from 2021-11-10 18-11-03

At the moment, there is another interactive function org-transclusion-make-from-link. The direction is the other way around; you have a link first, and then create a transclusion keyword.

Does this answer your question?

ouboub commented 2 years ago

"NO" == Noboru Ota @.***> writes: Hi Noboru Hi Uwe @ouboub For Org syntax, it's a keyword; I don't think it can be a link.

Nevertheless, you can click on the link part and navigate to the target. Currently, not all link types are supported -- file: and id: really. Screenshot from 2021-11-10 18-11-03

At the moment, there is another interactive function org-transclusion-make-from-link. The direction is the other way around; you have a link first, and then create a transclusion keyword.

Right, I understand that much, but I see that I explain what I want rather poorly. I am thinking of a function that, optionally, adds a link and create a transclusion keyword at the same time. Right now one has to do two steps by using two functions

  1. org-insert-link and

  2. org-transclusion-make-from-link

I am asking for function, which is doing that in one go.

Did I explain this better?

Uwe

nobiot commented 2 years ago

This seems to do the two steps in one go:

(defun my/org-insert-link-transclusion (&optional COMPLETE-FILE LINK-LOCATION DESCRIPTION)
  (interactive)
  (org-insert-link COMPLETE-FILE LINK-LOCATION DESCRIPTION)
  (org-transclusion-make-from-link))

It does not offer the option -- it always tries make-from-link. So you would choose between normal org-insert-link and (optionally) my/org-insert-link-transclusion

Is this what you mean?

ouboub commented 2 years ago

"NO" == Noboru Ota @.***> writes:

This seems to do the two steps in one go:

(defun my/org-insert-link-transclusion (&optional COMPLETE-FILE LINK-LOCATION DESCRIPTION)
  (interactive)
  (org-insert-link COMPLETE-FILE LINK-LOCATION DESCRIPTION)
  (org-transclusion-make-from-link))

It does not offer the option -- it always tries make-from-link. So you would choose between normal org-insert-link and (optionally) my/org-insert-link-transclusion

Is this what you mean?

Almost. The problem is that the function does not allow to specify optionally the complete file and link location.

1. Try please C-u M-x org-insert-link

2. And the same for  C-u M-x my/org-insert-link-transclusion

The first one will allow to specify link location, yours does not.

Uwe

nobiot commented 2 years ago

Oh I see. I didn't know about this feature with C-u. Then it should be as easy as adding "P" in call to the interactive function. Like this:

(defun my/org-insert-link-transclusion (&optional COMPLETE-FILE LINK-LOCATION DESCRIPTION)
  (interactive "P")
  (org-insert-link COMPLETE-FILE LINK-LOCATION DESCRIPTION)
  (org-transclusion-make-from-link))

My casual test has worked.