diff options
Diffstat (limited to 'lisp/net')
-rw-r--r-- | lisp/net/browse-url.el | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el index 3ab1a345470..34bfb403e1c 100644 --- a/lisp/net/browse-url.el +++ b/lisp/net/browse-url.el @@ -669,7 +669,7 @@ regarding its parameter treatment." ;; functions allows them to be stand-alone commands, making it easier ;; to switch between browsers. -(defun browse-url-interactive-arg (prompt) +(defun browse-url-interactive-arg (prompt &optional default-url) "Read a URL from the minibuffer, prompting with PROMPT. If `transient-mark-mode' is non-nil and the mark is active, it defaults to the current region, else to the URL at or before @@ -686,7 +686,8 @@ for use in `interactive'." "[\t\r\f\n ]+" "" (buffer-substring-no-properties (region-beginning) (region-end)))) - (browse-url-url-at-point))) + (browse-url-url-at-point) + default-url)) (not (eq (null browse-url-new-window-flag) (null current-prefix-arg))))) @@ -799,6 +800,13 @@ narrowed." ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Browser-independent commands +(defun url-tidy (url) + "Tidy up URL as much as possible." + (if (equal 0 (string-match ".*://" url)) + url + (concat "http://" url) ;;TODO guess more url forms, like mailto + )) + ;; A generic command to call the current browse-url-browser-function ;;;###autoload @@ -811,6 +819,7 @@ first, if that exists." (interactive (browse-url-interactive-arg "URL: ")) (unless (called-interactively-p 'interactive) (setq args (or args (list browse-url-new-window-flag)))) + (setq url (url-tidy url)) (let ((process-environment (copy-sequence process-environment)) (function (or (and (string-match "\\`mailto:" url) browse-url-mailto-function) |