Closed minad closed 2 years ago
See discussion following in #109 https://github.com/minad/corfu/issues/109#issuecomment-1030688695
Here's another nice unicode option (#x00b7
, MIDDLE DOT):
Why not just use space? If we dynamically turn off the boundary check for M-SPC we can do that.
OK, yeah, better; so also check the command keys for disabling boundary check? We of course still want a normally-typed space to quit. And then for any further spaces entered, you'd also be checking for existing spaces in the input, so that'd work.
Yes, sure. It would require you to configure two things: 1. The separator corfu-separator-char and 2. bind a new command corfu-insert-separator to a key of your choice.
Hello !
I thought the workflow for using corfu effectively, and discovered (or just find one time again after someone else ?) something very nice (I think), with the following behaviour:
Here's the code that should normally work:
(setq corfu-separator 32)
;; highly recommanded to use corfu-separator with "32" (space)
(define-key corfu-map (kbd "SPC")
(lambda ()
(interactive)
(if current-prefix-arg
;;we suppose that we want leave the word like that, so do a space
(progn
(corfu-quit)
(insert " "))
(if (and (= (char-before) corfu-separator)
(or
(= (char-after) ?\s)
(= (char-after) ?\n)))
(progn
(corfu-insert)
(insert " "))
(corfu-insert-separator)))))
We can now type "spc" to insert a separator (and using orderless), and "spc spc" to insert the current candidate.
What do you think about this ?
@Cletip Thanks, feel free to add your code to the Corfu wiki. I don't see much of a difference to the current approach:
Ok thanks The problem was that I wanted the same key to insert the separator and insert the candidate, I feel that much more natural.
Ok thanks The problem was that I wanted the same key to insert the separator and insert the candidate, I feel that much more natural.
Sure, there is nothing wrong to use this in your user configuration. Please also add it to the wiki for other users. To me it does not look more natural, considering how Emacs usually works. Emacs uses many different keys and keys with modifiers.
OK, I have a corfu-auto + orderless setup that works very well for me. Happy to put it on the wiki if it isn't too esoteric. The idea is:
⚋
).M-SPC
in corfu-map to insert this special character.corfu--post-command
to turn off (via let-bind)corfu-quit-at-boundary
if the input contains this special separator character.This works really well in practice. All I have to do is remember to
M-SPC
instead ofSPC
with corfu the first time only when I want to use multiple orderless filters. And the default quit-on-boundary basically eliminates all the false-positives, e.g. defining new variables, random words in strings or comments that my cape-ified dabbrev-enabled capf throws, etc. But still lets you use full orderless power with regexps, etc. in buffer. The only small drawback is the potential for unicode chars to persist in your buffer (if youC-g
with a multi-component filter), hence my interest in a quick undo-and-quit, above.Thoughts? Suggesting an advice is obviously not ideal for the wiki. Is there a predicate config option you are considering which might work instead for this
corfu--post-command
:around
advice?Originally posted by @jdtsmith in https://github.com/minad/corfu/issues/109#issuecomment-1030686690