diff options
author | Sean Allred <code@seanallred.com> | 2015-02-13 20:56:27 -0600 |
---|---|---|
committer | Sean Allred <code@seanallred.com> | 2015-02-13 20:56:27 -0600 |
commit | 89132aa7b82abd1b54356831dda9d4dd28cf7492 (patch) | |
tree | 5edcb8f88ed4ed0a5c7221af347512947fd65adf /sx-button.el | |
parent | 2c7e276ebcd06616362b9710ca45c2e48641adcf (diff) | |
parent | b7d1d7c47e6bbb907df90ee078ef18ba47412b75 (diff) |
Merge pull request #232 from vermiculus/visit-internally-first
Visit internally first
Diffstat (limited to 'sx-button.el')
-rw-r--r-- | sx-button.el | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/sx-button.el b/sx-button.el index 5a2f052..992c654 100644 --- a/sx-button.el +++ b/sx-button.el @@ -98,9 +98,14 @@ usually part of a code-block." (defun sx-button-follow-link (&optional pos) "Follow link at POS. If POS is nil, use `point'." (interactive) - (browse-url - (or (get-text-property (or pos (point)) 'sx-button-url) - (sx-user-error "No url under point: %s" (or pos (point)))))) + (let ((url (or (get-text-property (or pos (point)) 'sx-button-url) + (sx-user-error "No url under point: %s" (or pos (point)))))) + ;; If we didn't recognize the link, this errors immediately. If + ;; we mistakenly recognize it, it will error when we try to fetch + ;; whatever we thought it was. + (condition-case nil (sx-open-link url) + ;; When it errors, don't blame the user, just visit externally. + (error (sx-visit-externally url))))) ;;; Help-echo definitions |