See introduction in memo : The memo parser.


  • the auto-completer might insert the full text into the editor after the pattern. The user can then decide whether to leave it or not.

  • The memo commands might also be defined as suggesters with a trigger of type "[ticket ". Note that in that case we need to add a new attribute "suffix", which would be empty for # and @ but "]" for memo commands.





The memo parser.

Suggester(trigger, data, fldname[, ...])

Holds the configuration for the behaviour of a given "trigger".

class lino.modlib.memo.parser.Suggester(trigger, data, fldname, formatter=<class 'str'>, getter=None)

Bases: object

Holds the configuration for the behaviour of a given "trigger".

Every value of Parser.suggesters is an instance of this.

class lino.modlib.memo.parser.Parser(**context)

Bases: object

The memo parser.

add_suggester(*args, **kwargs)

trigger is a short text, usually one character, like "@" or "#", which will trigger a list of autocomplete suggestions to pop up.

func is a callable expected to yield a series of suggestions to be displayed in text editor.

Every suggestion is expected to be a tuple (abbr, text), where abbr is the abbreviation to come after the trigger (e.g. a username or a ticket number), and text is a full description of this suggestion to be displayed in the list.

Usage examples: see and lino.modlib.users

register_command(cmdname, func: Callable[[Any, str, str, dict], None])

Register a memo command identified by the given text cmd.

func is the command handler. It must be a callable that will be called with two positional arguments ar and params.

register_django_model(name, model, cmd=None)

Register the given string name as command for referring to database rows of the given Django database model model.

Optional keyword arguments are

  • cmd the command handler used by parse()


Yield all database objects referred in the given text using a suggester.

parse(src, ar=None, context=None, mentions=None)

Parse the given string src, replacing memo commands by their result.

ar is the action request asking to parse. User permissions and front-end renderer of this request apply.

context is a dict of variables to make available when parsing expressions in safe mode.

If mentions is specified, it should be a set to collect mentioned database objects.