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

Robustify counsel occur #1845

Closed
wants to merge 2 commits into from
Closed

Conversation

mookid
Copy link
Contributor

@mookid mookid commented Dec 8, 2018

see be98b75

the implemented strategy: always prefix matches with ./ or ., regardless of whether the tool (ie, ag or rg or git-grep or pt or......) adds it.

As mentioned, this fixes the broken navigation from the results of ag-based ivy-occur buffers.

counsel.el Outdated
@@ -1491,6 +1491,9 @@ If NO-ASYNC is non-nil, do it synchronously instead."
nil " *counsel-gg-count*")
nil))))

(defun counsel--normalize-grep-match (str)
(if (string-prefix-p "\\.[/\\]" str) str (concat "./" str)))
Copy link
Collaborator

@basil-conto basil-conto Dec 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be string-match-p?

Copy link
Contributor Author

@mookid mookid Dec 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hum I don't want to match a path such as "foo./bar"

Copy link
Contributor Author

@mookid mookid Dec 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh got it. string-prefix-p does not handle regexps

counsel--normalize-grep-match: new function.
counsel-git-grep-occur: use the new function.
counsel--grep-mode-occur: use the new function.
counsel-grep-like-occur: force normalization of completion candidates.
@abo-abo
Copy link
Owner

@abo-abo abo-abo commented Dec 12, 2018

Thanks.

@mookid mookid deleted the robustify_counsel_occur branch Dec 12, 2018
@basil-conto
Copy link
Collaborator

@basil-conto basil-conto commented Dec 14, 2018

Either counsel--normalize-grep-match should call ivy--starts-with-dotslash or the latter function should be deleted along with its tests. At the moment it's not being used anywhere.

Re: #1846

@abo-abo
Copy link
Owner

@abo-abo abo-abo commented Dec 17, 2018

@basil-conto Thanks.

basil-conto added a commit that referenced this issue Apr 25, 2020
(ivy--dirname-p, ivy--magic-file-slash): Simplify now that Ivy
requires Emacs 24.5 or later by using string-suffix-p instead of
slower regexp matching.
(ivy--occur-insert-lines): Escape leading dot in regexp by using
existing helper ivy--starts-with-dotslash.

Re: #1817, #1845, #1846
astoff pushed a commit to astoff/swiper that referenced this issue Jan 1, 2021
astoff pushed a commit to astoff/swiper that referenced this issue Jan 1, 2021
astoff pushed a commit to astoff/swiper that referenced this issue Jan 1, 2021
(ivy--dirname-p, ivy--magic-file-slash): Simplify now that Ivy
requires Emacs 24.5 or later by using string-suffix-p instead of
slower regexp matching.
(ivy--occur-insert-lines): Escape leading dot in regexp by using
existing helper ivy--starts-with-dotslash.

Re: abo-abo#1817, abo-abo#1845, abo-abo#1846
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants