Commit Diff


commit - 2116f17d9692b4032c4a2534c4831f92a31f671e
commit + cfcbc23cf9c18cbc9964064ce954c05cde9fd473
blob - 16164f693136252d6151264291d8d25ef904d201
blob + d53931d48251bd4b83a7661aa43b4c46bc269a77
--- defaults.c
+++ defaults.c
@@ -27,6 +27,7 @@
 #include "ui.h"
 #include "utils.h"
 
+char	*default_protocol = NULL;
 char	*download_path = NULL;
 char	*new_tab_url = NULL;
 
@@ -565,6 +566,17 @@ config_setvari(const char *var, int val)
 int
 config_setvars(const char *var, char *val)
 {
+	if (!strcmp(var, "default-protocol")) {
+		if (strcmp(val, "finger") &&
+		    strcmp(val, "gopher") &&
+		    strcmp(val, "gemini"))
+			return 0;
+
+		free(default_protocol);
+		default_protocol = val;
+		return 1;
+	}
+
 	if (!strcmp(var, "download-path")) {
 		const char *prfx = "", *v = val, *sufx = "";
 
blob - b52d550568e8735f56e4da0206d63aeb4628fbf7
blob + 2a9d1be7b0c7a7f2c3038fe66a2255b334104d45
--- include/defaults.h
+++ include/defaults.h
@@ -17,6 +17,7 @@
 #ifndef DEFAULTS_H
 #define DEFAULTS_H
 
+extern char	*default_protocol;
 extern char	*download_path;
 extern char	*new_tab_url;
 
blob - 8d79a25e8a2df4bcf37a5f0eb7728f3a4fb2ebf3
blob + 2f8dab0975bc6a59cb9fd0f76a534bfac41771c6
--- telescope.1
+++ telescope.1
@@ -176,7 +176,9 @@ or
 .Dq /
 assume it's a file:// URL,
 .It
-otherwise assume it's a Gemini URL.
+otherwise treat it like a hostname with protocol
+.Ic default-protocol
+.Pq gemini by default .
 .El
 .Pp
 The setting
@@ -254,6 +256,13 @@ If greater than zero, save the session after the speci
 seconds after some events happens
 .Pq new or closed tabs, visited a link ...
 Defaults to 20.
+.It Ic default-protocol
+.Pq string
+The default protocol assumed for the
+.Ic load-url
+heuristic.
+Defaults to
+.Dq gemini .
 .It Ic dont-wrap-pre
 .Pq boolean
 If true, don't wrap preformatted blocks.
blob - f0d7a2e2ae0487414997c8675a685974b6c111eb
blob + c91a22e859b1ba5cbb259e68f8bf65a421e70b07
--- telescope.c
+++ telescope.c
@@ -887,7 +887,7 @@ write_buffer(const char *path, struct tab *tab)
  *
  * - if it's a proper url use it
  * - if it starts with a `./' or a `/' assume its a file:// url
- * - assume it's a gemini:// url
+ * - assume it's a default-protocol:// url
  *
  * `ret' (of which len is the size) will be filled with the resulting
  * url.
@@ -919,7 +919,8 @@ humanify_url(const char *raw, const char *base, char *
 		return;
 	}
 
-	strlcpy(ret, "gemini://", len);
+	strlcpy(ret, default_protocol, len);
+	strlcat(ret, "://", len);
 	strlcat(ret, raw, len);
 }
 
@@ -1095,6 +1096,10 @@ main(int argc, char * const *argv)
 		exit(0);
 	}
 
+	if (default_protocol == NULL &&
+	    (default_protocol = strdup("gemini")) == NULL)
+		err(1, "strdup");
+
 	if (download_path == NULL &&
 	    (download_path = strdup("/tmp/")) == NULL)
 		errx(1, "strdup");