fvictorio / vim-extract-variable

Vim plugin to extract an expression to a variable
MIT License
26 stars 6 forks source link

Add support for makefile var extract #5

Closed shlomif closed 6 years ago

shlomif commented 6 years ago

note that in the process i used if_pyth because vimscript lacks both quotemeta() and a plain string replace func.

fvictorio commented 6 years ago

Hey, thanks for this, and sorry for taking so long to answer.

The issue with this change is that it won't work for people that don't have the vim python module installed, right?

Could you elaborate on why the current approach doesn't work? Could you give me an example of a Makefile expression that needs the python string replacement?

shlomif commented 6 years ago

Hi,

On Tue, 11 Sep 2018 22:36:04 +0000 (UTC) Franco Victorio notifications@github.com wrote:

Hey, thanks for this, and sorry for taking so long to answer.

The issue with this change is that it won't work for people that don't have the vim python module installed, right?

right.

Could you elaborate on why the current approach doesn't work? Could you give me an example of a Makefile expression that needs the python string replacement?

the problem is that vimscript does not have either http://perldoc.perl.org/functions/quotemeta.html or a way to substitute plain substrings, which made me resort to use if_pyth.

Regards,

--

Shlomi Fish http://www.shlomifish.org/ Optimising Code for Speed - http://shlom.in/optimise

Writing a BitKeeper replacement is probably easier at this point than getting its license changed. — Matt Mackall (who ended up writing a BitKeeper replacement)

Please reply to list if it's a mailing list post - http://shlom.in/reply .

fvictorio commented 6 years ago

Hey @shlomif, what do you think if we just add support for Makefiles and, if there's something specific to Makefiles that make it fail in some cases, we address it in another issue/PR? I'd like to merge this, but without the python stuff that breaks compatibility.

shlomif commented 6 years ago

@fvictorio : feel free to do it yourself, but I'm not going to redo my pull-req and risk patching code that may have security and reliability issues. I'd rather fork the code and maintain my own version of it that uses if_pyth. I don't think depending on python is a big deal - see https://shadow.cat/blog/matt-s-trout/but-i-cant-use-cpan/ . Anyway there are some references for make syntax, like https://www.shlomifish.org/lecture/W2L/Development/ or http://mrbook.org/blog/tutorials/make/ . I will keep my version MIT/Expat-licensed, so we can always consolidate later.

fvictorio commented 6 years ago

see shadow.cat/blog/matt-s-trout/but-i-cant-use-cpan .

I don't think that applies here? Merging this is asking every user of this plugin to have some python module installed (and having vim compiled with python support, but that's more common). That is different from using the ecosystem of your language when you can, which is what that article seems to be about.

I will keep my version MIT/Expat-licensed, so we can always consolidate later.

That sounds like the best solution :+1: Thanks.

shlomif commented 6 years ago

@fvictorio : thanks for the update and for your open mindedness. I'll proceed with the fork.

shlomif commented 1 year ago

just for the record:

/home/shlomif/.local/share/hexchat/logs/libera.chat-#perl.log-Nov 15 09:06:32 <rindolf> mauke: vimscript has its limitations - https://github.com/fvictorio/vim-extract-variable/pull/5
/home/shlomif/.local/share/hexchat/logs/libera.chat-#perl.log-Nov 15 09:06:33 <Paperbot>    Link title(s): [ Add support for makefile var extract by shlomif · Pull Request #5 · fvictorio/vim-extract-variabl... ]
/home/shlomif/.local/share/hexchat/logs/libera.chat-#perl.log-Nov 15 09:07:42 * guyhello has quit (Quit: https://quassel-irc.org - Chat comfortably. Anywhere.)
/home/shlomif/.local/share/hexchat/logs/libera.chat-#perl.log-Nov 15 09:09:25 * clawza has quit (Quit: Leaving)
/home/shlomif/.local/share/hexchat/logs/libera.chat-#perl.log-Nov 15 09:10:18 * jpn has quit (Ping timeout: 268 seconds)
/home/shlomif/.local/share/hexchat/logs/libera.chat-#perl.log-Nov 15 09:12:46 * epony has quit (Remote host closed the connection)
/home/shlomif/.local/share/hexchat/logs/libera.chat-#perl.log-Nov 15 09:13:13 * Macwinner (~Macwinner@99.189-202-251.bestelclientes.com.mx) has joined
/home/shlomif/.local/share/hexchat/logs/libera.chat-#perl.log:Nov 15 09:15:08 <mauke>   rindolf: what's wrong with substitute()?
/home/shlomif/.local/share/hexchat/logs/libera.chat-#perl.log-Nov 15 09:16:28 mauke Macwinner MaddieKalan madduck maettu Maff manjaroi3__ manwithluck marcus marienz Martchus mason MasterOfMagic 
/home/shlomif/.local/share/hexchat/logs/libera.chat-#perl.log-Nov 15 09:16:35 <rindolf> mauke: regex
/home/shlomif/.local/share/hexchat/logs/libera.chat-#perl.log-Nov 15 09:17:27 <mauke>   escape()
/home/shlomif/.local/share/hexchat/logs/libera.chat-#perl.log-Nov 15 09:17:59 * Macwinner has quit (Ping timeout: 260 seconds)
/home/shlomif/.local/share/hexchat/logs/libera.chat-#perl.log-Nov 15 09:18:33 <mauke>   actually, substitute(target, '\V' .. escape(str, '\'), replacement)
/home/shlomif/.local/share/hexchat/logs/libera.chat-#perl.log-Nov 15 09:26:06 mauke MaddieKalan madduck maettu Maff manjaroi3__ manwithluck marcus marienz Martchus mason MasterOfMagic 
/home/shlomif/.local/share/hexchat/logs/libera.chat-#perl.log-Nov 15 09:26:20 <rindolf> mauke: i see, thanks
/home/shlomif/.local/share/hexchat/logs/libera.chat-#perl.log-Nov 15 09:30:07 * jpn (~jpn@user/jpn) has joined
/home/shlomif/.local/share/hexchat/logs/libera.chat-#perl.log-Nov 15 09:31:04 <mauke>   "The best way to get the right answer on the Internet is not to ask a question, it's to post the wrong answer. This is called Godwin's Law."
/home/shlomif/.local/share/hexchat/logs/libera.chat-#perl.log-Nov 15 09:33:12 <rindolf> mauke: heh