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

Command wishlist #6

Closed
20 tasks done
minad opened this issue Nov 29, 2020 · 918 comments
Closed
20 tasks done

Command wishlist #6

minad opened this issue Nov 29, 2020 · 918 comments
Labels
discussion Needs feedback, open for discussion

Comments

@minad
Copy link
Owner

minad commented Nov 29, 2020

todo/open for discussion

Seems feature complete? ;)

done

  • consult-info dynamic info search based on consult--dynamic-collection. See Info manual commands needed #634 and Add a ‘consult-info’ command. #128 for an earlier draft. The wiki contains a version of consult-info too.
  • More efficient consult-line-multi reimplementation based on consult--dynamic-collection (See More efficient consult-line-multi #644)
  • consult-lsp, available as a separate package
  • consult-yasnippet, available as a separate package
  • consult-eglot, available as a separate package
  • consult-org-clock-in, consult-org-heading, consult-org-agenda (See consult-org-heading, consult-org-agenda #276)
  • Add narrowing to consult-outline by using the outline-level function (Add narrowing to consult-outline #277)
  • consult-xref show function, see xref branch and Add consult-xref. #216 implemented
  • consult-outline extension for shell prompts (originally consult-prompt which gives a list of all shell/terminal prompts), see consult-prompt UI #130 discussion. Instead of implementing an extension/extra command, set outline-regexp=eshell-prompt-regexp in the eshell-mode-hook as documented in the wiki.
  • consult-focus-lines which uses overlays in contrast to consult-keep-lines implemented
  • consult-keep-lines with preview and filtering using the completion-style implemented
  • consult-kmacro implemented
  • consult-completion-at-point implemented
  • consult-flycheck (see consult-flycheck #51, cycle through errors with preview) implemented
  • consult-imenu implemented
  • consult-flymake implemented
  • consult-global-mark support for global mark ring, ideally consult-mark should show both local and global marks and via l and g narrowing via can either narrow to the local ring or the global one implemented
  • consult-major-command list commands corresponding to current major mode, similar to amx-major-mode-commands implemented as consult-mode-command
  • consult-ripgrep (see [WIP] Add first implementation of consult-search #68, consider using xref facilities, xref-search-program, xref-matches-in-files) See also https://github.com/travitch/completing-read-xref.el implemented
  • consult-match jump to matches in the buffer, needs dynamic recomputation of candidates, similar to swiper-isearch, implemented as consult-line-multi.

rejected

Contributions and new proposals are welcome. Note that Consult focuses on Emacs core functionality. Integrations with external packages should be provided by external packages, e.g., consult-lsp, consult-notmuch, ...

In many cases it is sufficient to use the built-in Emacs completing-read functionality. Therefore dedicated consult-* packages may not be necessary.

@minad minad added the feature New feature or request label Nov 29, 2020
@doolio
Copy link

doolio commented Nov 29, 2020

An equivalent to counsel-linux-app would be great.

@minad
Copy link
Owner Author

minad commented Nov 29, 2020

@doolio For now I am focused on the core commands, which are Emacs related and uncontroversial. But certainly some of the others like accessing linux apps could be added as well. Since I am not experienced with ivy, I would love some kind of usage statistics or experience reports regarding the most used commands. For example there is counsel-rythmbox which I doubt to be useful for many people. Then there are other commands which are already covered better by other packages I guess.

@Luis-Henriquez-Perez
Copy link

I would really like the selectrum-info command. Also, I'd like a command for selecting org capture templates akin to counsel-org-capture-string and something to select org tags like counsel-org-tag. I have implementations in my config for the last two if you want them.

@tomfitzhenry
Copy link
Contributor

consult-comint-ring that read from (ring-elements comint-input-ring) would be useful. Users would bind that to C-r in shell-mode-map, to behave like fzf in bash.

@tomfitzhenry
Copy link
Contributor

consult-imenu that browses imenu via completing-read.

@tomfitzhenry
Copy link
Contributor

consult-completion-at-point that performs completion-at-point using completing-read. I use company-mode but sometimes there are so many results that I'd like to narrow them via completing-read.

Apologies for the multiple messages. I took inspiration from my current init file, and my todo list.

@doolio
Copy link

doolio commented Nov 30, 2020

For now I am focused on the core commands, which are Emacs related and uncontroversial.

That makes sense.

@minad
Copy link
Owner Author

minad commented Nov 30, 2020

@Luis-Henriquez-Perez

I would really like the selectrum-info command. Also, I'd like a command for selecting org capture templates akin to counsel-org-capture-string and something to select org tags like counsel-org-tag. I have implementations in my config for the last two if you want them.

Yes, please open PRs! We can discuss over there then!

@minad
Copy link
Owner Author

minad commented Nov 30, 2020

@tomfitzhenry

consult-imenu that browses imenu via completing-read.

Is this needed? imenu already uses completing-read for me? Take a look at the function imenu-choose-buffer-index. What should be different?

consult-completion-at-point that performs completion-at-point using completing-read. I use company-mode but sometimes there are so many results that I'd like to narrow them via completing-read.

Same question here. I am not sure if this should be part of consult. I think selectrum alone can already do this by itself. What do you use for completion? Selectrum?

@tomfitzhenry
Copy link
Contributor

Is this needed? imenu already uses completing-read for me? Take a look at the function imenu-choose-buffer-index. What should be different?

Ah yes, imenu uses completing-read (recursively) as it descends the imenu tree, setting the list of candidates to that node's children. i.e. multiple calls to completing-read are made. This interface feels awkward, since I typically know the leaf I want, but not the imenu tree structure.

I'm suggesting consult-imenu traverses the entire imenu tree and sets the list of candidates to all tree leafs. i.e. one call to completing-read is made.

This is what counsel-imenu does.

@tomfitzhenry
Copy link
Contributor

Same question here. I am not sure if this should be part of consult. I think selectrum alone can already do this by itself. What do you use for completion? Selectrum?

I use icomplete. It sounds like Selectrum somehow manages to act as the Completion buffer. I'll look into it, thanks.

@minad
Copy link
Owner Author

minad commented Nov 30, 2020

@tomfitzhenry

Ah yes, imenu uses completing-read (recursively) as it descends the imenu tree, setting the list of candidates to that node's children. i.e. multiple calls to completing-read are made. This interface feels awkward, since I typically know the leaf I want, but not the imenu tree structure.

Thank you I got it. It is flattening the imenu. There is already flimenu for that but I look into if I can do anything about that here. flimenu also looks like a pretty simple package which does nearly nothing. The confusion thing is that the imenu on my Emacs already looks flat, I don't know what is causing this. But my overall feeling is that consult is not the right place to add something like this if it can be easily solved on another level.

@minad minad added the discussion Needs feedback, open for discussion label Nov 30, 2020
@tomfitzhenry
Copy link
Contributor

There is already flimenu for that

Perfect, thanks.

@oantolin
Copy link
Contributor

oantolin commented Dec 4, 2020

consult-completion-at-point that performs completion-at-point using completing-read. I use company-mode but sometimes there are so many results that I'd like to narrow them via completing-read.

I wrote this function, @tomfitzhenry:

(defun completing-read-in-region (start end collection &optional predicate)
  "Prompt for completion of region in the minibuffer if non-unique.
Use as a value for `completion-in-region-function'."
  (if (and (minibufferp) (not (string= (minibuffer-prompt) "Eval: ")))
      (completion--in-region start end collection predicate)
    (let* ((initial (buffer-substring-no-properties start end))
           (limit (car (completion-boundaries initial collection predicate "")))
           (all (completion-all-completions initial collection predicate
                                            (length initial)))
           (completion (cond
                        ((atom all) nil)
                        ((and (consp all) (atom (cdr all)))
                         (concat (substring initial 0 limit) (car all)))
                        (t (completing-read
                            "Completion: " collection predicate t initial)))))
      (if (null completion)
          (progn (message "No completion") nil)
        (delete-region start end)
        (insert completion)
        t))))

To use it you just (setq completion-in-region-function #'completing-read-in-region). I'll contribute it soon to consult: even if selectrum already does this, icomplete users would benefit.

@minad
Copy link
Owner Author

minad commented Dec 4, 2020

@oantolin Cool, please do!

@Luis-Henriquez-Perez
Copy link

This might be out of the scope of consult but here goes. I have also wanted a richer set of org refile functions. Right now org-refile is very limited in the sense that the files have to be in the org-refile-targets. Would be nice to have a function that could refile to any org buffer. Since it seems consult will contain generally useful commands, this might be a good addition.

@minad
Copy link
Owner Author

minad commented Dec 4, 2020

@Luis-Henriquez-Perez please describe a bit more precisely what these functions are supposed to do. It is nice to have a bit more context. There is a plethora of functionality in Emacs and not everyone is aware of everything.

@Luis-Henriquez-Perez
Copy link

The function would move subtrees to different places. They would be very similar to the function that doom has to address this same problem.

@oantolin
Copy link
Contributor

oantolin commented Dec 4, 2020

I sometimes wish ispell used completing-read when prompting you for a spelling correction.

@okamsn
Copy link
Contributor

okamsn commented Dec 4, 2020

I sometimes wish ispell used completing-read when prompting you for a spelling correction.

Have you tried the package flyspell-correct? It uses completing-read (or other UIs) to select corrections, and also allows jumping to the underlined Flyspell errors.

@oantolin
Copy link
Contributor

oantolin commented Dec 4, 2020

Thanks, @okamsn! I'll be sure to check it out, it looks like there are a bunch of UIs to choose from (I bet I'll land on avy). By the way, I think I fixed your file dialog problem with embark.

@oantolin
Copy link
Contributor

oantolin commented Dec 6, 2020

What about a function to open a file in the default application for it according to the operating system? It would use open on Windows and Mac OS, xdg-open on Linux and cygstart undey Cygwin. Counsel has something like this in counsel-locate-action-extern and Embark has it in embark-open-externally.

@minad
Copy link
Owner Author

minad commented Dec 6, 2020

@oantolin I think counsel-locate-action-extern or embark-open-externally fits better into an action library, like Embark, not here.

@oantolin
Copy link
Contributor

oantolin commented Dec 6, 2020

I am completely fine with that, @minad. But for future reference, can you explain why you think it fits better into an action library? Here's the code from embark (suggestively renamed :P). As you can see it has no embark-specific details in it at all. It is a useful function, that uses completion to select a file and then opens it:

(defun consult-open-externally (file)
  "Open FILE using system's default application."
  (interactive "fOpen: ")
  (if (and (eq system-type 'windows-nt)
           (fboundp 'w32-shell-execute))
      (w32-shell-execute "open" target)
    (call-process (pcase system-type
                    ('darwin "open")
                    ('cygwin "cygstart")
                    (_ "xdg-open"))
                  nil 0 nil
                  (expand-file-name file))))

Is it because it relies on external commands that you think it shouldn't be in consult? (That would be a reasonable reason, but is it your reason?)

@minad
Copy link
Owner Author

minad commented Dec 6, 2020

Sorry, I misunderstood - I thought it is only used as an action, I should have looked more closely. What you propose selects a file, opens it externally, that's perfectly fine and I think it belongs here. Please make a PR. Why is the counsel function called like this with the "action" in the name?

EDIT: I just saw (defalias 'counsel-find-file-extern #'counsel-locate-action-extern)

@amosbird
Copy link
Contributor

amosbird commented Aug 6, 2023

  1. Is there an option to configure consult to always recenter the selected line during preview?
  2. Is there an option to configure consult-line-multi to search only on current buffer?

@oantolin
Copy link
Contributor

oantolin commented Aug 6, 2023

2. Is there an option to configure consult-line-multi to search only on current buffer?

Why not just use consult-line (no multi) for that?

@amosbird
Copy link
Contributor

amosbird commented Aug 6, 2023

Why not just use consult-line (no multi) for that?

Because it's faster.

@colonelpanic8
Copy link

@IvanMalison I still don't understand what helm-apropos does (maybe combine multiple symbol sources?), but there is also the builtin describe-symbol which has all the symbols. You can use it the same way as described in #6 (comment). Are there additional features offered on top by helm-apropos?

yeah I just wanted describe-symbol. Thanks!

@minad
Copy link
Owner Author

minad commented Aug 6, 2023

@amosbird

  1. See consult-after-jump-hook.
  2. Pass a QUERY argument with a predicate to consult-line-multi. This is a bit indirect, since the argument is meant to filter buffers flexibly by passing :exclude, :mode, etc.
(defun consult-line-multi-current-buffer ()
  (interactive)
  (consult-line-multi
   (list :predicate (lambda (buf) (eq buf (current-buffer))))))

@oantolin
Copy link
Contributor

oantolin commented Aug 6, 2023

If consult-line-multi with a single buffer is really faster than consult-line as @amosbird said, should you replace consult-line with that specialization, @minad?

@amosbird
Copy link
Contributor

amosbird commented Aug 7, 2023

It seems consult-after-jump-hook doesn't take effect in commands like consult-buffer, consult-recent-file, etc.

@minad
Copy link
Owner Author

minad commented Aug 7, 2023 via email

@oantolin
Copy link
Contributor

oantolin commented Aug 7, 2023

Oh, I guess I had never tried consult-line-multi before, @minad. It has the same two-step search & filter UX that consult-grep has, but both searching and filtering are done in Emacs. If I understood correctly, the search part does re-search-forward on the first component regexp and for each matching line checks if all other components are found there as well. So this is an Emacs Lisp loop for what (let ((completion-regexp-list ...)) (all-completions ...)) does with a loop in C. So whether consult-line or a single-buffer variant of consult-line-muti is faster depends on your completion styles: if you use flex exclusively, then single-buffer consult-line-multi wins; if you use, say, Orderless with only orderless-literal, then probably consult-line wins.

Do people really use the filtering stage of consult-line-multi? Probably not, I would guess, since the search part is already basically a reimplementation of Orderless. :)

For buffer switching based on buffer contents consult-line-multi looks great, specially the default of using only buffers in the current project seems really handy; but it looks like for me personally a single-buffer variant of consult-line-muti would not be very useful.

@minad
Copy link
Owner Author

minad commented Aug 7, 2023 via email

@oantolin
Copy link
Contributor

oantolin commented Aug 7, 2023

The main difference is the startup overhead.

Of course! I should have realized that! You keep trying to teach me allocation is expensive in Emacs, @minad, and I keep not quite getting it. 😄

@amosbird
Copy link
Contributor

amosbird commented Aug 7, 2023

The main difference is the startup overhead. consult-line has to allocate all the candidates first, while consult-line-multi collects the candidates given the input.

That's the exact motivation :) especially for large buffers

@jgarte
Copy link
Contributor

jgarte commented Aug 17, 2023

Hi,

Any idea why consult-line does not work with icomplete-vertical?

image

GNU Emacs 29.0.92 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.37, cairo version 1.16.0)

I'm using version 0.35 of consult that is in ELPA:

https://elpa.gnu.org/packages/consult.html

@oantolin
Copy link
Contributor

@jgarte It does work with icomplete-vertical, but to get the results most people expect you need to configure your completion-styles. What completion-styles are you using? For consult-line you probably want something that can match substring in the middle of the line, so I'd recommend the substring or flex completion styles. For more flexibility, I recommend the orderless completion style (which I believe is also recommended in the consult documentation).

@jgarte
Copy link
Contributor

jgarte commented Aug 17, 2023

Hi,

This is what I currently have set in my emacs config regarding icomplete-vertical:

https://git.sr.ht/~whereiseveryone/emacsaroni/tree/master/item/init.el#L11

so I'd recommend the substring or flex completion styles.

But isn't flex the default style and currently is not working with consult?

I'll look into substring. Thanks!

I'm currently not using orderless but I am using marginalia.

@oantolin
Copy link
Contributor

But isn't flex the default style and currently is not working?

No, it isn't on by default. It is however the style used by fido-vertical-mode, maybe that's what you were thinking of.

@jgarte
Copy link
Contributor

jgarte commented Aug 17, 2023

TLDR:

Should I be enabling your icomplete-vertical?

https://github.com/oantolin/icomplete-vertical

@jgarte
Copy link
Contributor

jgarte commented Aug 17, 2023

Or setting one of these?

(use-package icomplete-vertical
  :ensure t
  :demand t
  :custom
  (completion-styles '(partial-completion substring))
  (completion-category-overrides '((file (styles basic substring))))
  (read-file-name-completion-ignore-case t)
  (read-buffer-completion-ignore-case t)
  (completion-ignore-case t)
  :config
  (icomplete-mode)
  (icomplete-vertical-mode)
  :bind (:map icomplete-minibuffer-map
              ("<down>" . icomplete-forward-completions)
              ("C-n" . icomplete-forward-completions)
              ("<up>" . icomplete-backward-completions)
              ("C-p" . icomplete-backward-completions)
              ("C-v" . icomplete-vertical-toggle)))

@oantolin
Copy link
Contributor

No, using my icomplete-vertical wouldn't make any difference. Try something like (setq completion-styles '(basic partial-completion substring)). Or using fido-vertical-mode instead of icomplete-vertical-mode.

@jgarte
Copy link
Contributor

jgarte commented Aug 17, 2023

Ok, consult-line works now after eval-defuning the last thing I posted:

image

@jgarte
Copy link
Contributor

jgarte commented Aug 17, 2023

What you posted also works. Thanks!

@jgarte
Copy link
Contributor

jgarte commented Aug 17, 2023

@oantolin Do you really use viper as your daily driver or are you just meming 😹

I tried using it once for a period but now I am on meow which feels nice with kmacro multiple cursors and whatnot.

https://github.com/oantolin/emacs-config/blob/master/viper

@oantolin
Copy link
Contributor

I hardly ever use viper, but if I ever do use it, I want that configuration, @jgarte. In general I'm not a fan of modal user interfaces. Even enable-recursive-minibuffers = nil feels too modal to me.

@minad
Copy link
Owner Author

minad commented Aug 17, 2023

@oantolin I like the expert level. It is even quoted for additional karma. :)

(setq viper-expert-level '5)

@jgarte
Copy link
Contributor

jgarte commented Aug 19, 2023

@oantolin Ok, the pain is too great with icomplete-vertical. I've switched back to vertico.

@oantolin
Copy link
Contributor

@jgarte Vertico is way better than icomplete!

@minad
Copy link
Owner Author

minad commented Sep 10, 2023

I think it is time to finally retire this long issue. I wonder how many people are still subscribed to this issue. ;)

Thank you all for your participation and your contributions! Consult got to its current state thanks to your help and feedback. I hope you still like and use this package. If you have feedback feel free to reach out.

I've just enabled the discussion on the Consult repository, where we can have feature discussions in the future. Support questions can also be asked there.

@minad minad closed this as completed Sep 10, 2023
@minad minad unpinned this issue Sep 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Needs feedback, open for discussion
Projects
None yet
Development

No branches or pull requests