Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Please support org-roam style link concealing in the taskpaper syntax #15

Open
wakatara opened this issue Apr 8, 2022 · 7 comments

Comments

@wakatara
Copy link

wakatara commented Apr 8, 2022

Using org-roam installed and Taskpaper, you can insert org-roam links of the style

Projects:
	Perso:...
	Work:
		Platforms:
			- Ping [[id:F5531E65-5ECB-465C-9384-0B9BBF04C8B4][Boss]] on that thing we talked about

This is nicely inserted with C-n i and a handy ivy narrowing to the thing you select.

In org-roam, these links use concealing special characters to appear simply as highlighted link Boss.

Is there a way we can support that in the Taskpaper syntax (perhaps optionally) as it is way to be able to connect people and topics into each todo item?

thanks!
Daryl.

@wakatara wakatara changed the title [Feature Request] Please support org-roam style link concelaing in the taskpaper syntax [Feature Request] Please support org-roam style link concealing in the taskpaper syntax Apr 8, 2022
@saf-dmitry
Copy link
Owner

saf-dmitry commented Apr 8, 2022

What should happen when you click on such link in a TaskPaper file?

@wakatara
Copy link
Author

Hey @saf-dmitry

You should simply go to the org-roam page indicated. Though it would be nice if the [[ ... ][...]] for the links was honoured so that you only see the "title" of the link you'd be heading to rather than the full linking style. Does that make sense?

@saf-dmitry
Copy link
Owner

saf-dmitry commented Apr 15, 2022

@wakatara TaskPaper mode already supports inline Markdown links in form [Description](URI) as described in the manual. When markup hiding is enabled, only the description part is displayed as hyperlink making the link more readable.

You can delegate opening id: links to Org-roam by adding the following lines to your Emacs init file:

(defun my-org-open-uri (uri)
  (when (string-prefix-p "id:" uri)
    (org-open-link-from-string (format "[[%s]]" uri))
    t))

(add-hook 'taskpaper-open-uri-hook 'my-org-open-uri)

Now you can write something like this in your TaskPaper documents:

- Ping [Boss](id:F5531E65-5ECB-465C-9384-0B9BBF04C8B4) on that thing ...

Clicking on the link should take you to the corresponding Org-roam node (assuming Org-roam is already installed and configured).

See the corresponding example in the Scripting Guide and the documentation string of taskpaper-open-uri-hook for more details and inspiration.

@wakatara
Copy link
Author

@saf-dmitry

Hey! Thanks for the quick response. The link opening works great once you insert that function. Very helpful.

Ah, I think I must have miscommunicated my intent with the links though.

Org-roam links use org-mode style so are of the form [[link uri][description]] rather than markdown []() style so they are neither highlighted nor clickable. And of course, having the mark up hidden for those so they only display their description would be amazing as well.

@saf-dmitry
Copy link
Owner

saf-dmitry commented Apr 17, 2022

@wakatara

I understand that you suggest supporting Org mode link syntax. However, honestly I don't see any good reason to support Org links (as many other link syntaxes) in the TaskPaper mode.

Why are Markdown links not working for you?

This is nicely inserted with C-n i and a handy ivy narrowing to the thing you select.

Could you elaborate this a bit more? What does C-n i exactly do? Is it bound to org-roam-node-insert?

@wakatara
Copy link
Author

@saf-dmitry

Completely understand your position. If it wasn't for tools like org-roam and org-journal in emacs and a few others in the ecosystem, I'd strongly prefer markdown everywhere myself (in fact, trying to see if I can get md-roam with org-roam working.). I'm a much bigger proponent of markdown myself.

But... in using emacs, it feel like org-mode has a special place even if you choose not to use it for org-agenda (which I'm obviously doing if using taskpaper mode), so I'd assert that supporting the org-mode link protocol is about as important as markdown's.

In org-roam, C-c n i calls org-roam-node-insert which brings up minibuffer you can type into to fuzzy search a node (mine's integrated with ivy) or it create an org-capture buffer with a templated org-mode file to allow you to create a new entry. The insert also then inserts an org-mode link to the document in question into your existing buffer.

If you've ever seen Roam Research or Logseq, the idea with org-roam is that it creates bidrectional links that you can then traverse to navigate or surface your information or see the backlinks to it (which is the handy feature) in order to understand it in your collections of documents and "knowledge graph" better. It's pretty handy.

@saf-dmitry
Copy link
Owner

@wakatara

You can convert an Org-roam link at point to Markdown syntax using the following function:

(defun my-org-convert-link ()
  (interactive)
  (require 'thingatpt)
  (let ((re "\\[\\[\\(.*?\\)\\]\\(?:\\[\\(.*?\\)\\]\\)?\\]"))
    (when (and (derived-mode-p 'taskpaper-mode)
               (thing-at-point-looking-at re))
      (let* ((uri  (match-string-no-properties 1))
             (desc (or (match-string-no-properties 2) uri)))
        (delete-region (match-beginning 0) (match-end 0))
        (insert (format "[%s](%s)" desc uri))))))

You could probably advise the org-roam-node-insert function to automatically execute my-org-convert-link after inserting a link in a TaskPaper buffer by adding something like this (not tested):

(advice-add 'org-roam-node-insert :after #'my-org-convert-link)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants