Is there a way in the org mode syntax to create a link and to define which browser to open the link in? I have some links that I want to open in a different browser than my default one.
More than two years later, and possibly not exactly what you were looking for, but still:
M-x customize-option RET org-file-apps RET
Feel free to customise.
You can define a function that grabs the URL at point and calls one of
browse-url-<browser name> functions. Taking the example of Chromium:
(defun browse-url-at-point-chromium (&optional ARG) (interactive) (let ((url (browse-url-url-at-point))) (if url (browse-url-chromium url ARG) (error "No URL found"))))
And bind that function to a key:
(define-key org-mode-map (kbd "C-RET") 'browse-url-at-point-chromium)
This also works in other modes, such as
mu4e (email in Emacs):
(define-key mu4e-view-mode-map (kbd "C-RET") 'browse-url-at-point-chromium)
On macOS, the browsers with a Graphical User Interface (GUI) are not linked to shell executables, so Emacs can't see them in the default
browse-url-chromium function, for example. So you need the additional step of giving Emacs the path to the executable:
(setq browse-url-chromium-program "/Applications/Chromium.app/Contents/MacOS/Chromium")
macOS and Safari
If you want Safari on macOS, it has the additional problem that the executable does not take arguments (see this thread). One solution from there is to call AppleScript to tell Safari to open the URL. The shell command is:
/Applications/Safari.app/Contents/MacOS/Safari & sleep 1 && osascript -e 'tell application "Safari" to open location "http://www.google.com"'
Another is to use
open -a Safari <URL> in bash and
start-process in ELisp:
(defun browse-url-at-point-safari () (interactive) (let ((url (browse-url-url-at-point))) (if url (start-process (concat "mozilla " url) nil "mozilla" url) (error "No URL found"))))
I was unable to make either of these work and found it easier to use another browser, such as Chromium.