🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). Log available at irclogs.raku.org/raku/live.html . If you're a beginner, you can also check out the #raku-beginner channel!
Set by lizmat on 6 September 2022.
[Coke] is there a way to create a shortcut for editing in vim? (e.g. if I'm on a word, I want to insert a C< before the word and a > after, without caring what the word is - I know I can redo the last edit, but that typically turns into two edits if I do it manually) 15:16
ab5tract [Coke]: I *think* that's the general use case for vim macros, but I haven't done much with them myself 15:17
[Coke] ab5tract: thanks, that's enough for me to google what I need. Wish I had done this 500 edits ago. :) 15:20
Voldenet [Coke]: vim-surround, point on the word, type in `ysiw>iC` and you're done 15:50
[Coke] ... that's harder than doing it manually, for me. 15:51
Voldenet then 15:53
type in `qxysiw>iCq`
afterwards @x
erm 15:54
`qxysiw>iC{esc}q`
[Coke] ... This is not helping. :)
Voldenet :>
@x will replay the macro recorded by qx{anything}q 15:55
vim-surround is here github.com/tpope/vim-surround?tab=...stallation 15:56
once you set up macros, it's almost as nice as emacs 15:57
[Coke] vim-surround++ 16:00
Voldenet: ok, was able to grok that and create a saved macro called @c that now does wraps a word in C<>. Thank you! 16:04
Voldenet happy to help
[Coke] now to make it work on Foo::Bar also. :) 16:05
ab5tract [Coke]: `vE` should extend a selection across all of Foo::Bar 16:06
ah, sorry, just caught up on the convo :)
[Coke] I'm not sure which of Voldenet's macro suggestion would be replaced with vE 16:07
ab5tract yeah, I don't know anything about vim-surround, but with a bare macro I would expect `vE` to work
but I've heard good things about vim-surround, so maybe that's a better bet 16:08
[Coke] Might have to do this without vim-surround, but having this work for even 1/3 of my cases is a time saver.
Voldenet [Coke]: ysiW>iC 16:12
(WORD is delimited by ws, word is delimited by anything non-wordy) 16:14
`BiC<{esc}Ea>` would do similar thing 16:17
lizmat And yet another Rakudo Weekly News hits the Net: rakudoweekly.blog/2024/05/20/2024-...ry-primed/ 16:36
[Coke] Voldenet++ 16:37
huh. found some pod that didn't complain but is weird: C<thing|other thing> - for a L<> the | is special, but for C<> it's just a literal. 16:39
lizmat seems to parse ok in RakuAST 16:40
[Coke] Yup - it's fine, just found two doc snippets like C<Foo|/type/Foo> which weren't setting off any author test alarms. 16:41
lizmat ah.. ok :-) 16:42
[Coke] Glad I happened to see them (searched, didn't find any others)
Voldenet: so W is too aggressive for me.
it works on the Foo::Bar cases, but L<Foo::bar|/type/Foo::Bar>, where I want L<C<Foo::Bar>|/type/Foo::Bar>, I instead get C<L<Foo::Bar|/type/Foo:Bar>> 16:44
so I might need to do it manually. By the time I sort this out, I will be mostly done with this exercise, though. the 'w' version gets me 90% of the way there.
Voldenet I like that currying -> priming change, makes me realize that currying can be added too 17:08
m: sub curry($fn, *@a) { my @args; sub inner-call(*@n) { @args.push(|@n); $fn.arity > @args ?? &inner-call !! $fn(|@args) }; inner-call(@a) }; curry( -> $a, $b, $c { say "$a $b $c" }, 1)(2, 3) 17:15
camelia 1 2 3
[Coke] codesections++ 17:39
ab5tract Voldenet: that's a cool example! 20:11
antononcube I assume some special (new) rakudo version is needed for Voldenet's example to work? 20:36
lizmat bisectable6: old=2023.01 sub curry($fn, *@a) { my @args; sub inner-call(*@n) { @args.push(|@n); $fn.arity > @args ?? &inner-call !! $fn(|@args) }; inner-call(@a) }; curry( -> $a, $b, $c { say "$a $b $c" }, 1)(2, 3) 20:42
bisectable6 lizmat, Cannot find revision “2023.01” (did you mean “2024.01”?)
lizmat bisectable6: old=2023.02 sub curry($fn, *@a) { my @args; sub inner-call(*@n) { @args.push(|@n); $fn.arity > @args ?? &inner-call !! $fn(|@args) }; inner-call(@a) }; curry( -> $a, $b, $c { say "$a $b $c" }, 1)(2, 3)
bisectable6 lizmat, On both starting points (old=2023.02 new=cf87ccf) the exit code is 0 and the output is identical as well
lizmat, Output on both points: «1 2 3␤»
lizmat antononcube seems to work for quite a while already :-)
antononcube @lizmat Ok, good to know. (Cannot make in VS Code + notebook.) 20:44
[Coke] Voldenet: given C<FOO>, how can I wrap that to get L<C<FOO>|/type/FOO> with a macro? :) 21:52
Xliff \o 22:13
Does anyone know if there are Raku source definitions for SourceView or GEdit? 22:14
lucs [Coke]: Between the pointies in C<Foo>, do you expect to have only alpha characters? 22:24
[Coke] lucs: could be :'s also 22:28
C<IO::Path>, e.g.
but even one that just did alpha would get me a huge time savings
lucs And that should expand to L<C<IO::Path>|/type/IO::Path> ? 22:29
Have this in your vimrc, or enter it on the ex command line ( :... ): 22:35
:let @r = "F<lvf>hyf>a|/type/\<esc>pa>\<esc>F<\<esc>hiL<\<esc>2f>"
Now in command mode, when your cursor is between the pointies, pressing @r will do what you want. 22:36
lucs You can see how it works by pressing those keys interactively: F< moves back to the opening < , l moves right one space, v begins highlight mode, etc. 22:38
And it works with any characters between the pointies (well, except other pointies, eh). 22:39
(I said "Now in command mode...", I meant "normal" mode.) 22:40
[Coke] lucs++! 22:42
I also just accidentally found that @@ is repeat last macro, apparently
lucs Oh, I'd forgotten about that one :) 22:43
[Coke] Voldenet, lucs, thanks so much! 22:45
lucs You're very welcome.