4

Suppose I have several browsers running at any given time.

Google Chrome Google Chrome Canary Chromium Opera Safari

How can I indicate in my org mode links

[[https://www.gnu.org/software/emacs/][GNU Emacs]]

which browser should be used when (C-c C-o) opening the link.

What I tried: Read https://orgmode.org/manual/External-links.html

american-ninja-warrior
  • 3,773
  • 2
  • 21
  • 40

1 Answers1

5

You can set up your own protocols in org-link-parameters with org-link-set-parameters.

If you run

(org-link-set-parameters "chrome" :follow (lambda (path) (browse-url-chrome (concat "http:" path))))
(org-link-set-parameters "chromes" :follow (lambda (path) (browse-url-chrome (concat "https:" path))))
(org-link-set-parameters "chromium" :follow (lambda (path) (browse-url-chromium (concat "http:" path))))
(org-link-set-parameters "chromiums" :follow (lambda (path) (browse-url-chromium (concat "https:" path))))

you can use [[chrome://www.gnu.org/software/emacs/][GNU Emacs]] or [[chromes://www.gnu.org/software/emacs/][GNU Emacs]] to open the link with the chrome browser google-chrome

and [[chromium://www.gnu.org/software/emacs/][GNU Emacs]] or [[chromiums://www.gnu.org/software/emacs/][GNU Emacs]] to open the link with the chromium browser chromium.

If you want to choose between different chrome browsers I suggest you copy the function definition of browse-url-chrome from the library browse-url. Paste it into your init file, change the function name, and adapt the function to your purposes. Afterwards you can add link parameters for it.

You find the library browse-url easily with M-x find-library RET... .

You can expand that solution to your likings. For an instance you can add an optional tab-number to the link if the chrome commando has such a parameter. You just have to process this information in your link handler. Note that the link handlers are the lambda expressions in the above example.

David Ongaro
  • 370
  • 4
  • 13
Tobias
  • 32,569
  • 1
  • 34
  • 75