Subject: bug#56312: 28.1; URI discrepancy between `thing-at-point' and `org-open-at-point'

From: Teika Kazura <[email-masked]>
Date: Thu, 30 Jun 2022 13:44:13 +0900 (JST)

Hello, Emacs world.

(An error reproduction code soon follows.)
When a cursor is on a url, (thing-at-point 'url) and (org-open-at-point) sometimes return different urls; more precisely, the delimiter sets of two seem to differ.

It's a corner case, and I don't think there exists a "correct" set of delimiters. But IMHO the behavior should be unified, by unifing the code. This makes Emacs' behavior more predictable / customizable, and code maintenance easier.

Since org-mode is now a part of Emacs, it possibly can rely on thing-at-point. (FYI: `browse-url-url-at-point' uses thing-at-point.)

How to reproduce it:
------------------------------------------------------------------------
#!/bin/bash

cat > /tmp/foo.txt << EOF
https://www.amazon.com/（"false"-parethesis）Learning-Emacs-Third-Debra-Cameron/dp/0596006489/ref=sr_1_1?keywords=emacs+gnu&sr=8-1
EOF

cat > /tmp/foo.el <<EOF
(find-file "/tmp/foo.txt")
(set-buffer "foo.txt")
(require 'org)
(message "tap returns: *%s*" (thing-at-point 'url))
(org-open-at-point)
EOF

emacs -Q -l /tmp/foo.el

# Caution! rm -f will follow.
# rm -f /tmp/foo.txt /tmp/foo.el
-------------------------------------------------------------------------
In the above example, the url contains a special Japanese parenthesis U+ff08, not an ascii one. thing-at-point cuts before it, but (caution: your browser will be called) org-open-at-point opens the entire line.

As I said above, it's not likely that there is an absolutely "correct" delimiter set. In the above case, the Japanese parenthesis is a part of a valid URL [1]. But it also is a commonly used punctuation mark, so it's rational to treat it as a URL boundary.
(Sorry, I'm completely ignorant about the syntax table.)

[1] The above example is hypothetical, but there does exist such URLs in Japanese Amazon.

Thank you very much indeed for developing Emacs.
Best regards.

Teika