mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Pratyush Yadav <>
To: Paul Mackerras <>
Subject: Re: [PATCH v2] gitk: Make web links clickable
Date: Fri, 30 Aug 2019 00:02:07 +0530	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <20190829012702.GB3297@blackberry>

On 29/08/19 11:27AM, Paul Mackerras wrote:
> This makes gitk look for http or https URLs in the commit description
> and make the URLs clickable.  Clicking on them will invoke an external
> web browser with the URL.
> The web browser command is by default "xdg-open" on Linux, "open" on
> MacOS, and "cmd /c start" on Windows.  The command can be changed in
> the preferences window, and it can include parameters as well as the
> command name.  If it is set to the empty string then URLs will no
> longer be made clickable.
> Signed-off-by: Paul Mackerras <>
> ---
> v2: Match URLs anywhere, not just after [Bug]Link:.
>  gitk | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 50 insertions(+), 1 deletion(-)
> diff --git a/gitk b/gitk
> index a14d7a1..2a0d00c 100755
> --- a/gitk
> +++ b/gitk
> @@ -7016,6 +7016,7 @@ proc commit_descriptor {p} {
>  # append some text to the ctext widget, and make any SHA1 ID
>  # that we know about be a clickable link.
> +# Also look for URLs of the form "http[s]://..." and make them web links.
>  proc appendwithlinks {text tags} {
>      global ctext linknum curview
> @@ -7032,6 +7033,18 @@ proc appendwithlinks {text tags} {
>  	setlink $linkid link$linknum
>  	incr linknum
>      }
> +    set wlinks [regexp -indices -all -inline -line \
> +		    {https?://[^[:space:]]+} $text]

I know I suggested searching till the first non-whitespace character, 
but thinking more about, there are some problematic cases. Say someone 
has a commit message like:
  Foo bar baz (more details at

Or like:

  Check out,

In the first example, the closing parenthesis gets included in the link, 
but shouldn't be. In the second, the comma after would be 
included in the link, but shouldn't be. So maybe use a more 
sophisticated regex?

A quick Google search gives out the following options [0][1].

[0] gives the following regex:


It is kind of ugly to look at, and I'm not even sure if there are any 
syntax differences with Tcl's regex library.

[1] lists a bunch of regexes and which URLs they work on and which ones 
they don't. The smallest among them I found is:


Again, I'm not sure how well this would work with Tcl's regex library, 
or how commonly these URL patterns appear in actual commit messages.  
Just something to consider.



Pratyush Yadav

  reply	other threads:[~2019-08-29 18:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-26 22:14 [PATCH] gitk: Make web links clickable Paul Mackerras
2019-08-27 15:33 ` Barret Rhoden
2019-08-27 20:32 ` Junio C Hamano
2019-08-29  0:50   ` Paul Mackerras
2019-08-29  3:46     ` Junio C Hamano
2019-08-27 21:58 ` Pratyush Yadav
2019-08-29  1:27 ` [PATCH v2] " Paul Mackerras
2019-08-29 18:32   ` Pratyush Yadav [this message]
2019-09-13 23:33     ` Paul Mackerras
2019-09-14 14:30       ` Pratyush Yadav

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).