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

Jump to line with the edit command #127

Merged
merged 4 commits into from
Jun 19, 2023

Conversation

giuli007
Copy link

@giuli007 giuli007 commented Oct 6, 2022

I find myself wanting to use the edit command and provide a +<linenumber> to directly jump to a certain line in my editor (vim).

I've attempted to implement it.

A command to use it will look like

sncli -k <key> edit +7

this relies in cfg_editor to be set with a +{line}:

cfg_editor = vim {fname} +{line}

For now I made the overall changes in 2 different commits.
The first one just adds a simple line parameter to the exec_cmd_on_note method.
On the second one the approach is generalised to pass a cmd_args dictionary that can be used to substitute different parameters in the cmd string.
This is not necessarily useful right now but I felt it makes a bit more sense to pass generic parameters in like this.
With the current implementation the only 2 parameters that can be substituted are fname and line and it practically only really makes sense to pass in a line number from the edit command for now.
This is why I kept the 2 commit separate so that I can just use the simpler solution if that's preferred.

Happy to hear opinions and potentially tweak the solution a bit more.

@giuli007
Copy link
Author

giuli007 commented Oct 7, 2022

cc @insanum @swalladge

@samuelallan72
Copy link

samuelallan72 commented Oct 13, 2022

@giuli007 thanks, this looks like a nice idea! I haven't had much time to spare lately to look at these though sorry. I'll try to take a look soon, but can't make any guarantees. :/

@giuli007
Copy link
Author

Thanks @swalladge (and @lostways) for the recent 0.4.2 release.

I wonder if the feature in this PR might still be considered for merging in at some point? I appreciate I'm probably the only person wanting to use something like it for now but I don't think it is too controversial to have it.

Please let me know if I can do anything to facilitate this.

simplenote_cli/sncli.py Outdated Show resolved Hide resolved
@samuelallan72
Copy link

Sorry for missing this for so long @giuli007 . I think it seems a good idea, and it ties in well with the existing focus position when editing from the interactive interface. I left a request on the code structure.

@giuli007
Copy link
Author

giuli007 commented Jun 1, 2023

Sorry for missing this for so long @giuli007 . I think it seems a good idea, and it ties in well with the existing focus position when editing from the interactive interface. I left a request on the code structure.

@swalladge Thank you
It also took me some time to get back to this.
As mentioned on the comment inline I've reverted back to the initial simpler implementation. I did so with an explicit git revert for clarity. If that is acceptable and gets approved I can then squash-merge this.
Please let me know if you have further feedback!

Copy link

@samuelallan72 samuelallan72 left a comment

Choose a reason for hiding this comment

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

Thanks! Looks pretty good - I just left some comments about off by one errors with focus_position / line.

simplenote_cli/sncli.py Outdated Show resolved Hide resolved
simplenote_cli/sncli.py Outdated Show resolved Hide resolved
simplenote_cli/sncli.py Outdated Show resolved Hide resolved
@giuli007
Copy link
Author

giuli007 commented Jun 8, 2023

Thanks! Looks pretty good - I just left some comments about off by one errors with focus_position / line.

@swalladge my bad I didn't notice those wrong defaults after the revert; I guess partly because my editor (vim) just defaults to the first line anyway if I pass it a zero like vim +0 file. That and the unnecessary focus_position initialization have been removed now.
Thanks!

Copy link

@samuelallan72 samuelallan72 left a comment

Choose a reason for hiding this comment

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

Thanks, looks great!

@samuelallan72 samuelallan72 merged commit 0276a8b into insanum:master Jun 19, 2023
@giuli007
Copy link
Author

giuli007 commented Jan 8, 2024

Hi @samuelengineer thanks so much for merging this in.

I am wondering when this might get released (and published to pypi). I appreciate it's a very small feature addition and I might be the only one wanting to use it so no rush.

@samuelallan72
Copy link

@giuli007 sorry for the delay - no worries, though I haven't had time to stay as maintainer on sncli, I'm still maintaining the pypi package for now. I cut a new release from master and uploaded it as 0.4.3, and opened #139 with the version bump. :)

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.

2 participants