insanum / sncli

Simplenote CLI
MIT License
396 stars 34 forks source link

Support for internal links #47

Open MatthiasKauer opened 6 years ago

MatthiasKauer commented 6 years ago

Hi, I'm a relatively new user and maybe this feature already exists or doesn't make sense. Every once in a while it makes sense to refer from one note to another note. nvpy allows this using [[..]].

Example:

Kotlin libraries
Also see [[Java libraries]]

Clicking on [[x]] effectively populates the search bar with x. Is something like that feasible and useful in sncli?

Best regards, Matthias

MatthiasKauer commented 6 years ago

In fact, regular web links are not straight-forward to click either, are they? I opened the note in vim and used gx to open it in the browser. Is that the best way?

samuelallan72 commented 6 years ago

Currently sncli doesn't support mouse events at all. Maybe someone with more experience than me on urwid could work something out? Personally, I think the main point of sncli is that a mouse isn't required, so if this feature was added, it would have to also include a keyboard-only interface to clicking links as well.

Your best bet for opening regular links is to use a terminal emulator that supports clicking on recognized links, or put something together with urlview (eg |urlview will pipe the note through urlview, giving you an interface to select and open any link from the note). Whether something similar could be integrated into sncli itself?

MatthiasKauer commented 6 years ago

Oh, I wasn't suggesting a mouse interface. The first link could be opened when hitting enter on a particular line, for instance. The gx shortcut from vim is another option.

What do you think?

samuelallan72 commented 6 years ago

In that case, it should be perfectly doable! I wonder if it would also be feasible to incorporate parts of urlscan as well. :+1:

MatthiasKauer commented 6 years ago

Cool. I am wondering how useful urlscan will be. It seems to be solving a similar issue but the interhal links [[x]] would have to be implemented in another way. It also probably has features that aren't really needed here like the encoding handling but I wouldn't know. Let's think about this for a bit, shall we?

samuelallan72 commented 6 years ago

Yep, it appears that opening external links is an already solved problem with piping to urlscan/urlview, or gx in vim. Internal links would have to be implemented directly in sncli because it must interface with the rest of the program (eg. searching and opening notes).

MatthiasKauer commented 6 years ago

Just to clarify: Piping is done by pressing | from the note browser or when a note is open, right? That gives me an error but we should probably look at it in a separate issue. What do you think?

samuelallan72 commented 6 years ago

Yep, when the note is open or from the index view (will work with the selected note). Please do open a new issue if you get any errors with that! :+1:

MatthiasKauer commented 6 years ago

Piping requires installation from master but it works now (see #48) which brings me back to this issue. urlscan doesn't seem to be very good at extracting links from markdown. It included the closing ")" and wouldn't let me select many links at all. Maybe that's a configuration issue with urlscan though.

samuelallan72 commented 6 years ago

Possibly a configuration issue, or an old version - it works for me out of the box with urlscan 0.8.6, and urlview works fine with a good regex configured.

MatthiasKauer commented 6 years ago

urlview seems to be better out of the box. I'll work with that for a bit.