org-roam / org-roam-ui

A graphical frontend for exploring your org-roam Zettelkasten
GNU General Public License v3.0
1.96k stars 108 forks source link

Support for org-cite links #55

Open sinnpi opened 3 years ago

sinnpi commented 3 years ago

org has recently added org-cite into it's release[1], and org-roam-ui currently does not seem to render those cite-links. I'm not sure if this is something that org-roam-ui gets out of the org-roam db, or if it's something that needs to be fixed here, but I figured I'd open an issue for it anyways.

[1] https://blog.tecosaur.com/tmio/2021-07-31-citations.html

blester125 commented 3 years ago

org-roam-ui currently gets (or derives) all link information from what is in the org-roam db, it never looks at actual org files. Once org-roam supports org-cite links and has them in the db we'll be able to show them. I'm super excited for org-cite too and can't wait for support in packages like org-ref, org-roam, and org-roam-bibtex!

tefkah commented 3 years ago

This has been implemented in the latest commit!

OmarAshkar commented 3 years ago

I can't see any cite links. I am supposed to only add cite:key to roam file right? If there is an example I'd be grateful.

tefkah commented 3 years ago

Hmmmm I'm not actually sure if that's enough on its own or whether you need org-roam-bibtex as well. I would think it is, since org-roam should just pick those up naturally, and we should be able to display cite links without a corresponding org-roam node. Could you share what you are (not) seeing?

An example node would look like this for me

:PROPERTIES:
:ID:       31cd49eb-770f-4d11-98b2-ca666b534201
:mtime:    20210930124248 20210820044947
:ctime:    20210218152909
:END:
#+title: Anyons
#+filetags: physics phase fqhe anyons definition

* Anyons
:PROPERTIES:
:mtime:    20210930124248
:END:

Anyons are quasiparticles exhibiting , first proposed by cite:Wilczek1991  They are particles for which holds that

\[ \Psi_\theta = \exp{i\theta}\Psi_0 \quad 0\leq\theta\leq2\pi \]

This is very different from [[id:9945ee0-4f04-419b-8680-e45203302491][fermions]] and [[id:edcab4d4-3171-4b32-9833-451bfc53bafa][bosons]], for which $\theta=\mp1$ respectively. Anyons can thus be seen as a kind of generalization of fermions and bosons.

With the view looking like this

image
OmarAshkar commented 3 years ago

So, do I have to have a note as roam node itself to get that working or it can be a reference to paper without a note? I use bibtex-actions with org-cite now, not org-ref.

tefkah commented 3 years ago

You shouldn't need to have a node, the linked paper there does not have a corresponding node for instance, but was indeed made with org-ref.

There is a toggle to show these nodes in the "Filter" settings though, maybe you have that turned on?

tefkah commented 3 years ago

Hmm no it does seem to be a deeper issue. I confess that I don't know much about how the new org-cite system is supposed to work and how org-roam should pick up those citations, but it doesn't "just" pick them up by default.

If i have a file like

* Some headline
[cite:@SomeKey2021]

it does not show up in the org-roam database. Maybe the key has to actually be picked up by org? Any hints would be very welcome!

tefkah commented 3 years ago

Even with a key that is picked up by org-cite, the key still does not get picked up by org-roam, so it is probably an issue there. I will investigate.

dheffels commented 2 years ago

Are there any new developments on this topic?

I use citar with Doom Emacs biblio module.

Citations nodes look like this : Screenshot 2022-06-10 at 01-26-07 ORUI

And the sidebar of the node: Screenshot 2022-06-10 at 01-26-29 ORUI

dheffels commented 2 years ago

Taking org-roam-bibtex as inspiration, maybe the following would be an acceptable solution?


(defcustom org-roam-ui-ref-format 'org-ref-v2
  "Defines the format of citation key in the `ROAM_REFS' property.
Should be one of the following symbols:
- `org-ref-v2': Old Org-ref `cite:links'
- `org-ref-v3': New Org-ref `cite:&links'
- `org-cite'  : Org-cite `@elements'
This can also be a custom `format' string with a single `%s' specifier."
  :type '(radio
          (const :tag "Org-ref v2" org-ref-v2)
          (const :tag "Org-ref v3" org-ref-v3)
          (const :tag "Org-cite" org-cite)
          (string :tag "Custom format string"))
  :group 'org-roam-ui)

(setq! org-roam-ui-ref-format 'org-cite)

(defun format-citekey (citekey)
  "formate citekey"
(format
 (pcase org-roam-ui-ref-format
   ('org-ref-v2 "cite:%s")
   ('org-ref-v3 "cite:&%s")
   ('org-cite "@%s")
   ((pred stringp) org-roam-ui-ref-format)
   (_ (user-error "Invalid format `org-roam-ui-ref-format'")))
 citekey))

(defun org-roam-ui--create-fake-node (ref)
  "Create a fake node for REF without a source note."
  (list
   ref
   ref
   (org-roam-ui--find-ref-title ref)
   0
   0
   'nil
   `(("ROAM_REFS" . ,(format-citekey ref))
     ("FILELESS" . t))
   'nil))

(Please excuse if the code violates any conventions I am just starting to learn elisp.)