]> git.eshelyaron.com Git - emacs.git/commitdiff
New user option browse-url-guess-default-scheme
authorStefan Kangas <stefan@marxist.se>
Sun, 10 Jul 2022 12:30:52 +0000 (14:30 +0200)
committerStefan Kangas <stefan@marxist.se>
Sun, 10 Jul 2022 13:01:23 +0000 (15:01 +0200)
* lisp/net/browse-url.el (browse-url-guess-default-scheme): New
user option.
(browse-url-url-at-point): Use above new user option.

etc/NEWS
lisp/net/browse-url.el

index c2e2f1b7b72ff48ae520d754df1383989ae48f1c..2ab1361a9ed455afe8026615c3e489b35d9d4b58 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1924,6 +1924,12 @@ related 'auth-sources' entry were wrong.
 
 ** Browse URL
 
+---
+*** New user option 'browse-url-guess-default-scheme'.
+This user option affects the URL scheme that 'browse-url' and related
+functions will assume when it has to guess.  You could customize this
+to "https" to always prefer HTTPS URLs.
+
 ---
 *** Support for the Netscape web browser has been removed.
 This support has been obsolete since Emacs 25.1.  The final version of
index b988fbf9a650cd4194d2b2ad5a755c4b24526116..198c86f935e08ef9efcb4c835723ca7eb56cb042 100644 (file)
@@ -652,11 +652,24 @@ regarding its parameter treatment."
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; URL input
 
+(defcustom browse-url-guess-default-scheme "http"
+  "URL scheme to use when `browse-url' (and related commands) has to guess.
+
+For example, when point is on an URL fragment like
+\"www.example.org\", `browse-url' will assume that this is an
+\"http\" URL by default (i.e. \"http://www.example.org\").
+
+Note that if you set this to \"https\", websites that do not yet
+support HTTPS may not load correctly in your web browser.  Such
+websites are increasingly rare, but they do still exist."
+  :type 'string
+  :version "29.1")
+
 (defun browse-url-url-at-point ()
   (or (thing-at-point 'url t)
       ;; assume that the user is pointing at something like gnu.org/gnu
       (let ((f (thing-at-point 'filename t)))
-        (and f (concat "http://" f)))))
+        (and f (concat browse-url-guess-default-scheme "://" f)))))
 
 ;; Having this as a separate function called by the browser-specific
 ;; functions allows them to be stand-alone commands, making it easier