[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] org-ref file path to pdf
From: |
Georg W. Otto |
Subject: |
Re: [O] org-ref file path to pdf |
Date: |
Tue, 13 Dec 2016 18:59:11 +0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
John Kitchin <address@hidden> 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