Giter Site home page Giter Site logo

Comments (6)

tmalsburg avatar tmalsburg commented on May 17, 2024

Wouldn't it be better to generate a link of the following form?:

** [[/home/julian/Documents/Refs/Lurton2015.pdf][Backscatter measurements by seafloor-mapping sonars]] 

Or do you really need to see the Bibtex-key?

The code for the citation format above is:

    (defun helm-bibtex-format-citation-my-org-link-to-PDF (keys)
      "Formatter for org-links to PDF.  Uses first matching PDF if
    several are available.  Entries for which no PDF is available are
    omitted."
      (s-join ", " (-non-nil
                    (--map (when (cdr it)
                               (format "[[%s][%s]]"
                                       (car it)
                                       (helm-bibtex-get-value "title" (cdr it))))
                           (--map (cons (helm-bibtex-find-pdf it)
                                        (helm-bibtex-get-entry it)) keys)))))

    (setq helm-bibtex-format-citation-functions
      '((org-mode      . helm-bibtex-format-citation-my-org-link-to-PDF)
        (latex-mode    . helm-bibtex-format-citation-cite)
        (markdown-mode . helm-bibtex-format-citation-pandoc-citeproc)
        (default       . helm-bibtex-format-citation-default)))

from helm-bibtex.

jmburgos avatar jmburgos commented on May 17, 2024

Thanks Titus! The Bibtex key would be useful because it gives me the first author and year of publication. Could you add it?

from helm-bibtex.

tmalsburg avatar tmalsburg commented on May 17, 2024

Here ya go:

(defun helm-bibtex-format-citation-my-org-link-to-PDF (keys)
  "Formatter for org-links to PDF.  Uses first matching PDF if
several are available.  Entries for which no PDF is available are
omitted."
  (s-join ", " (-non-nil
                (--map (when (cdr it)
                         (format "[[%s][%s]] %s"
                                 (car it)
                                 (helm-bibtex-get-value "=key=" (cdr it))
                                 (helm-bibtex-get-value "title" (cdr it))))
                       (--map (cons (helm-bibtex-find-pdf it)
                                    (helm-bibtex-get-entry it)) keys)))))

from helm-bibtex.

jmburgos avatar jmburgos commented on May 17, 2024

Thanks again! One last question. I would like to have this as an action, rather than the default citation format in org mode (because most of the time I use LaTex citations in org-mode). In other words, I would like to call helm-bibtex, select a reference, press TAB, and see "Insert link to pdf and title" as one of the possible actions. That is why I was trying to make a function similar to helm-bibtex-insert-key. I suspect cannot just modify helm-source bibtex as below, calling helm-bibtex-format-citation-my-org-link-to-PDF as one of the actions, right?

(defvar helm-source-bibtex
'((name . "BibTeX entries")
(init . helm-bibtex-init)
(candidates . helm-bibtex-candidates)
(filtered-candidate-transformer . helm-bibtex-candidates-formatter)
(action . (("Open PDF file (if present)" . helm-bibtex-open-pdf)
("Insert link to pdf and title" . Helm-bibtex-format-citation-my-org-link-to-PDF) ; NEW ACTION
("Open URL or DOI in browser" . helm-bibtex-open-url-or-doi)
("Insert citation" . helm-bibtex-insert-citation)
("Insert reference" . helm-bibtex-insert-reference)
("Insert BibTeX key" . helm-bibtex-insert-key)
("Insert BibTeX entry" . helm-bibtex-insert-bibtex)
("Attach PDF to email" . helm-bibtex-add-PDF-attachment)
("Edit notes" . helm-bibtex-edit-notes)
("Show entry" . helm-bibtex-show-entry))))
"Source for searching in BibTeX files.")

from helm-bibtex.

tmalsburg avatar tmalsburg commented on May 17, 2024

Hi Julian, sorry I don't have time to deal with this. You have to create a new function similar to helm-bibtex-insert-citation and add it as an action to the source. Perhaps a good opportunity to get your feet wet. Basic Elisp knowledge will allow you to get much more out of Emacs, so it should be worth your time.

from helm-bibtex.

jmburgos avatar jmburgos commented on May 17, 2024

Ok, fair enough. :) I will dive into this. Many thanks for your help!

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.