[slime-devel] slime-fuzzy-complete-symbol

Brian Downing bdowning at lavos.net
Mon May 8 17:48:41 UTC 2006


On Mon, May 08, 2006 at 03:43:50PM +0200, Levente M?sz?ros wrote:
> I think it's great but the user interface could be tuned a little bit.
> (at least to my taste)
> 
> Here is my idea (which I might eventually implement):
> - in the source window use <TAB> key to show the fuzzy completion list
> - simultanously in the match window display the possible matches and
> highlight the first one as being the current fuzzy completion
> - do not change anything in the source window and let the focus stay
> there (this is different from the one currently implemented)
> - use the subsequent <TAB> keypresses to iterate through the possible
> matches and use S-<TAB> to go backwards. one can always switch to the
> completion list window and navigate back and forth with the usual
> keystrokes if one wants to
> - otherwise the focus stays in the source window and no changes there
> - if you hit any key that clearly stops editing the current symbol in
> the source window, then the incomplete symbol will be replaced by the
> current fuzzy match and the key will be evaluated afterwards (implicit
> completion). such keys are space, enter, (), arrow keys leaving the
> symbol, etc... of course, hide completion window
> - if you did not find a match or there are too many matches, you can
> continue editing by navigating back, deleting back, etc.
> - the completion window remains there and continuously updates making
> the first match as the current completion, so that you can hit space,
> enter, () to commit
> 
> to type in slot-value-using-class one would type:
> 
> ( svuc TAB SPACE object SPACE slot )

I think that exact interface would probably drive me nuts, but then
again since I wrote the existing one it's pretty optimized for how I
like it.  :)

All of the swank calls for fuzzy-completion are pretty general - it
should be relatively easy to wrap a completely new emacs-side interface
around it, which sounds like what you're talking about above.  Digging a
little deeper, you have:

(defun compute-highest-scoring-completion (short full test)
  "Finds the highest scoring way to complete the abbreviation
SHORT onto the string FULL, using TEST as a equality function for
letters.  Returns two values:  The first being the completion
chunks of the high scorer, and the second being the score."
  ...)

CL-USER> (swank::compute-highest-scoring-completion 
          "mulvb" "multiple-value-bind" #'char=)
((0 "mul") (9 "v") (15 "b"))
42.391666666666666

...so you can use the core algorithm to complete whatever strings want,
not just symbols.

-bcd



More information about the slime-devel mailing list