jkitchin / org-ref

org-mode modules for citations, cross-references, bibliographies in org-mode and useful bibtex tools to go with it.
GNU General Public License v3.0
1.36k stars 243 forks source link

Tooltip on citation references #915

Closed deb75 closed 2 years ago

deb75 commented 3 years ago

If I introduce a reference like this :

cite:&mykey2021

when I put the cursor or the mouse on it, nothing show up, neither tooltip nor something in the minibuffer.

According to the latest documentation, does something should appear ?

I remember I could at least see the full reference in the minibuffer with org-ref version 2.

Regards

Windows 10 - emacs 29.0.50

jkitchin commented 3 years ago

You should definitely see tooltips. I see them on my end.

  1. what color is the cite link?
  2. if you click on it, do you get the menu?
  3. if you turn off native-compiling for all org-ref files, does it work?
deb75 commented 3 years ago

With the latest org-ref (previous issues fixed, thanks :-) ) :

  1. with doom-solarized-dark the cite link is yellow/gold
  2. yes, clicking on it opens the menu
  3. still no tooltips with removing all native compiled org-ref files.

Do you work on Linux or on Windows 10 ?

EDIT : also, there are no error or warning messages appearing.

jkitchin commented 3 years ago

I work on a mac.

  1. yellow/gold doesn't sound right, it should be forest green (maybe that looks yellow/gold?) unless you changed the color. If you delete a char in the link, it should turn red.

  2. The tooltip is generated by org-ref-cite-tooltip Here is a function you can use interactively, with the point on a cite key. it should show a message in the minibuffer.

#+BEGIN_SRC emacs-lisp
(defun ort ()
  (interactive)
  (message (org-ref-cite-tooltip nil nil (point))))
#+END_SRC
deb75 commented 3 years ago
  1. Deleting a char does not change the color so, yellow/gold means red. Other types of links are indeed close to forest green and, if I remove one character, they turn "red" like the citation link.
  2. I cop/pasted the src block in the org file and then, executed it while the mouse pointer over the citation link. Nothing showed up.

Then, there seem to have an issue with the link itself. However, the menu does appear and works.

Regards

EDIT : launching org-ref in the org file returns indeed :

* Bad citations
- bibkey

What could be the reason for that ? What "bad" means ? Badly formatted in bib file ?

jkitchin commented 3 years ago

Maybe run M-x org-ref in the buffer. It could tell you if you have some issues that are preventing things from working.

For red links there should still be a tooltip, and it should say "Key not found."

if you put your point on a link and run M-x describe-text-properties, you should see something like this

image

deb75 commented 3 years ago

Yes, with describe-text-properties, I see the same thing except that there are no cite-key.

Also, I was wrong, there are some warning appearing when I hover the citation link with the mouse :

Warning (:warning): Bibtex-completion couldn't find entry with key "walsh2019general".
jkitchin commented 3 years ago

that means the error is probably in the bibtex file or configuration of bibtex-completion.

What does M-x org-ref tell you?

deb75 commented 3 years ago

org-ref says indeed there is a bad citation, but does not explain what is bad

Here is my configuration :

(setq bibtex-completion-bibliography (list (concat local-org-ref-directory "/bibliography.bib")
                                           (concat local-org-ref-directory "/other.bib"))
      bibtex-completion-library-path (list (concat local-org-ref-directory "/other/2021/")
                                           (concat local-org-ref-directory "/article/")
                                           (concat local-org-ref-directory "/book/")
                                           (concat local-org-ref-directory "/phd/"))
      bibtex-completion-notes-path (concat local-org-ref-directory "/notes/")
      bibtex-completion-notes-template-multiple-files "* ${author-or-editor}, ${title}, ${journal}, (${year}) :${=type=}: \n\nSee [[cite:&${=key=}]]\n"

      bibtex-completion-additional-search-fields '(keywords)
      bibtex-completion-display-formats
      '((article       . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*} ${journal:40}")
        (inbook        . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*} Chapter ${chapter:32}")
        (incollection  . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*} ${booktitle:40}")
        (inproceedings . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*} ${booktitle:40}")
        (t             . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*}"))
      bibtex-completion-pdf-field "file"
      bibtex-completion-pdf-symbol "⌘"
      bibtex-completion-notes-symbol "✎"
      bibtex-completion-pdf-open-function 'org-open-file
      bibtex-completion-browser-function 'browse-url-firefox)
jkitchin commented 3 years ago

you can probably click on the message to open the bibtex file, or you should open it and run M-x bibtex-validate which may give you some hint. I guess the problem is there.

deb75 commented 3 years ago

I changed my bibliography file to :

@ARTICLE{smit54,
    AUTHOR = {J. G. Smith and H. K. Weston},
    TITLE = {Nothing Particular in this Year's History},
    YEAR = {1954},
    JOURNAL = {J. Geophys. Res.},
    VOLUME = {2},
    PAGES = {14-15}
}
@BOOK{colu92,
    AUTHOR = {Christopher Columbus},
    TITLE = {How {I} Discovered {America}},
    YEAR = {1492},
    PUBLISHER = {Hispanic Press},
    ADDRESS = {Barcelona}
}

and my org file to :

#+TITLE test

Inserting one citation link works but it is shown red and rog-ref does report it as a bad citation.

I really do not see what can be wrong with my configuration, bib or org file.

Could you explain me how org-ref consider a citation is bad ? That could help me.

Regards

jkitchin commented 3 years ago

It basically checks if the key is a member of what is returned from (org-ref-valid-keys).

that function uses a cache that is getting a list of keys from (bibtex-completion-candidates).

It is pretty weird you can insert keys, and they are shown in red. In the example above, is that bib file in bibtex-completion-bibliography? If not, you need to add a bibliography link in the org-file.

jkitchin commented 3 years ago

Can you check if this is working now? I think the issue was related to the compiled files from MELPA, and some undeclared variables. I think that is fixed now.

deb75 commented 3 years ago

Thanks for the time you take to solve this issue.

Unfortunately, it is still there. I cannot see any tooltip and citation links are still red.

(org-ref-valid-keys) returns

("colu92" "smit54")

and (bibtex-completion-candidates) returns :

(("1492 How I Discovered America Christopher Columbus book colu92  " ("year" . "1492") ("title" . "How {I} Discovered {America}") ("author" . "Christopher Columbus") ("=type=" . "book") ("=key=" . "colu92")) ("1954 Nothing Particular in this Year's History J. G. Smith and H. K. Weston article smit54  " ("year" . "1954") ("title" . "Nothing Particular in this Year's History") ("author" . "J. G. Smith and H. K. Weston") ("=type=" . "article") ("=key=" . "smit54")))

So far to me, these results seem good.

Also, bibtex-completion-bibliography does include the right bib file. How do you add a bibliography link in the org file ?

Regards

deb75 commented 3 years ago

Here are how links appears :

cap1

If I remove the "&" and intentionally make an error, then :

cap3

The link really turns red.

So, I do not know what to think. Links are reported by org-ref as bad citations, but not because they are wrong, as far as I understand.

Regards

jkitchin commented 3 years ago

What version of org-ref are you using?

Can you paste the output of M-x org-ref here?

deb75 commented 3 years ago

Here is the full output of M-x org-ref on the test.org file :

#+title: org-ref report on [[c:/Users/edebry/Documents/test/test.org][test.org]]

org-ref called from c:/Users/xxxx/Documents/test/test.org

* Bad citations
- [[elisp:(progn (switch-to-buffer "test.org") (goto-char 47)(org-show-entry))][smit54]]
- [[elisp:(progn (switch-to-buffer "test.org") (goto-char 29)(org-show-entry))][colu92]]

* Bibliography

- No bibliography style found. This may be ok, if your latex class style sets that up, but if not this is an error. Try adding something like:
    bibliographystyle:unsrt
    at the end of your file.
- [[d:/xxxx/Documents/reference/biblio.bib]] (dialect = biblatex)

* Miscellaneous

- org-latex-prefer-user-labels = t
- bibtex-dialect = biblatex
- biblatex is not required.
- biblatex is not used.
- emacs-version = GNU Emacs 29.0.50 (build 1, x86_64-w64-mingw32)
 of 2021-10-15
- org-version = 9.4.6
- org-ref: Version 3.0
- org-ref.el installed at c:/Users/xxxx/.emacs.d/elpa/org-ref-20211025.1744/org-ref.el
- org-ref-insert-cite-function = org-ref-cite-insert-helm
- org-ref-insert-label-function = org-ref-insert-label-link
- org-ref-insert-ref-function = org-ref-insert-ref-link
- org-ref-cite-onclick-function = (lambda (_) (org-ref-citation-hydra/body))
- org-latex-pdf-process is defined as (latexmk.exe -pdf -f %f)
- natbib is not required.
- natbib is not in org-latex-default-packages-alist or org-latex-packages-alist.
- cleveref is not required.
- cleveref is not in org-latex-default-packages-alist or org-latex-packages-alist.
- bibtex-completion installed = t
- bibtex-completion loaded = t
- org-latex-default-packages-alist
  ("AUTO" "inputenc" t ("pdflatex"))
  ("T1" "fontenc" t ("pdflatex"))
  ("" "graphicx" t)
  ("" "grffile" t)
  ("" "longtable" nil)
  ("" "wrapfig" nil)
  ("" "rotating" nil)
  ("normalem" "ulem" t)
  ("" "amsmath" t)
  ("" "textcomp" t)
  ("" "amssymb" t)
  ("" "capt-of" nil)
  ("" "hyperref" nil)
-  org-latex-packages-alist is nil
- ox-bibtex loaded = nil
- ox-bibtex loaded after org-ref = nil
- ebib loaded = nil
- ebib loaded after org-ref = nil
- cite link definition:
("cite" :complete
 #[128 "\302\300\303\301\"\"\207"
       [org-ref-cite-link-complete
        ("cite")
        apply append]
       6 "

(fn &rest ARGS2)"]
 :follow org-ref-cite-follow :face org-ref-cite-face :help-echo org-ref-cite-tooltip :export
 #[128 "\302\300\303\301\"\"\207"
       [org-ref-cite-export
        ("cite")
        apply append]
       6 "

(fn &rest ARGS2)"]
 :activate-func org-ref-cite-activate)

* LaTeX setup

latex is installed at d:/xxxx/Documents/utils/miktex/texmfs/install/miktex/bin/x64/latex.exe
pdflatex is installed at d:/xxxx/Documents/utils/miktex/texmfs/install/miktex/bin/x64/pdflatex.exe
bibtex is installed at d:/xxxx/Documents/utils/miktex/texmfs/install/miktex/bin/x64/bibtex.exe
biblatex is installed at nil
makeindex is installed at d:/xxxx/Documents/utils/miktex/texmfs/install/miktex/bin/x64/makeindex.exe
makeglossaries is installed at d:/xxxx/Documents/utils/miktex/texmfs/install/miktex/bin/x64/makeglossaries.exe

* Warnings

* Utilities

- [[elisp:(progn (find-file "c:/Users/xxxx/Documents/test/test.org") (ispell))][Spell check document]]
- [[elisp:(progn (find-file "c:/Users/xxxx/Documents/test/test.org") (org-ref))][recheck document with org-ref]]
jkitchin commented 3 years ago

if you go into the elpa/org-ref-20211025.1744 directory, and remove all the .elc files (and probably restart emacs) does it start to work?

deb75 commented 3 years ago

I removed all byte/native comiled files by hand, deleted all ref related packages, killed emacs, started it again and reinstalled previously deleted packages.

Unfortunately, I keep having the same issue : everything seems to work except tooltips and org-ref reports bad citations although I can access them in the bib file.

The first point is that I do not understand why the citations links are reported as bad although (from previous posts) they do exist in org-ref-valid-keys. Could you indicate me how I could debug that ? I would like to put log messages that tell more precisely why citations are reported as bad.

Regards

jkitchin commented 3 years ago

The issue you have is that you don't have tooltips, and M-x org-ref reports them as bad links, right?

Here is an example org file that might help figure things out. Copy this text into a buffer, with the cite at the very beginning. It should start out red, but when you run the first block it will create test.bib, and then the link should turn green.

The next block should only find one key, and the last block is the function that calculates the tool tip. Any differences you see here are likely the place where it is not working.

[[cite:&xiao-2006-size-effec]]

#+BEGIN_SRC emacs-lisp :var tangle=(org-babel-tangle)
(org-ref-find-bibliography)
#+END_SRC

#+RESULTS:
| test.bib |

#+BEGIN_SRC emacs-lisp
(org-ref-valid-keys)
#+END_SRC

#+RESULTS:
| xiao-2006-size-effec |

#+BEGIN_SRC emacs-lisp
(describe-text-properties 8)
(with-current-buffer "*Help*" (buffer-string))
#+END_SRC

#+RESULTS:
#+begin_example
Text content at position 8:

There are text properties here:
  cite-key             "xiao-2006-size-effec"
  face                 org-ref-cite-&-face
  font-lock-multiline  t
  fontified            t
  help-echo            org-ref-cite-tooltip
  htmlize-link         (:uri "cite:&xiao-2006-size-effec")
  keymap               [Show]
  mouse-face           highlight

[back]
#+end_example

#+BEGIN_SRC emacs-lisp
(org-ref-cite-tooltip nil nil 8)
#+END_SRC

#+RESULTS:
: ⌘ Xiao, S., Hu, W., Luo, W., Wu, Y., Li, X., & Deng, H. (2006). Size effect on alloying ability and phase stability of immiscible bimetallic nanoparticles. The European Physical Journal B, 54(4), 479–484. http://dx.doi.org/10.1140/epjb/e2007-00018-6

#+BEGIN_SRC emacs-lisp
(org-ref-bad-cite-candidates)
#+END_SRC

#+RESULTS:

bibliography:test.bib

#+BEGIN_SRC bibtex :tangle test.bib
@article{xiao-2006-size-effec,
  author =   {S. Xiao and W. Hu and W. Luo and Y. Wu and X. Li and H. Deng},
  title =    {Size Effect on Alloying Ability and Phase Stability of
                  Immiscible Bimetallic Nanoparticles},
  journal =  {The European Physical Journal B},
  volume =   54,
  number =   4,
  pages =    {479-484},
  year =     2006,
  keywords = {test, test2},
  doi =      {10.1140/epjb/e2007-00018-6},
  url =      {http://dx.doi.org/10.1140/epjb/e2007-00018-6},
  DATE_ADDED =   {Thu Oct 14 16:45:45 2021},
}
#+END_SRC
deb75 commented 3 years ago

Just upgraded to latest version, I get now the error :

Error (use-package): org-ref/:catch: Symbol’s value as variable is void: org-ref Disable showing Disable logging
Error (use-package): org-ref-helm/:catch: Symbol’s value as variable is void: org-ref Disable showing Disable logging
jkitchin commented 3 years ago

I am unable to reproduce this. I guess it is an issue with something in helm. Maybe try updating helm-core.

I added the configs that work for me at https://github.com/jkitchin/org-ref/tree/master/melpa. If you are cloning org-ref, you should be able to go into that directory, type make helm and I would expect it to work.

deb75 commented 2 years ago

Yes, it is working !

But it still fails, otherwise. The previous issue (":catch:") seems due to native compilation. If I prevent org-ref from being natively compiled, this error goes away.

deb75 commented 2 years ago

The issue you have is that you don't have tooltips, and M-x org-ref reports them as bad links, right?

Here is an example org file that might help figure things out. Copy this text into a buffer, with the cite at the very beginning. It should start out red, but when you run the first block it will create test.bib, and then the link should turn green.

The next block should only find one key, and the last block is the function that calculates the tool tip. Any differences you see here are likely the place where it is not working.

[[cite:&xiao-2006-size-effec]]

#+BEGIN_SRC emacs-lisp :var tangle=(org-babel-tangle)
(org-ref-find-bibliography)
#+END_SRC

#+RESULTS:
| test.bib |

#+BEGIN_SRC emacs-lisp
(org-ref-valid-keys)
#+END_SRC

#+RESULTS:
| xiao-2006-size-effec |

#+BEGIN_SRC emacs-lisp
(describe-text-properties 8)
(with-current-buffer "*Help*" (buffer-string))
#+END_SRC

#+RESULTS:
#+begin_example
Text content at position 8:

There are text properties here:
  cite-key             "xiao-2006-size-effec"
  face                 org-ref-cite-&-face
  font-lock-multiline  t
  fontified            t
  help-echo            org-ref-cite-tooltip
  htmlize-link         (:uri "cite:&xiao-2006-size-effec")
  keymap               [Show]
  mouse-face           highlight

[back]
#+end_example

#+BEGIN_SRC emacs-lisp
(org-ref-cite-tooltip nil nil 8)
#+END_SRC

#+RESULTS:
: ⌘ Xiao, S., Hu, W., Luo, W., Wu, Y., Li, X., & Deng, H. (2006). Size effect on alloying ability and phase stability of immiscible bimetallic nanoparticles. The European Physical Journal B, 54(4), 479–484. http://dx.doi.org/10.1140/epjb/e2007-00018-6

#+BEGIN_SRC emacs-lisp
(org-ref-bad-cite-candidates)
#+END_SRC

#+RESULTS:

bibliography:test.bib

#+BEGIN_SRC bibtex :tangle test.bib
@article{xiao-2006-size-effec,
  author =     {S. Xiao and W. Hu and W. Luo and Y. Wu and X. Li and H. Deng},
  title =  {Size Effect on Alloying Ability and Phase Stability of
                  Immiscible Bimetallic Nanoparticles},
  journal =    {The European Physical Journal B},
  volume =     54,
  number =     4,
  pages =  {479-484},
  year =   2006,
  keywords = {test, test2},
  doi =        {10.1140/epjb/e2007-00018-6},
  url =        {http://dx.doi.org/10.1140/epjb/e2007-00018-6},
  DATE_ADDED =     {Thu Oct 14 16:45:45 2021},
}
#+END_SRC

I did as you advocated.

First, I do not have the same bib file, it is not test.bib but the one settled in my configuration.

Also, when trying to evaluate the last code block, I get the error :

No org-babel-execute function for bibtex!
jkitchin commented 2 years ago

The first cell should make test.bib, via tangling. The point of using this bib file is it should give the same output as shown above. You don't need to run the bibtex cell.

jkitchin commented 2 years ago

I added some tests that suggest tooltips work when org-ref is installed from MELPA. Those tests don't run with native-compilation, but I can't see a problem with emacs29 and native compilation (I think) locally. Are you still seeing a problem with tooltips?

deb75 commented 2 years ago

Hello,

Yes I still have the issue.

I did again the test file you provided me.

Something different appears when executing the third block from beginning :

#+BEGIN_SRC emacs-lisp
(describe-text-properties 8)
(with-current-buffer "*Help*" (buffer-string))
#+END_SRC

which gives me this :

#+RESULTS:
: Text content at position 8:
: 
: 
: There are text properties here:
:   face                 org-drawer
:   font-lock-fontified  t
:   fontified            t
: 
: [back]

instead of

#+RESULTS:
#+begin_example
Text content at position 8:

There are text properties here:
  cite-key             "xiao-2006-size-effec"
  face                 org-ref-cite-&-face
  font-lock-multiline  t
  fontified            t
  help-echo            org-ref-cite-tooltip
  htmlize-link         (:uri "cite:&xiao-2006-size-effec")
  keymap               [Show]
  mouse-face           highlight

[back]
#+end_example

Which version of emacs are you working with ? Is it native compilation enabled ? I should perhaps get the same version as you.

Regards

jkitchin commented 2 years ago

I am using emacs-28 with native-compilation enabled.

Some is wrong with how your org is parsing that document (assuming you used exactly that document, in a new buffer so that the cite is the first thing there and position 8 is actually in the middle of the cite), there is definitely no drawer there. That shouldn't matter though, even if there was, there should be those properties.

deb75 commented 2 years ago

Yes, new buffer and first line is cite:...

I have emacs 29 (master), I will turn back to emacs-28.

jkitchin commented 2 years ago

It works fine for me with GNU Emacs 29.0.50 (build 1, x86_64-apple-darwin20.6.0, NS appkit-2022.60 Version 11.5 (Build 20G71)) of 2021-10-26

deb75 commented 2 years ago

Hello,

I located where comes from this issue, it is from my configuration, the culprit is this line:

(use-package dap-mode :after lsp-mode :config (dap-auto-configure-mode))

If I remove it, I can see the tooltip in upper test.org file. If I put it again, I do no more see it.

I wonder what is behind this line and why it interacts badly with tooltips.

Regards

jkitchin commented 2 years ago

Hm, thanks for doing the detective work to figure that out. I have not heard of dap-mode. I am not sure what it would be doing, maybe it advises or monkeypatches parts of the tool tip / help echo code. It sounds like we can close this issue.

deb75 commented 2 years ago

For anyone runnning into this issue, it can be solved on the dap-mode side with :

(use-package dap-mode
     :after lsp-mode
     :init
      (setq dap-auto-configure-features '(sessions locals breakpoints expressions controls))
     :config (dap-auto-configure-mode))

Original value of dap-auto-configure-features is (sessions locals breakpoints expressions controls tooltip). I removed tooltip from the list.

But this is only a temporary workaround, I will open an issue to dap-mode. So far I understand, there are no reasons for this to last.

Regards

Paethon commented 2 years ago

Thanks! I had exactly the same problem because of dap-mode!