tmalsburg/helm-bibtex

supressing warnings

Closed this issue · 6 comments

Sometimes when opening an org-file I get a Warnings buffer with entries like:

Warning (:warning): Bibtex-completion couldn't find entry with key "core-1999-error".

although sometimes it also looks like this

Warning (:warning): Bibtex-completion couldn't find entry with key "//doi.org/10.1021/acs.jpcc.6b12752"

I am pretty sure this comes from bibtex-completion-get-entry1. I would like to just suppress this warning and not see it, because it seems like every time the citation gets fontified the warning buffer pops up which is disruptive. Is there a way to prevent that?

I also can't figure out where this is getting called. Is it in an org-mode-hook somewhere?

Thanks

I don't understand under which circumstances this happens. You say it happens when you open any org-file? Seems strange because opening org-files should not involve bibtex-completion at all (i.e., nothing is added to any org-mode hook).

The warning message occurs when some code tries to retrieve a BibTeX entry that doesn't exist. Of course we could just deactivate the warning, but the warning suggests that there is a bug somewhere else and it would be good to pin down and fix that bug. You could replace the warning by an error (perhaps better independently of this issue?) and then inspect the stack trace when it happens.

I think I understand what is happening. It only happens when org-ref is fontifying citations. It looks like sometimes the bibtex-completion-bibliography is not set correctly for the file, so some keys are not found, and there must be some funny regexp patterns somewhere that are triggering things like the url piece above. org-ref does some lexical-let binding of some variables, and I have directory-local variables for bibliographies set in some of these files too. I will dig around and see if it can be resolved.

I would still find it nice to suppress the warning, sometimes we have files with bad cites in them, and it is still annoying to have the warning buffer pop up everytime we scroll by them.

Update If I add (hack-local-variables) into the font-lock function that uses bibtex-completion, then the warnings go away, but I get a new message about:

File mode specification error: (error Variable binding depth exceeds max-specpdl-size)
File local-variables error: (error Variable binding depth exceeds max-specpdl-size)

So I guess it is related at least in part to the use of directory/file local variables here.

Update 2 This seems to solve the issue for at least one file, and the part related to missing keys.

  (hack-dir-local-variables)
  (hack-local-variables-apply)

I am not sure what would be causing the issue related to partial urls and other things. If I come across it again I will dig in then.

It's not clear you need to do anything in this library, so feel free to close this if you want.

Okay, thanks for the update. By the way, I think you could have suppressed the warnings by temporarily setting warning-minimum-log-level to :error.

That does indeed work. Thanks. I had tried something like that with warning-suppress-types before, but it seemed to not work. This worked fine I think.

I'm having this problem as well. It happens when I'm typing a cite: link manually, org-ref-cite-link-face-fn gets called to check if the key exists so it can change the link from the invalid face to the valid face. But this gets called with every character entered, so even when I type a valid link I still get:

Warning (:warning): Bibtex-completion couldn't find entry with key "J".
Warning (:warning): Bibtex-completion couldn't find entry with key "Ji".
Warning (:warning): Bibtex-completion couldn't find entry with key "Jia".
Warning (:warning): Bibtex-completion couldn't find entry with key "Jian".
Warning (:warning): Bibtex-completion couldn't find entry with key "Jiang".
Warning (:warning): Bibtex-completion couldn't find entry with key "Jiang2".
Warning (:warning): Bibtex-completion couldn't find entry with key "Jiang20".
Warning (:warning): Bibtex-completion couldn't find entry with key "Jiang201".

every time, which is a lot of noise. It happens additionally in org-ref-format-entry whenever the cursor is over an invalid link.

I could file an issue in org-ref, but I feel like the problem is really with the bibtex-completion-get-entry function. It seems like it should be expected that this function will frequently fail to lookup the key under normal operation. Both functions in org-ref assume this is the case, recognize when it returns nil and communicate this information to the user effectively (by setting the face on an invalid link or displaying "!!! No entry found !!!" in the message bar instead of the formatted citation). I don't think the warning gives any useful information to either package developers or users.

It is possible to suppress this with (setq warning-minimum-log-level :error) as @tmalsburg noted above.