emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Georg W. Otto" <g.otto@ucl.ac.uk>
To: emacs-orgmode@gnu.org
Subject: Re: org-ref file path to pdf
Date: Tue, 13 Dec 2016 18:59:11 +0000	[thread overview]
Message-ID: <861sxb8xkw.fsf@georgotto.de> (raw)
In-Reply-To: m2bmwl6ehg.fsf@Johns-MacBook-Air.local

John Kitchin <jkitchin@andrew.cmu.edu> writes:

> I just pushed a feature that might get you back what you want.
>
> You can now put [[file:%F][%f]] in the org-ref-note-title-format
> variable, and it will put (concat org-ref-pdf-directory key ".pdf") in
> for %F, and (concat key ".pdf") in for %f. There is unfortunately, no
> check if the pdf actually exists though.
>
> A second option is to write a function to add to a new hook variable:
> org-ref-create-notes-hook
>
> There is an example function in that that adds a cite link (which can
> open a pdf), but if you wanted to you could write a function that would
> add a file link to a pdf if it could find one.

Thanks a lot, this is really helpful. As you suggested I added a
function to org-ref-create-notes-hook in my init file:

(defun org-ref-add-note-pdf()

  (setq pdf (concat org-ref-pdf-directory key ".pdf"))
	    
  (if (file-exists-p pdf)
      
      (insert (format "[[file:%s][pdf]]\n\n" pdf))

    ;; no pdf found. Prompt for a path, but allow no pdf to
    ;; be inserted.
    (let ((pdf (read-file-name "PDF: " nil "no pdf" nil "no pdf")))
      (when (not (string= pdf "no pdf"))
	(insert (format
		 " [[file:%s][pdf]]\n\n"
		 pdf))))
    )
  )

(add-hook 'org-ref-create-notes-hook 'org-ref-add-note-pdf)


This formats the pdf link as intended.

My question now concerns the citation link that is defined in the lambda
function in org-ref-create-notes-hook. I might want to override this
lambda function with my own hook function in order to change the format
of the citation link. I haven't found a way to override a lambda
function, though. Can you give me a hint how this is done?

Cheers,

Georg

      reply	other threads:[~2016-12-13 18:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-06 12:36 org-ref file path to pdf Georg W. Otto
2016-12-07 15:03 ` John Kitchin
2016-12-07 18:13   ` Georg W. Otto
2016-12-09  2:08     ` John Kitchin
2016-12-13 18:59       ` Georg W. Otto [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=861sxb8xkw.fsf@georgotto.de \
    --to=g.otto@ucl.ac.uk \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).