insanum / sncli

Simplenote CLI
MIT License
396 stars 34 forks source link

Start editor in the currently highlighted line #50

Closed MatthiasKauer closed 6 years ago

MatthiasKauer commented 6 years ago

Hi, when switching from note view to editor, I'd like the editor to start in the correct line.

I have taken a look at the code and it appears to me that lb.focus_position needs to be passed along to exec_cmd_on_note. For vim, the command to execute would be something like vim <fname> +<line>. Ideally, that could be encoded in the config so the style of other editors is also possible.

Do you have any thoughts on this?

Best regards, Matthias

BTW: What's your workflow for copying things from one note to another? Do you open sncli twice? Is that safe?

samuelallan72 commented 6 years ago

Sounds good! Perhaps it could be implemented with substitution in the cfg_editor setting - eg. cfg_editor = vim {filename} +{line}.

I can't remember needing to copy between notes, but I'd probably simply copy to the clipboard, close and open the new note, then paste. I don't think it would work too well with multiple sncli processes running - it's not using a database as such, so would probably end up with overwritten files... Perhaps we should also look into implementing a lockfile or similar to avoid that if it is a problem.

MatthiasKauer commented 6 years ago

So, I have created a first proof of concept for this feature.

Getting {line} and {fname} interpolated was surprisingly simple. Now, I am wondering what I broke with my changes. Can you guide me a bit and tell me what I should check?

MatthiasKauer commented 6 years ago

@swalladge How should I continue here?

samuelallan72 commented 6 years ago

@MatthiasKauer sorry I've been busy with other things over the last week. I'll check out your PR as soon as I can. :)

samuelallan72 commented 6 years ago

52 has been merged and I completed the functionality. The latest master should have full support for opening the editor at the current line, as well as being fully backwards compatible. Thanks for the issue and PR @MatthiasKauer :+1:

MatthiasKauer commented 6 years ago

Hmm. I would've loved to test that PR a bit more :| Let's see how it goes. Contact me if things break. I doubt I broke something on a fundamental level.