2

When i click or C-c C-o on pdf link in org-mode, Emacs opens the pdf with gimp.

I don't find how to overide this behavior.

Tried with these two recipes

(require 'openwith)
(openwith-mode t)
(add-to-list  'mm-inhibit-file-name-handlers 'openwith-file-handler
(setq openwith-associations '(("\\.pdf\\'" "evince" (file))))

With first recipe, no change on behavior

(org-add-link-type "pdf" 'org-pdf-open nil)

(defun org-pdf-open (link)
  (let* ((path+page (split-string link "#page="))
         (pdf-file (car path+page))
         (page (car (cdr path+page))))
    (start-process "view-pdf" nil "evince" "--page-index" page pdf-file)))

With second recipe, no change in behavior

Can you help me ?

Best regards

Stefan
  • 26,154
  • 3
  • 46
  • 84
olopost
  • 43
  • 5
  • Please explain what happened with each one of those two "recipes". BTW, I only see one "recipe". – Stefan Mar 31 '20 at 12:39
  • inline change, for the two recipes with result after change. Thanks – olopost Mar 31 '20 at 14:27
  • I'm pretty sure I've heard of people having similar problems (PDF handled by Gimp) where the culprit was linked to Emacs's handling of mailcap settings. Maybe a `M-x report-emacs-bug` is in order. – Stefan Mar 31 '20 at 16:16

1 Answers1

0

It might still be using the mailcap system and gimp somehow has the highest priority in /etc/mailcap. To fix this for you user override it in ~/.mailcap by putting this there:

application/pdf; /usr/bin/evince %s; test=test "$DISPLAY" != ""; description=Portable Document Format; nametemplate=%s.pdf
application/x-pdf; /usr/bin/evince %s; test=test "$DISPLAY" != ""; description=Portable Document Format; nametemplate=%s.pdf

You can also do this system-wide by editing /etc/mailcap directly, there are instruction on how to do this in this file safely since this is also automatically updated when packages are installed or removed.

flub
  • 101
  • 1