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?
1 Answer
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)
-
2This works for links/URLs in some emails, where the URLs are numbered
[1]
etc. For other emails, there are URLs but no numbers. I can move the point to the url withTAB
and open it in the default browser withENTER
(or a mouse click), but there seems to be no way to copy the URL (other than.
to see the source, do some searching, and select and copy the URL manually (sometimes into a scratch buffer as to remove some hard wrapping (often with=
characters)). In these emails,g
andk
give[mu4e] No links for this message
in the buffer... Is there a solution for such emails? Commented Nov 29, 2023 at 15:59 -
1@AstroFloyd I'm sorry, I stopped using mu4e a few years ago. How about asking a separate question mentioning this thread?– emonigmaCommented Nov 30, 2023 at 18:22
-
1I asked the separate question here: emacs.stackexchange.com/q/79769/17538 Commented Apr 12 at 7:08