abo-abo / avy

Jump to things in Emacs tree-style
1.72k stars 110 forks source link

The link part of org-mode links is ignored. #261

Closed whatacold closed 5 years ago

whatacold commented 5 years ago

Hi,

I noticed there is an issue that avy-goto-char will only match the description part of org link:

  1. git clone https://github.com/abo-abo/avy.git and cd avy

  2. emacs -Q -l avy.el to run a fresh emacs instance

  3. Open a org-mode buffer and insert below two lines, then M-x org-toggle-link-display to display it literally.

    github [[https://github.com/abo-abo/swiper][abo-abo/swiper - github.com]]

  4. M-x avy-goto-char RET g will only highlight the gs in the first line and second one of the second line, i.e. the one in https://github.com/abo-abo/swiper is ignored.

abo-abo commented 5 years ago

Thanks, please test.

duianto commented 5 years ago

It seems to be working for M-x avy-goto-char RET g now:

Before

before

After

after

But the same issue remains for other avy-goto-* commands

A quick test showed that these commands still ignore the url part of the link:

avy-goto-subword-0
avy-goto-subword-1
avy-goto-symbol-1
avy-goto-symbol-1-above (with the cursor below the org link)
avy-goto-symbol-1-below (with the cursor above the link)
avy-goto-char-timer

I'm not sure how a symbol is defined, but if avy-goto-symbol-1 targets the first character in a "group" of characters, then those commands probably work as expected since github inside the link part.

whatacold commented 5 years ago

It works fine for avy-goto-char now, but I can confirm that it remains at least for avy-goto-char-timer.

@duianto Thanks for helping test.

abo-abo commented 5 years ago

@duianto Thanks for testing, I've added fixes for the functions you mentioned. Could not reproduce avy-goto-symbol-1-* though, please add a repro scenario.

duianto commented 5 years ago

I followed the steps above:

Both cases show (the same as the "Before" screenshot above):

without the g in the links word github having a target.

Shows the same thing, a missing link g target, but the a and s targets are swapped (I'm guessing because the targets are set from the cursor outwards.

P.S. But as I said in the previous comment, if symbol looks for the first char of: https://github.com/abo-abo/swiper then it won't add a target to the g in the middle. In that case it's probably working as expected.

duianto commented 5 years ago

Just tested the latest version avy-20190121.1644 and:

avy-goto-subword-0
avy-goto-subword-1
avy-goto-char-timer

all work as expected, an avy goto target is added to the link as well. 👍

abo-abo commented 5 years ago

In that case it's probably working as expected.

That's what I suspected. See the doc:

Jump to the currently visible CHAR at a symbol start

In your example, "g" is not at a symbol start. So it works as expected. Thanks for testing.