Search code examples
emacsorg-mode

Get browse-url-at-point to behave like browse-url in Emacs / Org Mode links


I'm trying to work out how to get org mode to open (as clickable links) URLs which link to another piece of software called ConnectedText. ConnectedText allows other applications to link to its files via URLs that look like the following: ct://Welcome/Welcome

If I invoke browse-url via M-x browse-url, and then paste one of these links, then the links open as they should do. But if I add them as clickable links in org mode they don't work (I get the 'no match- create this as a new heading?' dialogue).

According to the org-mode manual, clickable links are handled by the browse-url-at-point function. When I try to use browse-url-at-point to open one of these URLs (via M-x browse-url-at-point), it also doesn't work, and instead tries to open the link in my web browser.

So I'm trying to figure out how to get browse-url-at-point to behave in the same way as browse-url in relation to these URLs.

Browse-url, if invoked when the point is on one of these URLs, defaults to the URL (as per the documentation; "If point is located near a plausible URL, that URL is used as the default.") However, when it does this, it inserts http:// so the resulting URL looks like the following: http://ct://Welcome/Welcome. I assume this is the reason things aren't working.

Is there a way I can get browse-url-at-point to not insert this http:// prefix?

Or am I going about this the wrong way?

Thanks for any suggestions!

David


Solution

  • The Emacs developers provided me with a solution to this issue. If ct:// is added to thing-at-point, then browse-url-at-point works in the same way as M-x browse-url in the scenario described in the question. The following added to the init file does this:

    (require 'thingatpt) 
    (push "ct://" thing-at-point-uri-schemes)