I have this function to open links in firefox with mu4e, which I found somewhere here.

;; open with firefox
    (defun my-browse-url-firefox-new-tab (url &optional new-window)
      "Open URL in a new tab in Firefox."
      (interactive (browse-url-interactive-arg "URL: "))
      (let ((cmd (shell-command-to-string
          (concat "~/src/firefox/mozilla-xremote-client -a any 'openURL("
              url ",new-tab)'"))))
    (unless (string= "" cmd)
      (message "Starting Firefox...")
      (start-process (concat "firefox " url) nil "/usr/bin/firefox" url)
      (message "Starting Firefox...done"))))

(define-key mu4e-view-mode-map (kbd "C-c C-o") #'my-browse-url-firefox-new-tab)

My problem is that it only works for "direct" links, not hypertext. If I have a link such as mylink, it displays URL: http://mylink, not URL http://www.example.com. Can anyone help?

  • What version of Org mode are you using? I believe this was a bug that was introduced recently and has been been fixed very recently in the master branch (as far as I know, the bug never made it to the stable branch). The bug was caused by commit d07d8ff4, dated Aug. 29. It was fixed by commit 1fd07c1e, dated Sep. 18. – NickD Sep 30 '19 at 11:11
  • Thanks Nick. I had 9.1.9 (built-in) installed. I then went an installed 9.2.6 (gnu), by going M-x package-list-packages > org > Other versions > Install. This didn't fix it, but it broke my automatic agenda which I have loading on start up, and I don't know how to delete the new org version again, as it doesn't seem to have a delete button. I know have to "orgs" in the package list, one is the old built-in and the other says "Status: Installed in ‘org-9.2.6/’, shadowing a built-in package. – Bertil Johannes Ipsen Oct 1 '19 at 9:24
  • M-x package-delete RET TAB should give you a list of installed packages - clicking on the appropriate Org mode package should get rid of it and get you back to the pre-installed version. – NickD Oct 1 '19 at 15:33
  • Thanks so much! I had to go a delete a few packages, but it eventually worked. Any idea on how to solve the original issue now? – Bertil Johannes Ipsen Oct 3 '19 at 17:20
  • Sorry, no: it sounded a bit like the bug I mentioned, but since it's not, I cannot think of any other reason. BTW, eventually you'll have to upgrade, so you might want to investigate why your automatic agenda broke. It might prevent a panic moment in the future (DAMHIKT). – NickD Oct 3 '19 at 18:05

For email in text format, g will prompt you for the url you want to visit, which you select by number. (The numbers appear next to the link in the message).

For emails in html format, put your cursor on the url you want to visit and type M-RET. Please, find more info about Mu4e keybindings here.

You may also be interested by opening the whole email in the browser; by defining a custom action


Pressing g followed by a number should open the link in the default browser AFAIK. The problem is how to open links in HTML format.

One way to do this is to create a hash table of all links in the buffer containing the URL and a number assigned to it (similar to how mu4e~view-make-urls-clickable works) by searching href anchor properties. There's no general solution AFAICT, so here's one using the default setting:

(setq mu4e-html2text-command 'mu4e-shr2text)

(defun mu4e-make-hypertext-clickable ()
  (let ((next-url
         (lambda ()
             (goto-char (next-single-property-change (point) 'shr-url))))))
      ;; Do nothing if no anchors are found
      (when (funcall next-url)
        (setq mu4e~view-link-map            ; buffer local
              (make-hash-table :size 32 :weakness nil))
        (let ((c 0))
          (goto-char (point-min))
          (while (funcall next-url)
            (let ((ov (make-overlay (point) (point)))
                  (num (cl-incf c))
                  (url (shr-url-at-point nil)))
              (puthash num url mu4e~view-link-map)
              (overlay-put ov 'before-string
                           (propertize (format "[%d]" num)
                                       'face 'mu4e-url-number-face)))
            (funcall next-url)))))))

(add-hook 'mu4e-view-mode-hook 'mu4e-make-hypertext-clickable)

I would also suggest reading this section of the manual.

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.