cpitclaudel / biblio.el

Browse and import bibliographic references from CrossRef, DBLP, HAL, arXiv, Dissemin, and doi.org from Emacs
GNU General Public License v3.0
185 stars 15 forks source link

Feature Request: inspirehep search #51

Open sbilmis opened 2 years ago

sbilmis commented 2 years ago

Hi, I just discovered this very useful package.

Is it possible to add InspireHEP like arXiv? (https://inspirehep.net/?ln=en )

aikrahguzar commented 2 years ago

@sbilmis inspire has a very nice JSON api and I started to write an inspire backend for biblio using it. But as I wanted it to work differently in many small ways and didn't need the other backends I ended up ripping parts from the biblio I needed. The code is here https://github.com/aikrahguzar/inspirehep.el and a biblio backend can be extracted from it relatively easily.

cpitclaudel commented 2 years ago

@aikrahguzar Remember to keep the ;; Copyright (C) 2016 Clément Pit-Claudel statements if you kept the code ^^. Any chance you could contribute the small changes back? I'd love to see the improvements propagate to the other backends as well.

aikrahguzar commented 2 years ago

@aikrahguzar Remember to keep the ;; Copyright (C) 2016 Clément Pit-Claudel statements if you kept the code ^^.

@cpitclaudel Thanks! I added back the statement.

Regarding small changes most of them would require changing how the backends are defined. For example if there are multiple pages of results, it fetches them one by one and inserts them in the buffer.

Other are just adjusting to my workflow and might not be generally useful: for example I wanted to see the abstract in the results so I added that.

There are some that I am more positive might be generally useful: the one I can think of right away is setting the target buffer based on the buffer the search was started from. For example if it was a latex buffer, use reftex to find the bib file being used and set that as the target buffer and set the current buffer as the target buffer only if is a bibtex buffer. If you think that is useful I can send a pr to adding a defcustom enabling such behavior and surrounding changes in a week or two.

I has been a while since I used biblio.el itself so I am forgetting where the differences actually are but it was a very solid base to start messing around and I am still mostly an emacs novice so thanks for that.

cpitclaudel commented 2 years ago

For example if there are multiple pages of results, it fetches them one by one and inserts them in the buffer.

That sounds super useful, actually. Do you have a "next page"/"load more" command, or do you load everything at once? A pagination API would definitely be good to have, and I bet it could be added in a backwards compatible way.

the one I can think of right away is setting the target buffer based on the buffer the search was started from.

Yep, sounds super useful as well. I would do that with hook functions (run-hook-with-args-until-success)

aikrahguzar commented 2 years ago

That sounds super useful, actually. Do you have a "next page"/"load more" command, or do you load everything at once? A pagination API would definitely be good to have, and I bet it could be added in a backwards compatible way.

There is a next-page command but depending upon the value of a custom variable, this command to fetch the next page is triggered when a page is inserted in the results buffer. There are checks to make sure results aren't inserted in the buffer if they arrive after a query change. I like this behavior since it doesn't block (except momentarily when a page arrives) and if there are lot of results searching from within emacs is better.

I think the one change backends will have to do is to somehow tell biblio what the next page to fetch is. It can be done in a backwards compatible fashion with some effort I think.

Yep, sounds super useful as well. I would do that with hook functions (run-hook-with-args-until-success)

I just used a function for the type of defcustom but this is better. I will prepare a pr to do this soonish. Some other related changes I have are a predicate for read-buffer (probably should also be customizable) in the function for interactively selecting the target buffer and getting the target buffer from a file if called with a prefix arg. I can add those to the pr too.