euporie.core.suggest

Suggest line completions from kernel history.

Functions

NamedTuple(typename[, fields])

Typed version of namedtuple.

lru_cache([maxsize, typed])

Least-recently-used cache decorator.

to_filter(bool_or_filter)

Accept both booleans and Filters as input and turn it into a Filter.

Classes

AutoSuggest()

Base class for auto suggestion implementations.

ConditionalAutoSuggest(auto_suggest, filter)

Auto suggest that can be turned on and of according to a certain condition.

ConditionalAutoSuggestAsync(auto_suggest, filter)

Auto suggest that can be turned on and of according to a certain condition.

HistoryPosition(idx, context_start, context_end)

Store position information for a history match.

SequenceMatcher([isjunk, a, b, autojunk])

SequenceMatcher is a flexible class for comparing pairs of sequences of any type, so long as the sequence elements are hashable.

SimpleCache([maxsize])

Very simple cache that discards the oldest item when the cache size is exceeded.

SimpleHistoryAutoSuggest(history[, cache_size])

Suggest line completions from a History object.

SmartHistoryAutoSuggest(history)

Suggest line completions from a History object.

Suggestion(text)

Suggestion returned by an auto-suggest algorithm.

defaultdict

defaultdict(default_factory=None, /, [...]) --> dict with default factory

deque

A list-like sequence optimized for data accesses near its endpoints.

partial(func, /, *args, **keywords)

Create a new function with partial application of the given arguments and keywords.

class euporie.core.suggest.ConditionalAutoSuggestAsync(auto_suggest: AutoSuggest, filter: bool | Filter)

Bases: ConditionalAutoSuggest

Auto suggest that can be turned on and of according to a certain condition.

get_suggestion(buffer: Buffer, document: Document) Suggestion | None

Return None or a Suggestion instance.

We receive both Buffer and Document. The reason is that auto suggestions are retrieved asynchronously. (Like completions.) The buffer text could be changed in the meantime, but document contains the buffer document like it was at the start of the auto suggestion call. So, from here, don’t access buffer.text, but use document.text instead.

Parameters:
async get_suggestion_async(buffer: Buffer, document: Document) Suggestion | None

Get suggestions asynchronously if the filter allows.

class euporie.core.suggest.HistoryPosition(idx: int, context_start: int, context_end: int)

Bases: NamedTuple

Store position information for a history match.

context_end: int

Alias for field number 2

context_start: int

Alias for field number 1

count(value, /)

Return number of occurrences of value.

idx: int

Alias for field number 0

index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

class euporie.core.suggest.SimpleHistoryAutoSuggest(history: History, cache_size: int = 100000)

Bases: AutoSuggest

Suggest line completions from a History object.

get_suggestion(buffer: Buffer, document: Document) Suggestion | None

Get a line completion suggestion.

async get_suggestion_async(buff: Buffer, document: Document) Suggestion | None

Return a Future which is set when the suggestions are ready. This function can be overloaded in order to provide an asynchronous implementation.

lookup_suggestion(line: str) Suggestion | None

Find the most recent matching line in the history.

class euporie.core.suggest.SmartHistoryAutoSuggest(history: History)

Bases: AutoSuggest

Suggest line completions from a History object.

get_suggestion(buffer: Buffer, document: Document) Suggestion | None

Get a line completion suggestion.

async get_suggestion_async(buff: Buffer, document: Document) Suggestion | None

Return a Future which is set when the suggestions are ready. This function can be overloaded in order to provide an asynchronous implementation.

process_history() None

Schedule history processing if not already running.