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

Is it any opportunity to open attached pdf file from bibtex... #20

Open
VolkovIlia opened this issue Oct 25, 2021 · 7 comments
Open

Is it any opportunity to open attached pdf file from bibtex... #20

VolkovIlia opened this issue Oct 25, 2021 · 7 comments
Labels
wontfix This will not be worked on

Comments

@VolkovIlia
Copy link

VolkovIlia commented Oct 25, 2021

I have bibtex file that is generated with link to pdf document (jabref and papers-cli generate it). Is it any opportunity to bind key for opening it while I search it in telescope... ?

@article{amini_rezaei2015,
 author = {Amini, Ehsan and Rezaei, Mehran},
 doi = {10.1016/s1872-2067(15)60922-6},
 file = {:/home/volk/Library/PDFs/2015/amini_rezaei2015.pdf:pdf},
 journal = {Chinese Journal of Catalysis},
 month = {10},
 number = {10},
 pages = {1711-1718},
 publisher = {Elsevier BV},
 title = {Preparation of mesoporous Fe-Cu mixed metal oxide nanopowder as active and stable catalyst for low-temperature CO oxidation},
 url = {http://dx.doi.org/10.1016/s1872-2067(15)60922-6},
 volume = {36},
 year = {2015}
}
@noahares
Copy link
Collaborator

If telescope supports specifying result-sensitive actions this should be possible.
However this is not a feature I have in mind for this plugin (at least right now, as I am busy doing other stuff and development of new features for this project is paused). I might look into it another time if more such actions come up. For now I see this more as a hack for a very specific use-case.

You can implement it yourself and then either open a PR or use it locally, of course.

@noahares
Copy link
Collaborator

I would start here: telescope docs under replace_if. There you can specify the condition and change the action.

@noahares noahares added the wontfix This will not be worked on label Nov 27, 2021
@erooke
Copy link
Contributor

erooke commented Jan 24, 2022

I have bodged together an implementation for this over at https://github.com/erooke/telescope-bibtex.nvim/tree/open-file. Simply specify the pdf reader in the config:

require('telescope').setup {
  extensions = {
    bibtex = {
      reader = { 'evince' },
    }
  }
}

then call Telescope bibtex open and select what you want opened.

Currently has a quirk where if you close the terminal hosting vim before closing vim the reader closes. I'm not sure how to stop that happening.

@noahares
Copy link
Collaborator

noahares commented Jan 24, 2022

This looks good. How exactly is the format of the file field in the entry?
To solve the problem of the viewer closing: plenary.Job takes a table of arguments to pass to libUV.
LibUV has the option detached which acts like a disown and would keep the viewer alive even after neovim exits.
(see options after uv.spawn(...) at libUV

@erooke
Copy link
Contributor

erooke commented Jan 24, 2022

This looks good. How exactly is the format of the file field in the entry?

That is a great question I wish I had an answer to. I was unable to find a good description of what was going on. The following is my best guess based on searching through all the bib files in the jabref repository:

  • It is a ; separated list of files
  • Each entry in the list is of the form name:location:filetype
    • The filetype is very much a guess as they don't have any which are non-pdfs in their tests
    • The name seems to be mainly to differentiate supplementary material related to the entry
    • the location need not be on disk for example: file = {:http\://arxiv.org/pdf/2003.05580v3:PDF}

The current implementation deals with very little:

  • it assumes there is only one file associated with each entry. Because of this it ignores the name of the file.
  • it assumes the file type is pdf
  • it assumed the file lives on disk

For my use case all of that is true but it's the main reason I hadn't submitted it as a pull request yet as it feels too hacky at the moment.

@erooke
Copy link
Contributor

erooke commented Jan 24, 2022

For what its worth helm-bibtex has implemented this feature. They support:

  • File = {/path/to/article.pdf}
  • File = {:/path/to/article.pdf:PDF}
  • File = {:/path/to/article.pdf:PDF;:/path/to/supplementary_materials.pdf:PDF}

as file specifications.

@anandkumar89
Copy link

I've proposed a reply here :
#73 (comment)

uses mappings to add this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

4 participants