[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 118e05f570 2/2: New user option browse-url-guess-default-scheme
From: |
Stefan Kangas |
Subject: |
master 118e05f570 2/2: New user option browse-url-guess-default-scheme |
Date: |
Sun, 10 Jul 2022 09:03:15 -0400 (EDT) |
branch: master
commit 118e05f570b127f9272c5dea1ae9a739531e238c
Author: Stefan Kangas <stefan@marxist.se>
Commit: Stefan Kangas <stefan@marxist.se>
New user option browse-url-guess-default-scheme
* 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 | 6 ++++++
lisp/net/browse-url.el | 15 ++++++++++++++-
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/etc/NEWS b/etc/NEWS
index c2e2f1b7b7..2ab1361a9e 100644
--- 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
diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el
index b988fbf9a6..198c86f935 100644
--- a/lisp/net/browse-url.el
+++ b/lisp/net/browse-url.el
@@ -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