Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

counsel-find-file-at-point does not respect ffap-url-regexp #1398

Closed
raxod502 opened this issue Jan 7, 2018 · 4 comments

Comments

@raxod502
Copy link
Contributor

commented Jan 7, 2018

Starting from emacs -Q, I load revision f7470fe of counsel.el, set counsel-find-file-at-point to non-nil and set ffap-url-regexp to nil. According to the documentation string of ffap-url-regexp,

Regexp matching the beginning of a URI, for ffap.
If the value is nil, disable URL-matching features in ffap.

this should disable URL-matching features of ffap. And it does, if I run M-x ffap with point at | as shown:

https://google.com|

But if I instead run counsel-find-file, Emacs attempts to ping google.com. This indicates to me that the setting of ffap-url-regexp is not being respected by counsel-find-file.

@abo-abo

This comment has been minimized.

Copy link
Owner

commented Jan 8, 2018

counsel-find-file wasn't designed to conform to ffap-url-regexp, it uses ivy-ffap-url-functions instead.

I'm open to a PR on this, if it isn't difficult. But the current interface should be good enough for customization purposes.

@raxod502

This comment has been minimized.

Copy link
Contributor Author

commented Jan 9, 2018

That makes sense. But I think ivy-ffap-url-functions is unrelated; setting it to nil does not change the behavior above. I investigated, and it actually happens because of the following clause in counsel-find-file:

            :preselect (when counsel-find-file-at-point
                         (require 'ffap)
                         (let ((f (ffap-guesser)))
                           (when f (expand-file-name f))))

(ffap-guesser) returns /https:/google.com, and expand-file-name on that gives /scp:https:/google.com, so Emacs invokes scp and tries/fails to open a connection.

On re-checking my example above, I found that the same happens for M-x ffap, but I didn't notice originally since it doesn't happen until you actually press RET to find the file, rather than immediately as in counsel-find-file.

@abo-abo abo-abo closed this in 0fd333a Jan 9, 2018

@abo-abo

This comment has been minimized.

Copy link
Owner

commented Jan 9, 2018

Thanks, please test.

But I think ivy-ffap-url-functions is unrelated

You're right. I mentioned it because that's how I always open URLs (with C-x C-f M-n). I keep counsel-find-file-at-point the default nil value, that's why I never encountered the buggy behavior.

@raxod502

This comment has been minimized.

Copy link
Contributor Author

commented Jan 10, 2018

The behavior remains the same (i.e. Emacs invokes scp when I type C-x C-f). Maybe it is outside the realm of counsel.el, though?

In any case, I should probably switch to using ivy-ffap-url-functions instead of counsel-find-file-at-point—the former seems more powerful and better designed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.