4

Assume that in the current buffer there is some text like http://emacs.stackexchange.com/. Is it possible to customize Emacs so that double clicking on this text, results in visiting the link by the deafult browser? (i.e., like hyperref in LaTeX).

  • 1
    Is using mouse mandatory? M-x ffap, with point on the link, does what you want. You can bind ffap to double click with (global-set-key [double-mouse-1] 'ffap). – giordano Jan 6 '15 at 13:18
  • @giordano Thank you very much. Please feel free to put your comment as an answer in order that I can acknowledge your help within site. – Name Jan 6 '15 at 13:25
  • Please do some basic background research before posting. A google search for "emacs web link" turns up the EmacsWiki page for browse-url and the Emacs manual on external links from org-mode as the first two hits. – Dan Jan 6 '15 at 13:26
3

M-x ffap RET does what you want (will be requested a confirmation though). You can bind it to double mouse click with

(global-set-key [double-mouse-1] 'ffap)

As the name suggests, ffap finds files at point, not just URLs. If you want a function tailored to URLs look at the builtin browse-url package (as suggested by Dan), which also lets you choose the browser to use. If you prefer browse-url, replace ffap with browse-url (or browse-url-at-point if you don't want to be prompted for confirmation, thanks glucas!) in the previous code to bind it to double click event.

  • 6
    Use browse-url-at-point if you don't want a confirmation prompt. – glucas Jan 6 '15 at 15:36
  • @glucas Thank you for your very useful comment. – Name Jan 6 '15 at 16:10
  • But with browse-url-at-point double-clicking any string opens the browser. How can I limit Emacs to only browse actual URL's? – doubleU Oct 8 '18 at 20:48

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.