noctuid/link-hint.el

link-hint-open-link not working as intended in help?

Closed this issue · 23 comments

This looks like a cool package. I just happened to see it in the melpa feed. What interested me was the fact that it also works with plain text urls. At first I was a bit unsure as to what exactly I'm supposed to be using, I suggest perhaps adding an example configuration.

I did C-h f region-active-p to test if it does also provide the functionality that ace-link provides. Once there, I ran M-x link-hint-open-link and it seems to jump to the first link and open that, even though there are other links in the page. Am I doing something incorrectly? By comparison, ace-link does show the link shortcuts as I would expect after pressing o.

My configuration consists solely of:

(use-package link-hint
  :bind
  ("C-c l o" . link-hint-open-link)
  ("C-c l c" . link-hint-copy-link))

Though as I said, I ran the command via M-x, not via a bind, to rule that out.

Your configuration is correct. This is a bug unfortunately; I think it is the same as #6. My first guess is that this may be a recently introduced bug because I can't remember having any problems like this before. I apologize for the inconvenience and will try to fix it as soon as I get the chance.

I will also try to improve the configuration section of the readme.

Edit:
I don't think this is a new bug actually. This is because of how link-hint--find-property is working currently. Instead of using ..-property-change functions, I should probably do things the same way ace-link does and use text-property-(any|not-all) (which should also fix #5). I may also need to change how I'm handling invisible areas...

This probably was a recent bug actually as info-mode link hinting was completely broken. I'm not quite sure what the cause of the bug was, but this way of finding links by properties fixes several issues. Please test and tell me if you still encounter any problems.

As for improving the readme, I have added an example configuration section. Once I add a few more avy related options, I will mention those settings in the readme as well. Let me know if you have any other suggestions.

Thanks, it's now showing them and it does work, but the little hint shows up on top of/replacing the first character, so it makes it kind of tricky to tell what the link is sometimes. Comparatively, ace-link shows the hint before the link.

link-hint:

link hint

ace-link:

ace link

You can set the avy style you want using avy-style or link-hint-avy-style (if you only want this style for link-hint.el). I've added a section about overriding avy settings to the readme.

For example, to use the same style as ace-link does:

(setq link-hint-avy-style 'pre)

Thanks! I wasn't aware of that.

It works perfectly in help pages now it seems, but now I've noticed that it does nothing in regular files with plain text urls. It did previously.

I can't reproduce this. Can you give an example? Are there any messages? I fixed a bug this morning that was breaking things if there was only a single link. If that was the situation, you'll need to update to the newest commit or wait for the next melpa update (sorry about this).

Ah yes, it's when there's a single link. As soon as I create more links, it works.

However, I did notice that the styling gets a bit messed up. It's not a huge deal, but it would be nice if this didn't happen:

strings:

styling bug

comments:

styling bug2

I'll wait for the next round of melpa updates and report back. Thanks again, no worries at all!

I have no idea why that's happening; it doesn't happen for me. What theme are you using (is that solarized-light)? Are the urls normally yellow? Is it just the "h" that is being messed up?

Yep, it's solarized-light from https://github.com/bbatsov/solarized-emacs .

It does just seem to be the first character that this is happening to. It seems like the style of the content before/around the hint is leaking into the first letter of the thing being hinted.

I tried to figure out a way to make it so that I could do something like describe-face or something on the first letter to try to figure something out, but I can't seem to manage to do it. The point wont end up on the first letter once I trigger the command, and even if it did, as soon as I do something like M-x or eval-expression, the hint goes away.

For some reason, this is caused by having goto-address-mode on. You don't really need goto-address-mode if you are exclusively using link-hint to open urls, but I'll look into it since it's reasonable that you might still want to have urls highlighted and as buttons. It may be due to some negative interaction between avy and goto-address-mode; this happens for ace-link's ace-link-addr as well.

The only thing relating to urls that I have is:

(use-package goto-addr
  :ensure nil
  :init
  (add-hook 'prog-mode-hook #'goto-address-prog-mode)
  (add-hook 'text-mode-hook #'goto-address-mode))

Haha, yeah. Reading your comment now.

You might want to make an issue on ace-link or avy. I'm guessing abo-abo will be more likely to figure out why this happens.

Yeah thanks. I wasn't aware that goto-address-mode is what's highlighting the urls. To be honest, I would still prefer to be able to click on urls and more importantly have them highlighted. I figure like if I already have my hand on my mouse, I'd like to be able to open the link in a natural manner with it, rather than having to context switch and run my binding.

So if you could get it to play nicely, I would really really appreciate it! I do understand and agree that it's likely that I'll be using link-hint in most cases. But I would love to have both!

In the worst case, it's mainly a cosmetic issue so it's nothing I can't live with. If there's any way I can help, please let me know.

Will do, thanks. Do you have an idea on how I should word it so that blame isn't somehow deflected onto link-hint?

I figure you're more aware of avy and related terminology so that you could better make the case, but I'm perfectly fine with filing the issue myself.

By the way, it seems that the most recent commit on ace-link is related to goto-address-mode: abo-abo/ace-link@ef67652

The issue also happens for ace-link if you're using the ace-link-addr command for me, so it's a bug for ace-link too. If text urls are the main reason you tried out link-hint, you may want to switch back to ace-link (since it supports them if you have goto-address-mode enabled).

Yes, the command added in that commit causes the same problem.

Ah okay thanks! I suppose I'll file an issue on that repo since it seems most relevant there.

If both have the same bug, I still think I prefer yours, since like you say you have one command for everything instead of separate commands for each!

abo-abo was awesome; seems to have fixed it in avy itself!

abo-abo/ace-link#24

@blaenk Good to see it fixed.
(edited to remove mention of non-existent bug)

Actually I think it was being caused by something unrelated to my package, and I can't reproduce it. Feel free to update.

Seems fine to me so far!