Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pdftools: org link type not recognized + xdg-open is used instead of pdfview #52

Open
malanders380 opened this issue Sep 23, 2020 · 6 comments

Comments

@malanders380
Copy link

malanders380 commented Sep 23, 2020

I just installed pdf-tools and org-pdftools and have the following two weird behaviors:

  1. Any links of the form [[./file.pdf]] within a org file gets opened externally using /usr/bin/xdg-open instead of within emacs! (but if I click on a file from within dired, it gets properly opened within emacs with pdfview)

  2. Any links of the form [[pdftools:./file.pdf]] within a org file does not get opened at all. When clinking on the link the following result is shown "No match - create this as a new heading? (y or n)". Then entering "n" appears "No match for fuzzy expression: pdftools:./file.pdf". Does org-pdftools not play well with other packages?

Emacs version: GNU Emacs 27.1

pdftools configuration:

(use-package pdf-tools
:ensure t
:config
(pdf-tools-install)
(setq-default pdf-view-display-size 'fit-width)
(define-key pdf-view-mode-map (kbd "C-s") 'isearch-forward)
(setq pdf-annot-activate-created-annotations nil)
(setq pdf-view-resize-factor 1.1)
(setq TeX-view-program-selection '((output-pdf "PDF Tools"))
TeX-view-program-list '(("PDF Tools" TeX-pdf-tools-sync-view))
TeX-source-correlate-start-server t)
(add-hook 'TeX-after-compilation-finished-functions
#'TeX-revert-document-buffer)
)

org-pdftools configuration:

(use-package org-pdftools
:ensure t
:hook (org-mode . org-pdftools-setup-link))

(use-package org-noter-pdftools
:ensure t
:after org-noter
:config
(with-eval-after-load 'pdf-annot
(add-hook 'pdf-annot-activate-handler-functions #'org-noter-pdftools-jump-to-note)))

Any help to fix the two issues would be greatly appreciated, thank you.

@malanders380
Copy link
Author

Some more infos:

  • org-version 9.4
  • org-pdftools-20200422.1350
  • pdf-tools-20200512.1524

@malanders380
Copy link
Author

Looking through the source code I suspect that the correct org link type is pdf: and not pdftools: as written in the README.org
Links of the form [[pdf:./file.pdf]] open nicely within emacs as expected.

It still remains unclear to me why links of the type [[./file.pdf]] are opened using xdg-open instead of being open within emacs. Any idea? Thx.

@fabriziojpiva
Copy link

Hi @malanders380 could you solve the issue? I am facing the same thing, the prefix "pdftools:" before the file destination does not work, and if I put only "pdf" it opens it, but if you open a pdf with comments, you won't be able to see them. You will only see the plain pdf.

@hyiltiz
Copy link

hyiltiz commented Nov 6, 2020

It would be ideal if all of the below would be opened properly inside emacs using pdftools:

  • [[./file.pdf]]
  • pressing enter on pdf files in dired
  • opening/finding a file path pointing to a pdf

@firmart
Copy link

firmart commented Nov 21, 2020

Just to clarify a bit, if one does not configure org-pdftools-link-prefix, then org-pdftools-setup-link activates the default prefix pdf:. So pdftools: won't work.

@avilaHugo
Copy link

avilaHugo commented Aug 13, 2021

Hi, just in case someone still have the same problem.

I follow the README instructions and copy the suggested config. Until now all features seem to work but in org-mode pdf links only open with DocView not PDFview. I try a feel changes to this block of code but none of then worked:

;;  Original (README recomended)
(use-package org-pdftools
  :hook (org-mode . org-pdftools-setup-link))

;;  Failed fixes
(use-package org-pdftools
  :ensure t
  :hook (org-mode . org-pdftools-setup-link))

(use-package org-pdftools
  :ensure t
  :after org
  :hook (org-mode . org-pdftools-setup-link))

(use-package org-pdftools
  :ensure t
  :after org-noter
  :hook (org-mode . org-pdftools-setup-link))

(use-package org-pdftools
  :ensure t
  :hook (org-noter . org-pdftools-setup-link))

After some research i was able to activate PDFview everywhere by adding this code to the recommended config:

  ;;(use-package org-pdftools
  ;;  :ensure t
  ;;  :hook (org-mode . org-pdftools-setup-link))

;; source code from: http://alberto.am/2020-04-11-pdf-tools-as-default-pdf-viewer.html

  (use-package pdf-tools
     :pin manual
     :config
     (pdf-tools-install)
     (setq-default pdf-view-display-size 'fit-width)
     (define-key pdf-view-mode-map (kbd "C-s") 'isearch-forward)
     :custom
     (pdf-annot-activate-created-annotations t "automatically annotate highlights"))

  (setq TeX-view-program-selection '((output-pdf "PDF Tools"))
	TeX-view-program-list '(("PDF Tools" TeX-pdf-tools-sync-view))
	TeX-source-correlate-start-server t)

  (add-hook 'TeX-after-compilation-finished-functions
	    #'TeX-revert-document-buffer)

  (add-hook 'pdf-view-mode-hook (lambda() (linum-mode -1)))

Is there an easier way to do this ?

my emacs version: GNU Emacs 26.3

ORG-NOTER
Status: Installed in ‘org-noter-20191020.1212/’ (unsigned).
Version: 20191020.1212
Commit: 9ead81d42dd4dd5074782d239b2efddf9b8b7b3d

ORG-NOTER-PDFTOOLS
Status: Installed in ‘org-noter-pdftools-20210118.1611/’ (unsigned). Delete
Version: 20210118.1611
Commit: a5b61bc

Thanks for the work ! it is a very helpful tool

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants