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

org-ref-get-bibtex-key-under-cursor returns nil instead of a list of keys #1097

Open
mlemerre opened this issue Oct 23, 2023 · 4 comments
Open

Comments

@mlemerre
Copy link

Hello,

First, thanks for org-ref!

I have investigated a problem that bugged me for a while, which is that when I click on a reference, I have a hydra menu that gets opened, but most commands fails with a "wrong argument nil".

I have investigated the problem which seems to be that the org-ref-get-bibtex-key-under-cursor returns nil (as it ends execution with a prog1) instead of a list of keys, as expected e.g. by its caller org-ref-open-notes-at-point.

It seems quite easy to fix the code but I wonder how this problem has been unnoticed for so long; maybe for most people the (get-text-property 'cite-key) function gets triggered, so maybe there is a problem in my config? Or do people never use there mouses to click on citations?

@mlemerre
Copy link
Author

As a temporary workaround I replaced
(prog1
(get-text-property (point) 'cite-key)

with
(prog1
(car keys)

but I guess this will fail when I use multiple citations. There seems to be a problem with this code, but I fail to understand the overall architecture.

@mlemerre
Copy link
Author

I found out that I add (setq org-ref-activate-cite-links nil) in my config, which explains why in general the bug is not triggered. Still, the bug remains if this option is set.

@jkitchin
Copy link
Owner

(setq org-ref-activate-cite-links nil) will make this problem happen because it relies on (get-text-property (point) 'cite-key) to work, and this is set during activation.

I think the way this works is the following. You can click on different parts of the link that have to be handled. First, if there is a 'cite-key property then you are on an activated citation. If not, it could mean you click on the cite type, then it gets the keys, and if there is one, searches forward to it, and if there are many, it prompts you to choose one, then searches forward to what you select. Then, it tries to get the 'cite-key property (which should exist if it was activated). org-ref-activate-cite-links should default to t, and you would only turn it off for performance reasons if there are so many cites you see things slow down.

@jkitchin
Copy link
Owner

see e8518f4, I think it makes this a little more robust.

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