emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-ref file path to pdf
@ 2016-12-06 12:36 Georg W. Otto
  2016-12-07 15:03 ` John Kitchin
  0 siblings, 1 reply; 5+ messages in thread
From: Georg W. Otto @ 2016-12-06 12:36 UTC (permalink / raw)
  To: emacs-orgmode



Dear all,


This is probably something that has come up before, but so far I haven't
found a solution:

My problem concerns automatic file path expansion in my org-ref
setting. According to the instructions in

https://github.com/jkitchin/org-ref
and
https://www.reddit.com/r/emacs/comments/4gudyw/help_me_with_my_orgmode_workflow_for_notetaking/

I set up the paths to my bibliography, my notes and my pdfs like this:

(setq org-ref-bibliography-notes "~/Dropbox/bibliography/notes.org"
      org-ref-default-bibliography '("~/Dropbox/bibliography/references.bib")
      org-ref-pdf-directory "~/Dropbox/bibliography/bibtex-pdfs/")


Navigation to a bibtex entry and running org-ref-open-bibtex-notes
creates an orgmode heading in notes.org that contains a link to the pdf
file of the publication. Unfortunately, that link uses an expanded file
path, i.e:
/home/<username>/Dropbox/bibliography/bibtex-pdfs/BibtexKey.pdf

so it is useless when generated by a different user. Would it be
possible to create a link that does not expand the file path, like this

~/Dropbox/bibliography/bibtex-pdfs/BibtexKey.pdf

I appreciate your help.

Georg

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: org-ref file path to pdf
  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
  0 siblings, 1 reply; 5+ messages in thread
From: John Kitchin @ 2016-12-07 15:03 UTC (permalink / raw)
  To: Georg W. Otto; +Cc: emacs-orgmode

This doesn't sound like something that should be happening I think. How
current is your org-ref?

I do not use the notes feature so it does not get tested too often. You
may be able to control the format of the notes created with the variable
org-ref-note-title-format if you are using the default notes function
that adds a headline. 


Georg W. Otto writes:

> Dear all,
>
>
> This is probably something that has come up before, but so far I haven't
> found a solution:
>
> My problem concerns automatic file path expansion in my org-ref
> setting. According to the instructions in
>
> https://github.com/jkitchin/org-ref
> and
> https://www.reddit.com/r/emacs/comments/4gudyw/help_me_with_my_orgmode_workflow_for_notetaking/
>
> I set up the paths to my bibliography, my notes and my pdfs like this:
>
> (setq org-ref-bibliography-notes "~/Dropbox/bibliography/notes.org"
>       org-ref-default-bibliography '("~/Dropbox/bibliography/references.bib")
>       org-ref-pdf-directory "~/Dropbox/bibliography/bibtex-pdfs/")
>
>
> Navigation to a bibtex entry and running org-ref-open-bibtex-notes
> creates an orgmode heading in notes.org that contains a link to the pdf
> file of the publication. Unfortunately, that link uses an expanded file
> path, i.e:
> /home/<username>/Dropbox/bibliography/bibtex-pdfs/BibtexKey.pdf
>
> so it is useless when generated by a different user. Would it be
> possible to create a link that does not expand the file path, like this
>
> ~/Dropbox/bibliography/bibtex-pdfs/BibtexKey.pdf
>
> I appreciate your help.
>
> Georg


-- 
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: org-ref file path to pdf
  2016-12-07 15:03 ` John Kitchin
@ 2016-12-07 18:13   ` Georg W. Otto
  2016-12-09  2:08     ` John Kitchin
  0 siblings, 1 reply; 5+ messages in thread
From: Georg W. Otto @ 2016-12-07 18:13 UTC (permalink / raw)
  To: emacs-orgmode

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

> This doesn't sound like something that should be happening I think. How
> current is your org-ref?
>
> I do not use the notes feature so it does not get tested too often. You
> may be able to control the format of the notes created with the variable
> org-ref-note-title-format if you are using the default notes function
> that adds a headline. 
>
>

my org ref version was 20160503 from elpa. I updated it to 20161129 and
here the part of org-ref-open-bibtex-notes that inserts a link to the
pdf is commented out. However I like this functionality, so I keep the
older version of org-ref-open-bibtex-notes in my init file.

Sorry about asking about a functionality that has been removed, but I
still do not understand why it it does expand my ~/dir to
/home/user/dir.

My org-ref-open-bibtex-notes is set to adaptive.

It might happen here, but I do not understand elisp enough to tell:

(setq pdf (-first 'f-file?
		  (--map (f-join it (concat key ".pdf"))
			 (-flatten (list org-ref-pdf-directory)))))

(if (file-exists-p pdf)
    (insert (format
	     " [[file:%s][pdf]]\n\n"
	     pdf)))


Cheers,

Georg

-- 
Georg Otto
The UCL Institute of Child Health

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: org-ref file path to pdf
  2016-12-07 18:13   ` Georg W. Otto
@ 2016-12-09  2:08     ` John Kitchin
  2016-12-13 18:59       ` Georg W. Otto
  0 siblings, 1 reply; 5+ messages in thread
From: John Kitchin @ 2016-12-09  2:08 UTC (permalink / raw)
  To: Georg W. Otto; +Cc: emacs-orgmode

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.

I hope those help.

Georg W. Otto writes:

> John Kitchin <jkitchin@andrew.cmu.edu> writes:
>
>> This doesn't sound like something that should be happening I think. How
>> current is your org-ref?
>>
>> I do not use the notes feature so it does not get tested too often. You
>> may be able to control the format of the notes created with the variable
>> org-ref-note-title-format if you are using the default notes function
>> that adds a headline. 
>>
>>
>
> my org ref version was 20160503 from elpa. I updated it to 20161129 and
> here the part of org-ref-open-bibtex-notes that inserts a link to the
> pdf is commented out. However I like this functionality, so I keep the
> older version of org-ref-open-bibtex-notes in my init file.
>
> Sorry about asking about a functionality that has been removed, but I
> still do not understand why it it does expand my ~/dir to
> /home/user/dir.
>
> My org-ref-open-bibtex-notes is set to adaptive.
>
> It might happen here, but I do not understand elisp enough to tell:
>
> (setq pdf (-first 'f-file?
> 		  (--map (f-join it (concat key ".pdf"))
> 			 (-flatten (list org-ref-pdf-directory)))))
>
> (if (file-exists-p pdf)
>     (insert (format
> 	     " [[file:%s][pdf]]\n\n"
> 	     pdf)))
>
>
> Cheers,
>
> Georg


-- 
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: org-ref file path to pdf
  2016-12-09  2:08     ` John Kitchin
@ 2016-12-13 18:59       ` Georg W. Otto
  0 siblings, 0 replies; 5+ messages in thread
From: Georg W. Otto @ 2016-12-13 18:59 UTC (permalink / raw)
  To: emacs-orgmode

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-12-13 18:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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

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).