fuxialexander / org-pdftools

A custom org link type for pdf-tools
GNU General Public License v3.0
331 stars 35 forks source link

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

Open malanders380 opened 3 years ago

malanders380 commented 3 years ago

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 commented 3 years ago

Some more infos:

malanders380 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

firmart commented 3 years ago

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 commented 2 years ago

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: a5b61bca3f8c91b0859bb0df1a929f9a31a57b99

Thanks for the work ! it is a very helpful tool