What I mean is, can I add a URL to my Emacs bookmarks, such that selecting the bookmark runs the URL through browse-url?

Desired behavior

What I would like is a bookmark-set-url function that prompts for a url, say emacs.stackexchange.com. Then when I run bookmark-jump, emacs.stackechange.com appears in my bookmarks, and selecting it runs (browse-url "emacs.stackexchange.com").

This is analogous to bookmark-set, which sets a bookmark that points at the current location.

Is this behavior—or something similar—available in Emacs? If not is it possible to augment bookmarks (or bookmarks+) to support it?

The reason I want this is that bookmark-jump feels like a general purpose targeted navigation command. Browser URLs feel like an extension of that idea, despite the fact that they switch to a different application.


The following seems working from here (I don't use the Bookmarks feature, and I ain't familir with its protocol.), I tested it with:

M-x your-bookmark-set-url https://example.com
M-x bookmark-jump https://example.com
(defun your-bookmark-set-url (url)
  (interactive "sBookmark URL: ")
  (if (assoc url bookmark-alist)
      (user-error "%s is already bookmarked" url)
    (push `(,url . ((handler . ,(lambda (bookmark)
                                  (browse-url (car bookmark))))))

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.