Giter Site home page Giter Site logo

Comments (10)

tmalsburg avatar tmalsburg commented on May 17, 2024

Yes, you have to modify helm-bibtex-find-pdf. This should work:

(defun helm-bibtex-find-pdf (key)
  "Searches in all directories in `helm-bibtex-library-path' for
a PDF whose name is the name specified in the ’file’ property of the
BibTeX entry or whose name is KEY + \".pdf\".  Returns the first
matching PDF."
  (let* ((entry (helm-bibtex-get-entry key))
         (fname (helm-bibtex-get-value "File" entry))
         (files1 (--map (f-join it fname) (-flatten (list helm-bibtex-library-path))))
         (files2 (--map (f-join it (s-concat key ".pdf")) (-flatten (list helm-bibtex-library-path)))))
    (-first 'f-exists? (append files1 files2))))

from helm-bibtex.

tmalsburg avatar tmalsburg commented on May 17, 2024

My code works when the content of the "file" field is just the bare name of the pdf file without directory. This pdf file is then searched in the directories specified in helm-bibtex-library-path. In order to make it work with the format that you have, you have to make some changes.

from helm-bibtex.

rdiaz02 avatar rdiaz02 commented on May 17, 2024

Thanks a lot. I'll work from that; I might also have to reorganize where directories with PDFs hang from, to make the search or the parsing of the directory easier. I just tried it, and I am getting Variable binding depth exceeds max-specpdl-size even if the pdf is present in the usual way (KEY + pdf); this is a directory with over 4000 subdirectories.
Since the question is basically answered (tweak helm-bibtex-find-pdf to suit the specific needs) I am closing the issue. If/when I am able to get it to work, I'll report back.

from helm-bibtex.

tmalsburg avatar tmalsburg commented on May 17, 2024

Not sure about the error message (which I don’t get on the current development version of Emacs) but you can try the following variant:

(defun helm-bibtex-find-pdf (key)
  "Searches in all directories in `helm-bibtex-library-path' for
a PDF whose name is KEY + \".pdf\".  Returns the first matching PDF."
  (let* ((entry (helm-bibtex-get-entry key))
           (fname (helm-bibtex-get-value "File" entry))
                 (files1 (-map (lambda (it) (f-join it fname)) (-flatten (list helm-bibtex-library-path))))
                 (files2 (-map (lambda (it) (f-join it (s-concat key ".pdf"))) (-flatten (list helm-bibtex-library-path)))))
        (-first 'f-exists? (append files1 files2))))

This replaces --map with -map because --map used to make problems in older versions of Emacs. (Which version are you using?)

from helm-bibtex.

rdiaz02 avatar rdiaz02 commented on May 17, 2024

Thanks. That does not lead to any problems or errors. I am using version 24.4.1 (from Debian). I still will need to tweek it, because of the format of the file name (with paths, : and other such things ---they way JabRef or Mendely export them, but that ebib will not handle gracefully, for example).

from helm-bibtex.

tmalsburg avatar tmalsburg commented on May 17, 2024

You can use s-split to extract the part between the colons:

(car (s-split ":" ":home/ramon/a_directory/some_file_123.pdf:PDF" t))

But the path is not complete (it starts at home) so you have to prepend the path to home before using it.

from helm-bibtex.

rdiaz02 avatar rdiaz02 commented on May 17, 2024

Thanks, I didn't know about s-split. Prepending a / to home/ramon should be fairly simple with sed on the bib file.

from helm-bibtex.

tmalsburg avatar tmalsburg commented on May 17, 2024

In Emacs you can do:

(s-concat "/" path)

from helm-bibtex.

rdiaz02 avatar rdiaz02 commented on May 17, 2024

Ooops. Thanks. (Did I say I know no elisp?)

from helm-bibtex.

tmalsburg avatar tmalsburg commented on May 17, 2024

No problem ;-)

from helm-bibtex.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.