Closed minad closed 8 months ago
Damn...
consult-binding
to browse keybindings
How is it different from which key?
How is it different from which key?
I would say it is totally different :D
@veronikazaglotova Yeah, totally different. Which-key (which is great) pops up help after typing a prefix key with the options you can type next. consult-binding (assuming it's like counsel-descbind) would give a completion list of all bindings that you could then narrow based on input matched against the key (or command name) of the binding. It's kinda the reverse of M-x with marginalia showing the keybindings.
I did a big dumb Should've read the thread
A consult-emoji
that inserts ARG number of the selected emoji into the buffer. It's similar to the built in insert-char
but would be limited to just emoji, making it easier to scan the matching candidates. Also, since emojis are just one character, I would display them first followed by their name (unlike insert-char
which shows the glyph at the end).
consult-mark
currently just uses the local mark-ring. There's also a global-mark-ring
and there could be another command to access it (or perhaps call consult-mark
with an arg). evil-mode
uses its own marks which are like markers stored in registers and there could be a command to access them.
IDK how to name it. Consult-mark already exists :/
In Vim, there's a thing called a mark. If you type ma
, to Vim it means "mark current line in the register a". Vim will remember the line where the cursor is and write it down. After that, you can go to that mark from any place in the file if you type 'a
. Neat, right?
Unfortunately, it's a half-baked feature. It's nice, but you have to hold all the marks in your head and think about which place is on which mark.
I want this feature! But I wish it also had a swiper-like menu so that I won't forget which mark is where. I also think it's a good idea to not limit to 1 character so that I could have a cool easy to remember name for the mark. Something like this
student class Student: # this class has propert...
car class Car: # cars have length, height...
On the left is the mark name, on the right is the line. Saving the file names and their marks somewhere (to make it save between sessions) is a good idea, too.
https://github.com/jacktasia/dumb-jump does a similar thing but (from what I see in the readme) you can't make your own marks, just go to definitions.
Vim also has global points, they are capital characters. If you open a file "test", go to third line, type mA
, Vim will remember that. Then you restart Vim (without opening any files), type 'A
and it opens the file "test" and moves the cursor to where it was.
Would be great if you made it smart: for example, if I delete a line before a mark, mark should still be on the same line, although it's not an easy task.
There is already consult-mark, consult-register and consult-bookmark. But I guess none of those options is perfectly satisfying for that use case? Can you try consult-bookmark and consult-register just to see if these are good enough?
@veronikazaglotova So the feature already exists in emacs. In emacs, there are named registers that can hold positions (and other things) and you save them and return to them. There's also a consult-register
already. 😄 There's also bookmarks which can have longer names and there's a consult-bookmark
already.
Emacs also has a mark-ring
that saves positions as you move around and that's what consult-mark
uses. I mentioned evil, it's the vim-like emulator in emacs and it implements vim's marks. There's a counsel-evil-marks
that accesses them and I was suggestion a consult version of it.
We could add an option to consult-register such that if you select an unused register or type "SPC key" the register is overwritten with the current location.
@hmelman what do you think about my suggestion regarding enhancing consult-register?
@minad I think it already does that, doesn't it? 😄 Oh, or does it just write text and not location and you're suggesting an ability to save a location too. That would be great. I'd probably use an argument instead of a SPC key.
@veronikazaglotova @hmelman No it does not. I will prototype something and ping you!
@minad There are lots of -to-register
commands that can save lots of things, numbers, window configs, text, location, rectangles. Maybe it would be better to have consult versions of all of them which use completing-read for the register name and could show existing registers (annotated with marginalia with their content) so that you see which having existing content and either choose one to overwrite or an unused one.
there is already consult-mark, consult-register and consult-bookmark. but i guess none of those options is perfectly satisfying for that use case? can you try consult-bookmark and consult-register just to see if these are good enough?
Both are indeed good enough and do just what i want, but i wish they could show the line as well, so that i knew where i'm going to end up.
Maybe it would be better to have consult versions
Why not one that rules them all?
@veronikazaglotova @hmelman I also thought about having some all in one solution.
Type "r" to access register r "wr" to store window config in r, "pr" to store position etc. Furthermore we can use the consult narrowing to narrow to positions only etc. Would that make sense? But it is quite different from standard emacs interactions with registers I guess.
Not the way emacs does it. These commands are bound under C-x r and the next key defines what is stored or accessed. In some cases the access works for multiple kinds of values. See insert-register
and jump-to-register
. I don't use them extensively but I think it works well. An all-in-one solution could work, but wouldn't it necessarily involve an additional keystroke?
@hmelman I agree it would be quite different and the keysequence would be longer. I am also not using registers much probably because I don't find them very accessible.
@veronikazaglotova we could render positions in registers such that the line is shown.
@veronikazaglotova @hmelman I think it is better to not reinvent such a thing. What we could do however is improving the consult-register view and maybe add preview support for locations for example. To store, simply use the standard register keys.
Registers already have a fairly flexible way of displaying themselves (based on their type) which consult-register
uses register-describe-oneline
. I think that's good enough for now. I didn't realize but the various -to-register
commands seem to read the register name via register-read-with-preview
which does previewing after a delay. Emacs knows ;)
@hmelman what's the purpose of viewing the register content when you want to write? In order to not overwrite something and find a free register? Or did I misunderstand you?
previewing after delay
Doesn't work on my Emacs. How?
@minad You did not misunderstand, that's the reason I was thinking of.
@veronikazaglotova I'm looking at Emacs 27 code. Put stuff in registers. I put a window config in a, text in b and a point in c. Then try to put stuff in another register, I did C-x r SPC to save a position, when it prompts for a register to use, wait a second (default is 1) and a temp window appears showing the values of registers a,b,c on three lines.
Oh yeah, now I see it!
Doesn't work with points in register sadly
Does for me.
That's not what I want. I want something like this:
d, line starting with "def func(arg" in file "somefile.py", position 424
Hi! Can I use your source code?
@hmelman @oantolin @veronikazaglotova I added consult-global-mark
to browse the global mark ring. Please test! :partying_face:
Will do. I suspect there's some refactoring and code sharing that could happen with consult-mark-ring. :)
@hmelman No, nothing significant, I decided to keep it separate from consult-mark
since I think it is conceptually different and it displays the candidates differently. Furthermore it requires buffer switching in contrast to consult-mark
. Not much code sharing is possible, except if I would over-generalize consult--mark-candidates
. It is better like this.
But I should add - I have quite a few more general purpose helper functions around which are used by both consult-mark
and consult-global-mark
and the other consult functions, so the situation is not bad. consult-global-mark
does not add much to the code base, no huge complexity and not a huge number of lines of code.
I'm not sure what your options are, but I had done my own counsel-global-marks and aligned the filename:line column on the : and liked how it looked.
@hmelman Indeed, this looks indeed better. See https://github.com/minad/consult/commit/d29ee8d86d4ee5fe6e5851128d0adc0ff8ea7b48.
and FWIW rather than M-g x
I've bound it to M-g M-m
to correspond with M-g m
for consult-mark
.
@hmelman The current proposed keybinding is not good, I agree. But I am also not so sure about M-g M-m
since I think consult-mark
and consult-global-mark
serve different purposes and are not just two sides of the same thing.
Therefore I also did not smash them together into one command - if I would have done that you would have to press M-g m l SPC
and M-g m g SPC
to narrow down to local and global marks only. What do you think? Better to have them separate?
EDIT: I changed the binding proposal to M-g k
. I think this is good :)
I agree they're better as separate commands. I'm not sure how much use these consult commands will get vs C-u C-SPC
and C-x C-SPC
but if they are to get use, they should be fast to get to. I do view them as related, particularly since the global mark is set by setting local marks. Many (even experienced) users don't know about these two rings, so two commands give them more visibility which is good.
emacs bindings usually have some (often strained) mnemonic meaning which I'm lost on for either M-g x
or M-g k
. Maybe M-g m
and M-g M
though I prefer keeping the same modifier key, hence M-g M-m
for me.
@hmelman
I do view them as related, particularly since the global mark is set by setting local marks. Many (even experienced) users don't know about these two rings, so two commands give them more visibility which is good.
Sure they are related, but I feel they fulfill different purposes, navigation between buffers vs inside the current one. And the global one is not just the sum of the local ones.
emacs bindings usually have some (often strained) mnemonic meaning which I'm lost on for either M-g x or M-g k.
I agree and I am also trying to propose mnemonic bindings here. And both M-g m**ark and M-g mark** are pretty mnemonic to me :)
Yes they're related and yes they do different things. :) I tend to use the global mark when I'm tracing a code path through several files and at some point need to move to another place along the code stack. xref might take over this usage, but a consult-global-mark can make random access to that list nice. It's still "move between these corresponding things I'm working on that just happen to be in different files" so they're more similar to me than different.
I agree and I am also trying to propose mnemonic bindings here. And both M-g mark and M-g mark are pretty mnemonic to me :)
Ah, I see the k is for marK I didn't get that at first. That is indeed an infrequently used way to find more keys, and it's definitely better than x. I'll stick with mine, it's why emacs is customizable, I just wanted to propose it so you considered it.
Yes, the good thing here is that consult is not grabbing any keybindings by default. Choose what you like :)
@hmelman @oantolin @veronikazaglotova I added
consult-global-mark
to browse the global mark ring. Please test! partying_face
That's quiet nice. I need some way to have keybindings for these things. Any ideas? I already remapped the defaults a lot...
consult-find-file
- similar to counsel-find-file
. I tried to use combo find-file
+ consult
, but Counsel's version works better:
~
changes path to ~
@pavel-popov Note that by default you can type ~/
or //
(see also this if you want to hide the previous path completely) and to to edit by dir levels you can use s-expression commands.
@pavel-popov Thank you for the suggestion, but consult-find-file
does not sound like a good fit for Consult. The improvements you have in mind cannot be solved on the level of Consult, but should be solved by the completion system, e.g., Selectrum or Icomplete, depending on what you are using. Furthermore I would like to avoid adding substitutes for existing commands which only provide marginal benefits over the original version.
EDIT I should expand a bit more - if you use Marginalia and Embark, the built-in find-file
command is enhanced such that it provides the same features as counsel-find-file
. The idea of the component-based approach is that a replacement of the original command is not necessary.
* Pressing Backspace removes directory by directory
You could bind backspace to something like backward-kill-sexp
in minibuffer-local-map
(or something similar) for that, I guess.
@hmelman @oantolin @veronikazaglotova I added
consult-global-mark
to browse the global mark ring. Please test! partying_faceThat's quiet nice. I need some way to have keybindings for these things. Any ideas? I already remapped the defaults a lot...
I like having a personal keymap bound to F2
. I have consult-mark
on F2 m
, consult-imenu
on F2 i
, consult-kmacro
on F2 k
, etc.
I like having a personal keymap bound to
F2
. I haveconsult-mark
onF2 m
,consult-imenu
onF2 i
,consult-kmacro
onF2 k
, etc.
I'm stealing this but I'll use C-i instead (heil GUI!).
I would prefer consult-line to show lines without indentation. Is this possible?
@clemera, ~/
and //
- it works, thank you for something new I learned today about Emacs. A bit not pleasant as in counsel-find-file
, but file-name-shadow-mode
should cover it.
@manuel-uberti, @minad thanks for quick response. I'm a bit confused with the scope of Consult vs Selectrum as it doesn't seem that a completion package (Selectrum) should know about current input context (like file path when dealing with find-file
), and it's Counsel not Ivy containing keymaps for find-file.
todo/open for discussion
Seems feature complete? ;)
done
consult-info
dynamic info search based onconsult--dynamic-collection
. See #634 and #128 for an earlier draft. The wiki contains a version ofconsult-info
too.consult-line-multi
reimplementation based onconsult--dynamic-collection
(See #644)consult-lsp
, available as a separate packageconsult-yasnippet
, available as a separate packageconsult-eglot
, available as a separate packageconsult-org-clock-in
~,consult-org-heading
,consult-org-agenda
(See #276)consult-outline
by using theoutline-level
function (#277)consult-xref
show function, see xref branch and #216 implementedconsult-outline
extension for shell prompts (originallyconsult-prompt
which gives a list of all shell/terminal prompts), see #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 implementedconsult-keep-lines
with preview and filtering using the completion-style implementedconsult-kmacro
implementedconsult-completion-at-point
implementedconsult-flycheck
(see #51, cycle through errors with preview) implementedconsult-imenu
implementedconsult-flymake
implementedconsult-global-mark
support for global mark ring, ideallyconsult-mark
should show both local and global marks and vial
andg
narrowing via can either narrow to the local ring or the global one implementedconsult-major-command
list commands corresponding to current major mode, similar to amx-major-mode-commands implemented asconsult-mode-command
consult-ripgrep
(see #68, consider using xref facilities, xref-search-program, xref-matches-in-files) See also https://github.com/travitch/completing-read-xref.el implementedconsult-match
jump to matches in the buffer, needs dynamic recomputation of candidates, similar toswiper-isearch
, implemented asconsult-line-multi
.rejected
consult-ripgrep/grep/...
(See #170 for a prototype, #238). It would be great to have a transient interface implemented as a separate package, based onconsult-ripgrep
etc.consult-kill-lines
andconsult-copy-lines
variants ofkill/copy-matching-lines
in the style ofconsult-focus-lines
(see https://github.com/minad/consult/issues/6#issuecomment-1108368266)consult-org-capture
(See #32 for a draft). I think capturing is better solved by access keys than by completing-read to quickly jump to a capture template.consult-link
(collect all shr/eww/org/buttons links in a buffer and present them for completion, see also https://github.com/oantolin/embark/issues/95 - this gives us an embark target collector for free). Maybe this functionality should not be added here - it would be a better fit for the link-hint package. See alsoffap-menu
.consult-hippie
hippie or dabbrev expand (see #175 for a draft) rejected, not robust, see #175 discussion for alternative ideasconsult-fzf
and async functions which keep the background process alive (see experiment #189), the problem is thatfzf
,fzy
etc do not support a pipe-mode. Therefore we cannot use them efficiently, but this may change in the future. For now it is possible to configureconsult-find-command
with a pipe intofzf
. See https://github.com/minad/affeconsult-flyspell
, provided by see https://github.com/d12frosted/flyspell-correct, which usescompleting-read
by default, see also https://github.com/raxod502/selectrum/wiki/Additional-Configuration#correcting-spelling-errors-with-flyspell-correctconsult-flycheck/flymake/error
variants which shows the lines instead of the error. This could be built in to the existing commands via C-u? out of scope, no intention to implement this as of nowconsult-color
out of scope, not sufficiently useful, there are better UIs for color selection than completing-readconsult-emoji
out of scope, could be implemented on top of insert-char by modifying the minibuffer-predicate of read-char-by-name to restrict the character range, now available upstream in Emacs 29consult-linux-app
out of scope, available as a separate package https://github.com/SebastienWae/app-launcherconsult-help
interactive search through documentation, commands in M-x and other symbols (see https://github.com/raxod502/selectrum/issues/241 for the suggestion). Note that this is different from what is provided bymarginalia-mode
. I have an implementation in the consult-help branch, see #67. While it would be very nice, it is too slow to be useful. Maybe computing the candidates dynamically would help. not implemented, use embark collect instead for a searchable helpconsult-help
- implement generic function which allows to search through marginalia annotations, basically transforming candidates such that they also include the annotations and make them searchable. not implemented, use apropos-documentation or embark collect instead for a searchable helpconsult-binding
to browse keybindings, out of scope, useembark-bindings
ordescribe-bindings
+consult-focus-lines
/consult-keep-lines
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.