Skip to content

Add mathcalc package#227

Merged
smeech merged 5 commits into
espanso:mainfrom
Vampir0:main
May 19, 2026
Merged

Add mathcalc package#227
smeech merged 5 commits into
espanso:mainfrom
Vampir0:main

Conversation

@Vampir0
Copy link
Copy Markdown
Contributor

@Vampir0 Vampir0 commented May 18, 2026

Inline math calculator using Python's math engine. Supports +, -, *, /, ^, sqrt, trig, log, factorial and more. Two triggers: :calc (result only) and :xcalc (expression = result)

Copy link
Copy Markdown
Collaborator

@smeech smeech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.

A short maths package with two very similar triggers calling a Python eval script. The script is pretty safe as long as executable code isn't pasted into the form, which is unlikely to occur in a user-environment.

I'll let Copilot do its stuff and run the automated checks to ensure it can be merged, but I have made a couple of suggestions, and the use of a script extension instead of shell is necessary, please.

Please restore the repository README.md.

Comment thread packages/mathcalc/0.1.0/package.yml Outdated
Comment thread packages/mathcalc/0.1.0/package.yml Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new mathcalc package (v0.1.0) that evaluates math expressions inline by shelling out to Python via PowerShell, exposing two triggers (:calc for result-only, :xcalc for expression = result). The PR also (apparently inadvertently) deletes the repository's top-level README.md.

Changes:

  • New package packages/mathcalc/0.1.0/ with _manifest.yml, package.yml, and README.md.
  • Two triggers (:calc, :xcalc) using a PowerShell + Python eval pipeline.
  • Deletion of the repo-root README.md.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
README.md Repo-level README removed entirely — appears unintentional.
packages/mathcalc/0.1.0/_manifest.yml Manifest for the new package; homepage looks like a placeholder.
packages/mathcalc/0.1.0/package.yml Defines :calc and :xcalc matches via duplicated PowerShell+Python eval commands (Windows-only).
packages/mathcalc/0.1.0/README.md User-facing docs and examples for the new package.
Comments suppressed due to low confidence (1)

README.md:1

  • This PR deletes the entire repository README.md. This appears to be unintentional and unrelated to adding a new package. Please restore the README.md file.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/mathcalc/0.1.0/_manifest.yml Outdated
Comment thread packages/mathcalc/0.1.0/package.yml Outdated
Comment thread packages/mathcalc/0.1.0/package.yml Outdated
Comment thread packages/mathcalc/0.1.0/package.yml Outdated
type: shell
params:
shell: powershell
cmd: "python -c \"from math import *; x = '{{input.val}}'.replace('^', '**'); r = eval(x); print(int(r) if r == int(r) else round(r, 10))\""
Comment thread packages/mathcalc/0.1.0/README.md
Comment thread packages/mathcalc/0.1.0/README.md
Comment thread README.md
@Vampir0
Copy link
Copy Markdown
Contributor Author

Vampir0 commented May 19, 2026

Thanks for the feedback!
I've made the following changes:

  • _Restored the repository README.md
  • Switched from shell to script extension in both triggers
  • Fixed the homepage in _manifest.yml
  • Added example hints in the form prompts_

@Vampir0
Copy link
Copy Markdown
Contributor Author

Vampir0 commented May 19, 2026

Hi, additional changes applied:

  • Refactored duplicate vars into global_vars
  • Added link to Python math docs in README.md

Ready for re-review, thanks!

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

Comment on lines +14 to +17
from math import *
x = '{{input.val}}'.replace('^', '**')
r = eval(x)
print(int(r) if r == int(r) else round(r, 10))
Comment thread packages/mathcalc/0.1.0/_manifest.yml
- `sin(pi/2)` → `1`
- `log10(1000)` → `3`
- `factorial(6)` → `720`
- `(sqrt(2)+1)^2` → `5.828427124`
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to ignore.

@smeech smeech merged commit 1d4a160 into espanso:main May 19, 2026
1 check passed
@smeech
Copy link
Copy Markdown
Collaborator

smeech commented May 19, 2026

Thank you.

The package should appear in the Hub in a few hours.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants