Subject: Re: bug#31927: 26.1; Fragment/bookmark part of URL omitted in default offered by `eww'

From: [email-masked] (N. Jackson)
Date: Thu, 21 Jun 2018 19:11:23 -0400

At 18:47 +0300 on Thursday 2018-06-21, Eli Zaretskii wrote:
>
>> From: [email-masked] (N. Jackson)
>> 
>>   1. In scratch type https://en.wikipedia.org/wiki/Midsummer#History
>> 
>>   2. Move point back into the just-typed URL
>> 
>>   3. M-x eww RET
>> 
>> Expected result:
>> EWW offers https://en.wikipedia.org/wiki/Midsummer#History as the
>> default.
>> 
>> Actual result:
>> EWW offers https://en.wikipedia.org/wiki/Midsummer as the default.
>
> You could customize eww-suggest-uris to add, say
> thing-at-point-url-at-point. I think this should give you what you
> want.

Thank you for the suggestion. But, no, that doesn't quite help.

By default the value of `eww-suggest-uris' is `(eww-links-at-point
url-get-url-at-point eww-current-url)'.

When I add `thing-at-point-url-at-point' it's added to the end of the
list and the behaviour is unchanged presumably because
`url-get-url-at-point' comes first.

However if I set `eww-suggest-uris' to just
`(thing-at-point-url-at-point)', then I see the "correct" behaviour --
that is, the fragment/bookmark part of the URL is picked up.

So the question is, why does `thing-at-point-url-at-point' pick up the
fragment/bookmark part or the URL but `url-get-url-at-point' does not?

That is, removing EWW from the picture altogether:

  0. $ emacs -Q

  1. On a new line in scratch type https://en.wikipedia.org/wiki/Midsummer#History

  2. C-a	; Move point to beginning of the just-typed URL.

  3. M-: (thing-at-point-url-at-point) RET
  => https://en.wikipedia.org/wiki/Midsummer#History

  4. M-: (url-get-url-at-point) RET
  => https://en.wikipedia.org/wiki/Midsummer

Is it expected for these two functions to behave differently here?

(And an additional anomaly: In Step 2, if point is just moved back one
character into the just-typed URL (between the `r' and `y' in
"#History") then:

  3. M-: (thing-at-point-url-at-point) RET
  => https://en.wikipedia.org/wiki/Midsummer#History

  4. M-: (url-get-url-at-point) RET
  => nil

).