Skip to content

Feature suggestion: Calc variables #354

@DrorHarari

Description

@DrorHarari

Calc Variables Feature Description

When working with Keypirinha's Calc plugin, one may want to save the result of the calculation for later use in other calculations. This features enables that using one the following patterns:

var=expr
or:
expr=var

For example:

image

image

image

image

The variables are stored persistently in a file variables.jsonlocated in the plugin's local folder.

Enjoy

Original proposal:

Proposal to allow Calc to save results as variables for later use.

Examples:
12+3 > a => 15
a/5>b => 3
a>b => 1 (the space after b disables the 'save to b' so this checks if a>b)
'abcd' >c => abcd
len(c) => 4
c+'x' => abcdx
2+1>pi => Error: cannot override constant value

Notes:

  • Variables names must start with an alphabetic character and may also contain digits.
  • Variable name on saving cannot have trailing spaces. If spaces trail variable name, it is ignored.
  • Variables are transient and are gone once the Calc plugin reloads.

I have implemented this (+19 lines) and its works nicely. If it's of interest, I'll submit a PR.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions