Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

to be able to redefine punctuation marks #1645

Open
casperdewith opened this issue Nov 30, 2023 · 1 comment
Open

to be able to redefine punctuation marks #1645

casperdewith opened this issue Nov 30, 2023 · 1 comment

Comments

@casperdewith
Copy link

request

I’d like to be able to define new bracket shorthands for punctuation. These are preferably system-specific, so they are defined in the Python file for the system, instead of being hard-coded in Plover.

This flexibility can keep dictionaries clean.

examples

Punctuation-mark definitions can vary across languages, or even dialects. For instance, in France French, a no-break space precedes a question mark, whereas in Québec French, the question mark is attached to the previous word.

If punctuation symbols would be definable per system, a user would be able to define {?} as {^ ^} ? {-|} in a France system and {^} ? {-|} in a Québec system, while keeping the same French dictionary. An entry like {?} et could stay unchanged; it would adapt its spacing behaviour to the current system.

Furthermore, you could define the full stop to have two spaces after it in some contexts. Or for it not to force a capital letter after it in some contexts. (This writing style is convenient for internal documents, because they can then be case-sensitively searched through, because a word is never affected by a sentence-initial capital letter.)

Lastly, if you like to add a punctuation mark, you could define it once in the system definition, and then easily refer to it in dictionaries. This is convenient for hard-to-type punctuation marks, like the en dash or the em dash; they could have {--} as shortcut.

alternatives

The alternative would be to put the full definition of e.g. a France-style {?} every time in each dictionary entry: {^ ^} ? {-|}. This is cumbersome, and makes the dictionary less maintainable.

implementation idea

A requirement would be that the keys start with { and end with }. I think that an already-used definition like {#control(s)} should be allowed to be remapped as ‹punctuation›; it is up to the user to choose their preferences. This means that the user’s punctuation definitions have higher priority over other bracket things (macros, key combos, etc.).

PUNCTUATION = {
    '{.}': '{^} . {-|}',
    '{?}': '{^ ^} ? {-|}',
    '{--}': '{^ ^} –',
}
@user202729
Copy link
Member

user202729 commented Dec 1, 2023

It somewhat is (although I'm not sure if having multiple entry points with the same name will make the external one override the internal one, or no guarantee), just write your own meta plugin.

# Punctuation.
(r'([,:;])', 'comma', 0),
(r'([.!?])', 'stop' , 0),

plover/setup.cfg

Lines 92 to 105 in 53c416f

plover.meta =
attach = plover.meta.attach:meta_attach
case = plover.meta.case:meta_case
carry_capitalize = plover.meta.attach:meta_carry_capitalize
comma = plover.meta.punctuation:meta_comma
command = plover.meta.command:meta_command
glue = plover.meta.glue:meta_glue
if_next_matches = plover.meta.conditional:meta_if_next_matches
key_combo = plover.meta.key_combo:meta_key_combo
mode = plover.meta.mode:meta_mode
retro_case = plover.meta.case:meta_retro_case
retro_currency = plover.meta.currency:meta_retro_currency
stop = plover.meta.punctuation:meta_stop
word_end = plover.meta.word_end:meta_word_end

def meta_comma(ctx, text):
action = ctx.new_action()
action.text = text
action.prev_attach = True
return action
def meta_stop(ctx, text):
action = ctx.new_action()
action.prev_attach = True
action.text = text
action.next_case = Case.CAP_FIRST_WORD
return action

Documentation: https://plover.readthedocs.io/en/latest/plugin-dev/metas.html

At the moment at worst you can probably write your own plugin and write {:france_french_stop:.} as your dictionary entry. Feel clunky though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants