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

Optionally disable ignore patterns for some functions. #369

Closed
wants to merge 1 commit into from
Closed

Optionally disable ignore patterns for some functions. #369

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Jan 30, 2016

I saw that ivy-ignore-buffers was added, which is a neat feature. I remember using the feature back when I used ido :-)

This patch adds the ability to optionally disable user-configured filtering at the command invocation. The convention is that if called with a non-nil prefix arg, then user-filtering is turned off. I added this to the new buffer filtering and counsel-find-file as well.

Example usage would look similar to:
C-xb - ivy-switch-buffer with ivy-ignore-buffers filtering
C-uC-xb - ivy-switch-buffer, no filtering
C-xC-f - counsel-find-file with counsel-find-file-ignore-regexp filtering
C-uC-xC-f - counsel-find-file, no filtering

One thing you might want to change in the patch is that I used current-prefix-arg directly rather than (interactive "P") because this would change the positional arguments in counsel-find-file and break any users' scripts that are using it with an initial-input.

If that's not really a concern then it would be better to use (interactive "P"), and make the prefix arg a normal optional argument and easier to use programatically.

@abo-abo
Copy link
Owner

abo-abo commented Jan 30, 2016

Hi, thanks for the effort. But could you make it work in the way Ido works?

I haven't used ignore filtering before, but now that I look into Ido code, it has:

(define-key ido-common-completion-map "\C-a" 'ido-toggle-ignore)

And this ido-toggle-ignore function works for both ido-switch-buffer and ido-find-file. I think it's a good interface, since the user doesn't have to commit to filtering (with prefix arg)- it can be changed at any time.

Maybe something like this for Ivy:

(define-key ivy-minibuffer-map (kbd "C-c C-a") 'ivy-toggle-ignore)

@ghost
Copy link
Author

ghost commented Jan 30, 2016

(define-key ido-common-completion-map "\C-a" 'ido-toggle-ignore)

Ah, I hadn't thought about wanting to toggle in the middle. I think I overlooked that feature back when I was using ido and had my own custom function.

I agree that's a better interface. I'll look into implementing it that way later tonight.

`C-c C-a' will toggle ignore patterns (user-configured filtering).

If ignore patterns are enabled and there are zero candidates
after ignoring, display the ones that match the current text.

This feature is added for `ivy-switch-buffer' and
`counsel-find-file'.
@ghost
Copy link
Author

ghost commented Feb 8, 2016

Okay, sorry for the delay. I've had some time to revisit it.

It now should work like ido:

  • Each ivy invocation will initially apply ignore patterns.
  • C-c C-a will toggle whether to apply ignore patterns.
  • If the current text results in zero matches after ignoring, then ignoring is disabled temporarily (until there is at least one non-ignored match).

@abo-abo abo-abo closed this in 1485e58 Feb 8, 2016
@abo-abo
Copy link
Owner

abo-abo commented Feb 8, 2016

Thanks a lot.

I've made one larger change: instead of using ivy--filter-recompute I use ivy--old-cands, since they effectively do the same thing, and I've used ivy--old-cands for this previously.

One smaller thing is that ivy--exhibit will be called after each interactive command, since it's in the minibuffer's post-command-hook. So in some cases it's not necessary to add it to commands.

I also rewrote the commit message a bit. What I like to do is to use C in magit, magit-commit-add-log on each diff. I recommend this style, since that's very similar to what the people in Emacs core use.

@ghost
Copy link
Author

ghost commented Feb 8, 2016

Sounds good, and thanks for the advice, I'll keep it in mind in the future.

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

1 participant