0

I can visit URLs in a message with g, bound to mu4e-view-go-to-url, which uses the default browser. How can I copy it to the clipboard to view it on another browser?

2

tl;dr

Use k, or mu4e-view-save-url, which saves it to the kill ring and to the clipboard.

Looking for the mu4e function

For similar functions, it helps to look at the documentation and source code. Press C-h k and g to view the documentation for the function bound to k:

g runs the command mu4e-view-go-to-url (found in mu4e-view-mode-map), which is
an interactive compiled Lisp function in
‘/usr/local/Cellar/mu/1.2.0/share/emacs/site-lisp/mu/mu4e/mu4e-view.el’.

It is bound to g, <menu-bar> <headers> <goto-url>.

(mu4e-view-go-to-url &optional MULTI)

Offer to go to url(s). If MULTI (prefix-argument) is nil, go to
a single one, otherwise, offer to go to a range of urls.

Click the first link to visit the source code, which shows this function right after mu4e-view-go-to-url:

(defun mu4e-view-save-url (&optional multi)
  "Offer to save urls(s) to the kill-ring. If
MULTI (prefix-argument) is nil, save a single one, otherwise, offer
to save a range of URLs."
...

Then from a mu4e buffer, you can find its key binding with C-h f RET mu4e-view-save-url:

mu4e-view-save-url is an interactive compiled Lisp function in
‘/usr/local/Cellar/mu/1.2.0/share/emacs/site-lisp/mu/mu4e/mu4e-view.el’.

It is bound to k, <menu-bar> <headers> <save-url>.

(mu4e-view-save-url &optional MULTI)

Offer to save urls(s) to the kill-ring. If
MULTI (prefix-argument) is nil, save a single one, otherwise, offer
to save a range of URLs.

Defining a custom function

You can also define a function to open a link in a browser other than the default. The code is from this thread and I was unable to make it work on Safari:

;; set Chromium path on macOS
(setq browse-url-chromium-program "/Applications/Chromium.app/Contents/MacOS/Chromium")

;; code to follow links in different browser
(defun browse-url-at-point-chromium (&optional ARG)
  (interactive)
  (let ((url (get-text-property (point) 'shr-url)))
    (if url
    (browse-url-chromium url ARG)
      (let ((url (browse-url-url-at-point)))
    (browse-url-chromium url ARG)))))

(define-key mu4e-view-mode-map (kbd "J") 'browse-url-at-point-chromium)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.