File: metas.md

package info (click to toggle)
plover 5.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 14,356 kB
  • sloc: python: 21,589; sh: 682; ansic: 25; makefile: 11
file content (41 lines) | stat: -rw-r--r-- 1,129 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Metas

To define a meta called `example_meta`, add the name as an entry point:

```ini
[options.entry_points]
plover.meta =
  example_meta = plover_my_plugin.meta:example
```

The meta can be used in dictionary entries:

```json
{
  "S-": "{:example_meta:argument}",
  "T-": "{:example_meta}"
}
```

Metas are implemented as **functions** that take a
{class}`formatting._Context<plover.formatting._Context>` and an optional string
argument. If an argument is not passed in the dictionary entry, it will be `''`.
The meta function returns a {class}`formatting._Action<plover.formatting._Action>`
which will then be applied to the existing output.

You will want to use either
{meth}`context.new_action()<plover.formatting._Context.new_action>` or
{meth}`context.copy_last_action()<plover.formatting._Context.copy_last_action>`
as the basis for the output value. Previously translated text can also be accessed.

```python
# plover_my_plugin/meta.py

def example(ctx, argument):
  pass
```

% TODO:
% - new actions (plover-current-time?)
% - accessing/modifying previous actions (retro_currency)
% - document context/actions API