org-roam / org-roam-bibtex

Org Roam integration with bibliography management software
GNU General Public License v3.0
565 stars 47 forks source link

New function orb-open-associated-note #238

Closed premopie closed 2 years ago

premopie commented 2 years ago

New function orb-open-associated-note according with https://github.com/org-roam/org-roam-bibtex/issues/191#issuecomment-1011875176

myshevchuk commented 2 years ago

I rephrased the docstring and messages to conform with Emacs standards (fill-column, double space, no trailing punctuation in errors) and made the function interactive. Otherwise it works perfectly. Thank you!

samspo commented 2 years ago

orb-edit-citation-note doesn't work for me. It says 'cursor not in a org-cite element'. In my org-roam-bibtex config, I have: (setq orb-roam-ref-format 'org-cite)

myshevchuk commented 2 years ago

@sampso

orb-edit-citation-note should be called when the point is on an Org-cite [cite:@citekey] citation. However, it will not work if the citation is within a property drawer, e.g. in ROAM_REFS - that's a limitation imposed by Org syntax. It will work anywhere else in the buffer.

In my org-roam-bibtex config, I have: (setq orb-roam-ref-format 'org-cite)

That plays no role for this function. It is for Org-cite citation anywhere in Org documents, except of property drawers as per above.

samspo commented 2 years ago

Thanks for the follow-up. Of course I'm on an org-cite citation. I'm not in a property drawer either. I have no idea why it doesn't work. Might be a problem in my config.

premopie commented 2 years ago

@samspo try to move cursor on the Org mode citation and eval there (using M-:) the org-element-context function. Confirm that you can see (in messages) a list starting with citation or citation-reference. You should see this if you have Org 9.5 org newer.

myshevchuk commented 2 years ago

@samspo I went too far in my assumptions. You mentioned orb-roam-ref-format which is only responsible for setting the citation as a ROAM_REFS key in the properties drawer. So I related that to orb-edit-citation-note not recognizing Org-cite citations.

Must indeed be something with your setup. Try `M-x load-library org-cite'.

samspo commented 2 years ago

Thanks @premopie and @myshevchuk Yes. My org-version is Version: 9.5.2 but there is a problem with org-element-context in my config. I must investigate that. Side note: @myshevchuk I understand now that orb-roam-ref-format is only responsible for setting the citation as a ROAM_REFS key in the properties drawer. From a user perspective, it would make sense that this variable also allows to customize the format of the links recognized by orb-edit-citation-note

myshevchuk commented 2 years ago

From a user perspective, it would make sense that this variable also allows to customize the format of the links recognized by orb-edit-citation-note

I must disagree. orb-roam-ref-format has nothing to do with orb-edit-citation-note. It's easy to run out of good names for Elisp symbols and I don't particularly like the 'format' part, but the orb-roam-ref part is what it is - a style/format of ROAM_REFs inserted by ORB.

orb-edit-citation-note does not require any control variables - it should work with/on citations, more specifically it should process a citation, retrieve the key and launch ORB's edit note functionality. Currently it only works with Org-cite citations, but it should definitely be expanded to work Org-ref citations too. There is simply no need for a control variable: if a user runs this command when not on a citation, then do nothing. If the point is on a citation element then do what the function's name implies.

samspo commented 2 years ago

Ok. Thanks for the follow-up