noctuid / link-hint.el

Pentadactyl-like Link Hinting in Emacs with Avy
GNU General Public License v3.0
160 stars 22 forks source link

`link-hint-copy-link-at-point` shifts one slash in a url to the start #17

Closed duianto closed 6 years ago

duianto commented 7 years ago

Description

When link-hint-copy-link-at-point is called with the cursor on any other letter in a url than the first, then the url gets copied to the clipboard but, one of the double slashes has moved to the start of the url.

Steps to reproduce

  1. Start Emacs (with the link-hint package installed).
  2. Open a new buffer: Press: C-x b Type: new Press: RET.
  3. Type or copy and paste this url: https://google.com into the new buffer.
  4. Move the cursor to any letter in the url after the first letter h.
  5. Press: M-x Type: link-hint-copy-link-at-point Press: RET

Observed behaviour

The clipboard now contains: /https:/google.com

System info

Windows 10 1607 (OS Build 14393.693) GNU Emacs 25.1.1 (x86_64-w64-mingw32) of 2016-09-17 avy-20170208.148 link-hint-20161216.857

duianto commented 7 years ago

The slash still gets shifted if there's anything written right before https, like this: (https://google.com, it doesn't seem to matter where the cursor is located, link-hint-copy-link results in: /https:/google.com. But the cursor has to be on the url for it to happen with the link-hint-copy-link-at-point command.

This line thisisaurlhttps://google.com results in: /thisisaurlhttps:/google.com.

This probably never happens, but if a backslash is after a url: https://google.com\ and the cursor is on the backslash, when one calls link-hint-copy-link-at-point, then one of the forward slashes also moves to the start: /https:/google.com\.

It's with the latest version: link-hint-20170313.1945

noctuid commented 7 years ago

It looks like url-util.el expects there to be nothing before the url, so it doesn't detect anything at the point. It then falls through to ffap which messes up the url. It looks like thing-at-point doesn't have this problem, so I'll probably switch to using it.

Edit: It looks like url-util will work with other characters before the url but not an open paren.

noctuid commented 6 years ago

The paren case (which is definitely a legitimate issue) is handled correctly now since thing-at-point is used to check for a url first. The backslash case doesn't work by default, but the url regexp can be changed if anyone wants this case to work.