Pass 'unknown' args to the backend EDITOR #2

Closed
mig5 wants to merge 1 commits from mig/pass-extra-args-to-editor into main
mig5 commented 2025-11-12 22:15:24 +00:00 (Migrated from github.com)

Fixes #1

I found a nice way. argparse's parse_known_args creates a separate tuple for unrecognised args. We can then leverage this to pass them to the backend EDITOR (on the assumption that any unknown args might be known by the backend EDITOR tool).

To test: run this version with EDITOR=vim mirro somefile +3 and check that it jumps to line 3 of the file somefile.

Fixes #1 I found a nice way. argparse's [`parse_known_args`](https://docs.python.org/3/library/argparse.html#argparse.ArgumentParser.parse_known_args) creates a separate tuple for unrecognised args. We can then leverage this to pass them to the backend EDITOR (on the assumption that any unknown args *might* be known by the backend EDITOR tool). To test: run this version with `EDITOR=vim mirro somefile +3` and check that it jumps to line 3 of the file `somefile`.
mdaleo404 (Migrated from github.com) reviewed 2025-11-12 22:15:24 +00:00
mdaleo404 commented 2025-11-13 15:32:46 +00:00 (Migrated from github.com)

Thank you for your PR 😄
Unfortunatelly this will only work when +3 is expected after somefile (e.g. using Vim).
It won't work for Nano as the expected command should be EDITOR=nano mirro +3 somefile

I'm closing this PR.

Thank you for your PR :smile: Unfortunatelly this will only work when `+3` is expected after `somefile` (e.g. using Vim). It won't work for Nano as the expected command should be `EDITOR=nano mirro +3 somefile` I'm closing this PR.

Pull request closed

Sign in to join this conversation.