Question about url_general

Massimiliano Gubinelli <[email protected]> Fri, 21 Mar 2025 14:25:58 +0000
Newsgroups gmane.editors.texmacs.devel
Message-ID <[email protected]>
--===============2664533199495182578==
Content-Type: multipart/alternative;
	boundary="Apple-Mail=_B32A4953-B482-44BC-ABE5-89EAF4794EEB"


--Apple-Mail=_B32A4953-B482-44BC-ABE5-89EAF4794EEB
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=utf-8

Dear all,

 I=E2=80=99m trying to understand the rationale behind the definition of =
the function url_general in url.cpp:

url
url_general (string name, int type=3D URL_SYSTEM) {
  if (starts (name, "local:")) return url_local (name (6, N (name)));
  if (starts (name, "file://")) return url_file (name (7, N (name)));
  if (starts (name, "http://")) return url_http (name (7, N (name)));
  if (starts (name, "https://")) return url_https (name (8, N (name)));
  if (starts (name, "ftp://")) return url_ftp (name (6, N (name)));
  if (starts (name, "tmfs://")) return url_tmfs (name (7, N (name)));
  if (starts (name, "//")) return url_blank (name (2, N (name)));
  #ifdef OS_ANDROID
  if (starts (name, "content://")) return url_content (name (10, N =
(name)));
  #endif
  if (heuristic_is_path (name, type)) return url_path (name, type);
  if (heuristic_is_default (name, type)) return url_default (name, =
type);
  if (heuristic_is_mingw_default (name, type)) return url_mingw_default =
(name, type);
  if (type !=3D URL_CLEAN_UNIX) {
    if (heuristic_is_http (name)) return url_http (name);
    if (heuristic_is_ftp (name)) return url_ftp (name);
  }
  return url_get_name (name, type);
}


I would like to allow other URLs, for example mail messages in MacOS are =
defined via URL of the form=20

message:%[email protected]%3E


and can be opened form the command line via

open message:%[email protected]%3E


but I cannot create for them hyperlinks in documents, as the schema is =
not recognized by url_general.

Do you see any solution to have a more general approach to URLs? Also =
the code above looks quite repetitive, but maybe there is a reason for =
this.

@Joris??

Max


--Apple-Mail=_B32A4953-B482-44BC-ABE5-89EAF4794EEB
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
	charset=utf-8

<html><head><meta http-equiv=3D"content-type" content=3D"text/html; =
charset=3Dutf-8"></head><body style=3D"overflow-wrap: break-word; =
-webkit-nbsp-mode: space; line-break: after-white-space;">Dear =
all,<div><br></div><div>&nbsp;I=E2=80=99m trying to understand the =
rationale behind the definition of the function url_general in =
url.cpp:</div><div><br></div><div><div style=3D"color: rgb(64, 64, 64); =
background-color: rgb(255, 255, 255); font-family: Menlo, Monaco, =
&quot;Courier New&quot;, monospace; font-size: 12px; line-height: 18px; =
white-space: pre;"><div><span style=3D"color: rgb(70, 224, =
192);">url</span></div><div><span style=3D"color: rgb(99, 99, =
36);">url_general</span> (<span style=3D"color: rgb(70, 224, =
192);">string</span> <span style=3D"color: rgb(9, 89, =
132);">name</span>, <span style=3D"color: rgb(63, 151, 223);">int</span> =
<span style=3D"color: rgb(9, 89, 132);">type</span><span style=3D"color: =
rgb(54, 54, 54);">=3D</span> <span style=3D"color: rgb(63, 151, =
223);">URL_SYSTEM</span>) {</div><div>  <span style=3D"color: rgb(157, =
78, 150);">if</span> (<span style=3D"color: rgb(99, 99, =
36);">starts</span> (<span style=3D"color: rgb(9, 89, =
132);">name</span>, <span style=3D"color: rgb(162, 86, =
55);">"local:"</span>)) <span style=3D"color: rgb(157, 78, =
150);">return</span> <span style=3D"color: rgb(99, 99, =
36);">url_local</span> (<span style=3D"color: rgb(9, 89, =
132);">name</span> <span style=3D"color: rgb(99, 99, 36);">(</span><span =
style=3D"color: rgb(73, 104, 57);">6</span>, <span style=3D"color: =
rgb(99, 99, 36);">N</span> (<span style=3D"color: rgb(9, 89, =
132);">name</span>)<span style=3D"color: rgb(99, 99, =
36);">)</span>);</div><div>  <span style=3D"color: rgb(157, 78, =
150);">if</span> (<span style=3D"color: rgb(99, 99, 36);">starts</span> =
(<span style=3D"color: rgb(9, 89, 132);">name</span>, <span =
style=3D"color: rgb(162, 86, 55);">"file://"</span>)) <span =
style=3D"color: rgb(157, 78, 150);">return</span> <span style=3D"color: =
rgb(99, 99, 36);">url_file</span> (<span style=3D"color: rgb(9, 89, =
132);">name</span> <span style=3D"color: rgb(99, 99, 36);">(</span><span =
style=3D"color: rgb(73, 104, 57);">7</span>, <span style=3D"color: =
rgb(99, 99, 36);">N</span> (<span style=3D"color: rgb(9, 89, =
132);">name</span>)<span style=3D"color: rgb(99, 99, =
36);">)</span>);</div><div>  <span style=3D"color: rgb(157, 78, =
150);">if</span> (<span style=3D"color: rgb(99, 99, 36);">starts</span> =
(<span style=3D"color: rgb(9, 89, 132);">name</span>, <span =
style=3D"color: rgb(162, 86, 55);">"http://"</span>)) <span =
style=3D"color: rgb(157, 78, 150);">return</span> <span style=3D"color: =
rgb(99, 99, 36);">url_http</span> (<span style=3D"color: rgb(9, 89, =
132);">name</span> <span style=3D"color: rgb(99, 99, 36);">(</span><span =
style=3D"color: rgb(73, 104, 57);">7</span>, <span style=3D"color: =
rgb(99, 99, 36);">N</span> (<span style=3D"color: rgb(9, 89, =
132);">name</span>)<span style=3D"color: rgb(99, 99, =
36);">)</span>);</div><div>  <span style=3D"color: rgb(157, 78, =
150);">if</span> (<span style=3D"color: rgb(99, 99, 36);">starts</span> =
(<span style=3D"color: rgb(9, 89, 132);">name</span>, <span =
style=3D"color: rgb(162, 86, 55);">"https://"</span>)) <span =
style=3D"color: rgb(157, 78, 150);">return</span> <span style=3D"color: =
rgb(99, 99, 36);">url_https</span> (<span style=3D"color: rgb(9, 89, =
132);">name</span> <span style=3D"color: rgb(99, 99, 36);">(</span><span =
style=3D"color: rgb(73, 104, 57);">8</span>, <span style=3D"color: =
rgb(99, 99, 36);">N</span> (<span style=3D"color: rgb(9, 89, =
132);">name</span>)<span style=3D"color: rgb(99, 99, =
36);">)</span>);</div><div>  <span style=3D"color: rgb(157, 78, =
150);">if</span> (<span style=3D"color: rgb(99, 99, 36);">starts</span> =
(<span style=3D"color: rgb(9, 89, 132);">name</span>, <span =
style=3D"color: rgb(162, 86, 55);">"ftp://"</span>)) <span style=3D"color:=
 rgb(157, 78, 150);">return</span> <span style=3D"color: rgb(99, 99, =
36);">url_ftp</span> (<span style=3D"color: rgb(9, 89, =
132);">name</span> <span style=3D"color: rgb(99, 99, 36);">(</span><span =
style=3D"color: rgb(73, 104, 57);">6</span>, <span style=3D"color: =
rgb(99, 99, 36);">N</span> (<span style=3D"color: rgb(9, 89, =
132);">name</span>)<span style=3D"color: rgb(99, 99, =
36);">)</span>);</div><div>  <span style=3D"color: rgb(157, 78, =
150);">if</span> (<span style=3D"color: rgb(99, 99, 36);">starts</span> =
(<span style=3D"color: rgb(9, 89, 132);">name</span>, <span =
style=3D"color: rgb(162, 86, 55);">"tmfs://"</span>)) <span =
style=3D"color: rgb(157, 78, 150);">return</span> <span style=3D"color: =
rgb(99, 99, 36);">url_tmfs</span> (<span style=3D"color: rgb(9, 89, =
132);">name</span> <span style=3D"color: rgb(99, 99, 36);">(</span><span =
style=3D"color: rgb(73, 104, 57);">7</span>, <span style=3D"color: =
rgb(99, 99, 36);">N</span> (<span style=3D"color: rgb(9, 89, =
132);">name</span>)<span style=3D"color: rgb(99, 99, =
36);">)</span>);</div><div>  <span style=3D"color: rgb(157, 78, =
150);">if</span> (<span style=3D"color: rgb(99, 99, 36);">starts</span> =
(<span style=3D"color: rgb(9, 89, 132);">name</span>, <span =
style=3D"color: rgb(162, 86, 55);">"//"</span>)) <span style=3D"color: =
rgb(157, 78, 150);">return</span> <span style=3D"color: rgb(99, 99, =
36);">url_blank</span> (<span style=3D"color: rgb(9, 89, =
132);">name</span> <span style=3D"color: rgb(99, 99, 36);">(</span><span =
style=3D"color: rgb(73, 104, 57);">2</span>, <span style=3D"color: =
rgb(99, 99, 36);">N</span> (<span style=3D"color: rgb(9, 89, =
132);">name</span>)<span style=3D"color: rgb(99, 99, =
36);">)</span>);</div><div>  <span style=3D"color: rgb(157, 78, =
150);">#ifdef</span><span style=3D"color: rgb(63, 151, 223);"> =
OS_ANDROID</span></div><div>  <span style=3D"color: rgb(157, 78, =
150);">if</span> (<span style=3D"color: rgb(99, 99, 36);">starts</span> =
(name, <span style=3D"color: rgb(162, 86, 55);">"content://"</span>)) =
<span style=3D"color: rgb(157, 78, 150);">return</span> <span =
style=3D"color: rgb(99, 99, 36);">url_content</span> (<span =
style=3D"color: rgb(99, 99, 36);">name</span> (<span style=3D"color: =
rgb(73, 104, 57);">10</span>, <span style=3D"color: rgb(99, 99, =
36);">N</span> (name)));</div><div><span style=3D"color: rgb(157, 78, =
150);">  #endif</span></div><div>  <span style=3D"color: rgb(157, 78, =
150);">if</span> (<span style=3D"color: rgb(99, 99, =
36);">heuristic_is_path</span> (<span style=3D"color: rgb(9, 89, =
132);">name</span>, <span style=3D"color: rgb(9, 89, =
132);">type</span>)) <span style=3D"color: rgb(157, 78, =
150);">return</span> <span style=3D"color: rgb(99, 99, =
36);">url_path</span> (<span style=3D"color: rgb(9, 89, =
132);">name</span>, <span style=3D"color: rgb(9, 89, =
132);">type</span>);</div><div>  <span style=3D"color: rgb(157, 78, =
150);">if</span> (<span style=3D"color: rgb(99, 99, =
36);">heuristic_is_default</span> (<span style=3D"color: rgb(9, 89, =
132);">name</span>, <span style=3D"color: rgb(9, 89, =
132);">type</span>)) <span style=3D"color: rgb(157, 78, =
150);">return</span> <span style=3D"color: rgb(99, 99, =
36);">url_default</span> (<span style=3D"color: rgb(9, 89, =
132);">name</span>, <span style=3D"color: rgb(9, 89, =
132);">type</span>);</div><div>  <span style=3D"color: rgb(157, 78, =
150);">if</span> (<span style=3D"color: rgb(99, 99, =
36);">heuristic_is_mingw_default</span> (<span style=3D"color: rgb(9, =
89, 132);">name</span>, <span style=3D"color: rgb(9, 89, =
132);">type</span>)) <span style=3D"color: rgb(157, 78, =
150);">return</span> <span style=3D"color: rgb(99, 99, =
36);">url_mingw_default</span> (<span style=3D"color: rgb(9, 89, =
132);">name</span>, <span style=3D"color: rgb(9, 89, =
132);">type</span>);</div><div>  <span style=3D"color: rgb(157, 78, =
150);">if</span> (<span style=3D"color: rgb(9, 89, 132);">type</span> =
<span style=3D"color: rgb(54, 54, 54);">!=3D</span> <span style=3D"color: =
rgb(63, 151, 223);">URL_CLEAN_UNIX</span>) {</div><div>    <span =
style=3D"color: rgb(157, 78, 150);">if</span> (<span style=3D"color: =
rgb(99, 99, 36);">heuristic_is_http</span> (<span style=3D"color: rgb(9, =
89, 132);">name</span>)) <span style=3D"color: rgb(157, 78, =
150);">return</span> <span style=3D"color: rgb(99, 99, =
36);">url_http</span> (<span style=3D"color: rgb(9, 89, =
132);">name</span>);</div><div>    <span style=3D"color: rgb(157, 78, =
150);">if</span> (<span style=3D"color: rgb(99, 99, =
36);">heuristic_is_ftp</span> (<span style=3D"color: rgb(9, 89, =
132);">name</span>)) <span style=3D"color: rgb(157, 78, =
150);">return</span> <span style=3D"color: rgb(99, 99, =
36);">url_ftp</span> (<span style=3D"color: rgb(9, 89, =
132);">name</span>);</div><div>  }</div><div>  <span style=3D"color: =
rgb(157, 78, 150);">return</span> <span style=3D"color: rgb(99, 99, =
36);">url_get_name</span> (<span style=3D"color: rgb(9, 89, =
132);">name</span>, <span style=3D"color: rgb(9, 89, =
132);">type</span>);</div><div>}</div></div></div><div><br></div><div><br>=
</div><div>I would like to allow other URLs, for example mail messages =
in MacOS are defined via URL of the =
form&nbsp;</div><div><br></div><div>message:%3C67dd051e.050a0220.1987fe.5a=
[email protected]%3E</div><div><br></div><div><br></div><div>and can =
be opened form the command line =
via</div><div><br></div><div>open&nbsp;<span style=3D"caret-color: =
rgb(0, 0, 0); color: rgb(0, 0, =
0);">message:%[email protected]%3E</span><=
/div><div><span style=3D"caret-color: rgb(0, 0, 0); color: rgb(0, 0, =
0);"><br></span></div><div><span style=3D"caret-color: rgb(0, 0, 0); =
color: rgb(0, 0, 0);"><br></span></div><div><span style=3D"caret-color: =
rgb(0, 0, 0); color: rgb(0, 0, 0);">but I cannot create for them =
hyperlinks in documents, as the schema is not recognized by =
url_general.</span></div><div><span style=3D"caret-color: rgb(0, 0, 0); =
color: rgb(0, 0, 0);"><br></span></div><div><font color=3D"#000000"><span =
style=3D"caret-color: rgb(0, 0, 0);">Do you see any solution to have a =
more general approach to URLs? Also the code above looks quite =
repetitive, but maybe there is a reason for =
this.</span></font></div><div><font color=3D"#000000"><span =
style=3D"caret-color: rgb(0, 0, 0);"><br></span></font></div><div><font =
color=3D"#000000"><span style=3D"caret-color: rgb(0, 0, =
0);">@Joris??</span></font></div><div><font color=3D"#000000"><span =
style=3D"caret-color: rgb(0, 0, 0);"><br></span></font></div><div><font =
color=3D"#000000"><span style=3D"caret-color: rgb(0, 0, =
0);">Max</span></font></div><div><font color=3D"#000000"><span =
style=3D"caret-color: rgb(0, 0, =
0);"><br></span></font></div></body></html>=

--Apple-Mail=_B32A4953-B482-44BC-ABE5-89EAF4794EEB--


--===============2664533199495182578==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline

X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KVGV4bWFjcy1k
ZXYgbWFpbGluZyBsaXN0ClRleG1hY3MtZGV2QGdudS5vcmcKaHR0cHM6Ly9saXN0cy5nbnUub3Jn
L21haWxtYW4vbGlzdGluZm8vdGV4bWFjcy1kZXYK

--===============2664533199495182578==--