jkitchin / org-ref

org-mode modules for citations, cross-references, bibliographies in org-mode and useful bibtex tools to go with it.
GNU General Public License v3.0
1.36k stars 243 forks source link

org-pdfview to org-pdftools Migration #846

Closed JudicialDomicide closed 3 years ago

JudicialDomicide commented 3 years ago

Hi,

I have just started a fresh emacs install and I used to use this code which enabled me to open pdf files within emacs in pdf-tools. (My use case was using org-ref with org-noter)

;; PDF links for org-mode
 (with-eval-after-load "pdf-tools"
     :config
     ;; https://lists.gnu.org/archive/html/emacs-orgmode/2016-11/msg00169.html
     ;; Before adding, remove it (to avoid clogging)
     (delete '("\\.pdf\\'" . default) org-file-apps)
     ;; https://lists.gnu.org/archive/html/emacs-orgmode/2016-11/msg00176.html
     (add-to-list 'org-file-apps
                  '("\\.pdf\\'" . (lambda (file link)
                                    (org-pdfview-open link)))))

I have seen your change in the readme to take account for the fact that pdfview is no longer maintained and org-pdftools has took over.

I tried the following code from your instructions

;; PDF links for org-mode
(with-eval-after-load 'pdf-tools
  (use-package org-pdftools
    :config
    ;; https://lists.gnu.org/archive/html/emacs-orgmode/2016-11/msg00169.html
    ;; Before adding, remove it (to avoid clogging)
    (delete '("\\.pdf\\'" . default) org-file-apps)
    ;; https://lists.gnu.org/archive/html/emacs-orgmode/2016-11/msg00176.html
    (add-to-list 'org-file-apps
         '("\\.pdf\\'" . (lambda (file link)
                   (org-pdftools-open link))))))

I get a Symbol's function definition is void: use-package

--debug-init gives the following:

Debugger entered--Lisp error: (void-function use-package)
  (use-package 'org-pdftools :config (delete '("\\.pdf\\'" . default) org-file-apps) (add-to-list 'org-file-apps '("\\.pdf\\'" lambda (file link) (org-pdftools-open link))))
  (lambda nil (use-package 'org-pdftools :config (delete '("\\.pdf\\'" . default) org-file-apps) (add-to-list 'org-file-apps '("\\.pdf\\'" lambda (file link) (org-pdftools-open link)))))()
  eval-after-load("pdf-tools" (lambda nil (use-package 'org-pdftools :config (delete '("\\.pdf\\'" . default) org-file-apps) (add-to-list 'org-file-apps '("\\.pdf\\'" lambda (file link) (org-pdftools-open link))))))
  eval-buffer(#<buffer  *load*> nil "/Users/$user/.emacs.d/init.el" nil t)  ; Reading at buffer position 10346
  load-with-code-conversion("/Users/$user/.emacs.d/init.el" "/Users/$user/.emacs.d/init.el" t t)
  load("/Users/$user/.emacs.d/init" noerror nomessage)
  startup--load-user-init-file(#f(compiled-function () #<bytecode 0x1ffd7ece646d>) #f(compiled-function () #<bytecode 0x1ffd7ece6481>) t)
  command-line()
  normal-top-level()

I'd appreciate any help. Thanks.

JudicialDomicide commented 3 years ago

A quick and dirty init.el hack resolved this for me.

   (delete '("\\.pdf\\'" . default) org-file-apps)
   (add-to-list 'org-file-apps
                   '("\\.pdf\\'" . emacs))

Sure its probably not a great solution for others but it works enough for what I need and allows me to open custom links that are generated [[papers:%l][%l-paper]] and corresponding notes [[notes:%l][%l-notes]]

Will leave open for now incase there is a wider issue.

jkitchin commented 3 years ago

It sounds like you just need to install use-package. (https://github.com/jwiegley/use-package)

JudicialDomicide commented 3 years ago

Thanks John, indeed for some reason when moving to the new Mac setup, I had forgotten to install use-package. Just installed from Melpa and the code in your documentation works. Sorry. I'll close this.