LispWorks Editor User Guide > 6 Advanced Features > 6.3 Programming the editor

NextPrevUpTopContentsIndex

6.3.13 In-place completion

editor:complete-with-non-focus

Function

editor:complete-with-non-focus complete-func &key extract-func skip-func insert-func

Performs a non-focus completion at the editor current point.

complete-func should be a function designator with signature:

complete-func string &optional user-arg => result

string should be a string to complete. user-arg is the second return value of extract-func , if this is not nil . result should be a list of items to be displayed in the list panel of the non-focus window.

extract-func must be a function designator with signature

extract-func point => string , user-arg

point should be a Point object

extract-func needs to move point to the beginning of the text that will be replaced if the user confirms. It should return two values: string is the string to complete, and user-arg can be any Lisp object. string is passed to the function complete-func , and if user-arg is non-nil it is also passed.

The default value of extract-func is a function which searches backwards until it finds a non-alphanumeric character, or the beginning of the buffer. It then moves its point argument forward to the next character. The function returns its first value string the string between this and the original location of the point, and it returns nil as the second value user-arg .

skip-func , if supplied, must be a function designator with signature

skip-func point

point should be a Point object

point will be used as the end of the region to replace by the completion. At the call to skip-func , the point is located at the same place as the point that was passed to extract-func (after it moved). skip-func needs to move point forward to the end of the text that should be replaced when the user wants to do the completion. If skip-func is not supplied, the end point is set to the current point.

insert-func , if supplied, must be a function designator with signature

insert-func result string user-arg => string-to-use

result is the item selected by the user, string is the original string that was returned by extract-func , and user-arg is the second value returned by extract-func (regardless of whether this value is nil ). It must return a string, string-to-use , which is inserted as the the completion.

If insert-func is not supplied, the completion item is inserted. If it is not a string it is first converted by prin1-to-string .

When editor:complete-with-non-focus is called, it makes a copy of the current point and passes it to extract-func . It then copies this point and positions it either using skip-func or the current point. These two points define the text to be replaced. editor:complete-with-non-focus then calls complete-func , and use the result to raise a non-focus window next to the current point. The interaction of this window is as described in LispWorks CAPI User Guide .


LispWorks Editor User Guide (Windows version) - 22 Dec 2009

NextPrevUpTopContentsIndex