Collecting my attempts to improve at tech, art, and life

Goto Address Mode Opens Links in Emacs

Tags: emacs tools

attachments/img/2020/cover-2020-02-04.png

Org mode has this nice thing where you can click a link in the Emacs buffer to open it in your browser. Turns out that’s not some special org-only behavior. It’s goto-address-mode, a minor mode that activates URLs and email addresses in the current buffer.

You can manually launch it with M-x goto-address-mode. It might be easier to automatically enable it for certain modes. You do that with a hook.

I want links to be available when reviewing notes and blog posts. Since I write those notes in a number of formats, I should add the hook one of the general major modes. text-mode is a good start.

;; base mode for prose
(add-hook 'text-mode-hook (lambda ()
                           (goto-address-mode)))

Now I can open links from my Markdown and reStructuredText files with a click! Or a C-c <RET>.

goto-address-mode key bindings

Key Function Action
C-c <RET> goto-address-at-point Opens the link under point

I might add the hook for prog-mode later, if I find myself wanting to click URLs in source code.


Added to vault 2024-01-15. Updated on 2024-02-01