I've already asked this question here but the context I proposed was maybe too restrictive. Here is what I'm looking for on a more behavioral level.
I have configured org-mode to open links with the return key. For instance, if a link points to a pdf, I have configured org-mode to open it with certain external pdf viewer (in fact Skim in Mac OS).
From time to time, I want to open pdf links with Inkscape, for instance, when I want to edit a pdf figure. For now, I'm globally changing my setting to open all pdf with inkscape, a setting that I have next to revert to return to my config with a common PDF viewer if I don't want to edit pdf anymore.
Since I find this setting change a bit heavy, I was wondering if there is a starting point or a solution that would allow me to keep both file opening systems, inkscape + pdf viewer, coexisting.
I think, for instance, to a solution that
- keeps the common behavior of opening a pdf with a pdf viewer by clicking (or pressing return) on a pdf link;
- opens this link with inkscape only if I press a given key when I click (or press return) on such a link.
I believe that such a solution could be of interest for other persons, in the combination of two applications on the same file extension (for instance, html link to be open either with a browser and an html editor to read the code)
Thank you in advance.
From the discussion below with the handy
dalanicolai's advice, emerged the following solution (for Mac OS only).
First, set the
mailcap-user-mime-data to open pdf files with inkscape :
(setq mailcap-user-mime-data '(("pdf" (viewer . "inkscape %s") (type . "application/pdf") (test . window-system))))
org-file-apps-macos (set by default in
org.el and called by
(defconst org-file-apps-macos '((remote . emacs) (system . mailcap) ("ps.gz" . "gv %s") ("eps.gz" . "gv %s") ("dvi" . "xdvi %s") ("fig" . "xfig %s") (t . "open %s")) "Default file applications on a macOS system. The system \"open\" is known as a default, but we use X11 applications for some files for which the OS does not have a good default. See `org-file-apps'.")
- clicking or hitting return key on a link to a pdf file open this with the pdf viewer defined in Mac OS (I use Skim),
- using the modifier
C-u C-ubefore this click/return key, open the same pdf inside
I'm sure this solution could be adapted to many other pairs of applications applied to the same file extension.
For more information on the rationale of this solution, see the discussion below.