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

Filtering capabilities for preview? #186

Closed
WorldsEndless opened this issue Jan 25, 2021 · 7 comments
Closed

Filtering capabilities for preview? #186

WorldsEndless opened this issue Jan 25, 2021 · 7 comments

Comments

@WorldsEndless
Copy link

I have several cases where consult's auto-preview brings performance-wrecking effects. Yet I still want to use consult as it provides various things that raw Selectrum doesn't cover. Consider my examples:

1- consult-bookmark. My bookmarks may be many things: buffers, PDFs, web pages, etc. But the one that really had an issue was my passwords.org.gpg file. If not recently opened, it pops up a password entry even for preview, which makes for a confusing disruption to flow.

2- consult-buffer. Because I'm on exwm and many of my buffers are exwm ones which cannot be shared, the moment I pass over one of them with consult, it steals the exwm buffer (e.g. a browser instance) from the monitor that was looking at it. So I use a different solution.

I don't have high hopes for a solution, because I think my usecases simply disagree with Consult's fundamental philsophy; but I thought I'd bring it up in case there's anything to be done, or if this helps prompt any ideas.

@minad
Copy link
Owner

minad commented Jan 25, 2021

I suggest you disable previews for the commands where they disrupt you. Besides that we could thing about using some filtering/exclusion lists.

  1. consult-bookmark: exclusion list could help.
  2. consult-buffer: This could also be solved by excluding X buffers. I somehow consider this an EXWM bug. EXWM can only show an X window in a single buffer. This is not how Emacs buffers usually work.

For now my recommendation is to disable previews where they don't work for you.

@minad minad added discussion Needs feedback, open for discussion feature New feature or request labels Jan 25, 2021
@minad minad changed the title vain hope: consult without preview? Filtering capabilities for preview Jan 25, 2021
@minad minad changed the title Filtering capabilities for preview Filtering capabilities for preview? Jan 25, 2021
@WorldsEndless
Copy link
Author

WorldsEndless commented Jan 25, 2021 via email

@minad
Copy link
Owner

minad commented Jan 25, 2021

  1. How do I add exclusions? This sounds perfect

This feature does not exist yet, at least not in a simple form. You can pull it off by overwriting the :preview function in the consult-config settings of the consult-buffer and consult-bookmark commands. But this requires a bit of familiarity with the code base. If you are interested you can give it a try and maybe create a pull request.

  1. I agree. I wonder if exwm can do anything about this.

This is hard, since this is a restriction of the X window system. I am really not familiar with ugly X internals. I guess an EXWM for wayland will fix this ;)

@minad
Copy link
Owner

minad commented Jan 25, 2021

@WorldsEndless One obvious interim solution I should have mentioned - you can set preview-keys per command as documented in the README. This allows you to use automatic preview for most commands but manual preview for the commands which are critical in your setup. By setting a manual preview key, preview behaves more like an action.

@minad minad added enhancement and removed discussion Needs feedback, open for discussion feature New feature or request labels Jan 28, 2021
@WorldsEndless
Copy link
Author

Ah -- consult-config with preview-key was PRECISELY what I needed. Now my config looks like so and works perfectly:

  (use-package consult
    :straight (consult :type git :host github :repo "minad/consult")
    :bind (("C-c s" . consult-outline)
	   ("C-x j j" . consult-bookmark)
	   ("M-s l" . consult-line)
	   ("C-h k" . tsa/consult-descbinds)
	   ("M-y" . consult-yank-pop)
	   ("<help> a" . consult-apropos))
    :custom
    (consult-config `((consult-bookmark :preview-key nil)
		      (consult-buffer :preview-key ,(kbd "M-p"))))
    :config
    (fset 'multi-occur #'consult-multi-occur))

@minad
Copy link
Owner

minad commented Feb 2, 2021

I am glad this fixes this solution is satisfactory for you, since I didn't feel inclined to implement additional support for special preview filters on top. Why are you not using a preview key for consult-bookmark? Note that you can also use multiple preview keys, e.g. S-up S-down and bind these keys to selectrum-next-candidate etc.

@minad
Copy link
Owner

minad commented Feb 4, 2021

Note for future visitors of this issue - consult-buffer has configurable consult-buffer-sources now. This means it is possible to create multiple buffer sources with different preview behavior. In the case of EXWM it makes sense to create two buffer sources, one for the non-X buffers with preview and one for the X-buffers without preview. See also #204.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants