raghur / vim-ghost

Vim/Nvim client for GhostText - Edit browser text areas in Vim/Neovim
333 stars 13 forks source link

Use filenames in coherence with URLs instead of just `tmp_ghost`. #1

Closed doronbehar closed 6 years ago

doronbehar commented 6 years ago

Hello,

First of all thanks for creating this wonderful plugin. It seems much more professional than falstro/ghost-text-vim and it's working with Neovim without the "6 windows bug" (1, 2).

Continuing from https://github.com/GhostText/GhostText/issues/119#issuecomment-348050358, I understand that I need to address my request to you and not the developers of GhostText.

Quoting my request at https://github.com/GhostText/GhostText/issues/119:

Back in Firefox version <57, when we used itsalltext, the add-on opened a .txt file and the name of the file corresponded to the URL of the webpage. For example, for the webpage I'm editing right now, the file name would be something like github.com_GhostText_GhostText_issues_new_jakd1312.txt (including the random characters). In addition, I told itsalltext to open a terminal emulator with Vim and the said file. Next, in my Vim configuration, I created a new file type for itsalltext and I detect(ed) the files created by the add-on and set custom settings for files from certain websites.

For example, it enables me to automatically have markdown syntax in my text editor for text areas in webpages like stackexchange's and stackoverflow.com's, or mediawiki syntax in Wikipedia-like pages.

I read ghost.py a little bit, and I noticed that line 176 is the line responsible for creating the temporary file. I would have loved to make the PR my self although I am not very experienced with Python, It's just that I couldn't find an API documentation for GhostText that would tell how to get the URL as a variable to use in line 176. I'm sure it won't be hard for you though!

Thanks in advance.

raghur commented 6 years ago

Fixed in c19a89d97d8d43d14a01cc8304c13cc957bb2ece

raghur commented 6 years ago

examples:

C:\Users\RAGHUR~1\AppData\Local\Temp\ghost-github.com-use-filenames-in-coherence-with-urls-instead-of-ju8i5tkep_.txt

C:\Users\RAGHUR~1\AppData\Local\Temp\ghost-www.reddit.com-til-that-one-of-the-main-engineers-behind-nasa-s-cp1y9s78r.txt
doronbehar commented 6 years ago

Looks good! Wouldn't it have been easier and less dependent to just replace the / with _ in the URLs? It would enable more customization for similar stuff like file-type detection because it could enable you to check the path after the domain of the URL and customize the autocmd's accordingly.

raghur commented 6 years ago

There's considerations of path length.. Windows barfs if it exceeds 256 chars. Also, paths can have Unicode.. Seems safer to restrict to ascii and limit length

doronbehar commented 6 years ago

Seems fair enough to me, thanks a lot!