This video demonstrates how to customize the Cocoon editor by defining new commands that integrate with external tools like DuckDuckGo for web searching and Odin programming language documentation. The presenter shows practical examples of creating FIFO-based commands, handling command arguments, and building utilities for viewing web pages in W3M and creating Obsidian notes from buffer selections. The core concept is that Cocoon follows the Unix philosophy of delegating to external programs rather than implementing functionality internally, allowing users to extend the editor's capabilities through shell scripts and command-line tools.
Deep Dive
Prerequisite Knowledge
- No data available.
Where to go next
- No data available.
Deep Dive
Getting into Kakoune, working on Odin programs for KakouneAdded:
Are we live? I think we're live.
All right. So, what are I have two things, two main things that I want to do first. They have to do with the cocoon.
All right. So, let's see here.
I have a few things that I want to add first that are going to be I think uh pretty interesting. So, we're going to make some new commands.
I don't really know where I'm going to add these. So I'm going to define them down here.
Uh this is going to be override dock string search via ddgr duck go dgr.
How do you take arguments? Actually, that's going to be interesting.
I think it's something like this. Params one.
Let's see.
declaring new commands, right? Define command. Let's see here.
Right. So, we have params. Um Okay, I think we can maybe we can maybe just work with this. So, we have one param. Uh, how is it?
How do you refer to the the parameters?
doesn't say it right. Am I missing something?
Anyway, I suppose we'll we'll try to figure it out somehow.
Uh I could of course Google for this but uh you know so we have we're defining a new command here and we want to probably execute FIFO a new FIFO buffer.
So we have FIFO name.
We probably won't well we don't want scroll actually. I think we can skip that.
We can run a command in a five blah blah blah evalid with args as Yeah, I can't access this uh from before.
So, we are going to FIFO name. Let's just say DDGR like this.
Duck.
Yeah. Duck duck go like this maybe.
And what's the we don't want scroll. We don't really care about that.
Then is it just a command then? So if I do FIFO name DDG DDGR cocoon FIFO uh I think it's probably these are probably needed right And here we actually want so uh DDGR uh expand no prompt like this and then we want arguments.
How do we insert arguments here?
We could try to cocoon define command arguments.
named parameters.
Hang on. I can't click this URL.
That's fascinating.
Um, let's try to just do this here.
And like this.
Is this going to work? Actually don't.
Not really. Um if what if I do this fo name and then we actually do val selection Maybe.
Oh, do I? Oh, it's dash name.
Not in gzip format.
What?
Can't I just give it a URL?
Like if I were to just say uh this here.
Yeah.
So, what is the val selection though?
Hang on. Let's just echo that.
Uh, not in this buffer, of course. This one.
Yeah, it's this.
What gives?
So then that means you know if you if we do this should it not actually just work like this not in gzip format well okay so is it literally that URL that's the problem maybe so if I do this for example xclipip cell clipboard now we have this in So now we can just execute our normal command here and paste URL literally.
Oh, it's that page that's the issue.
Okay, I don't even know what do we even do with that.
Uh we could of course just So, why does it need gzip?
It says nothing about G up here.
That seems a little bit old. No.
So if I do this, I don't do dump.
Nope. That's still still gives us that Well, yeah. I don't really know to be honest what the what the problem with that would be, but we do know that it does work on some pages. So, we're going to just work with that for now.
Uh, I'm going to have to open this in just a normal browser, I suppose.
Oh, right. You have org one and so on.
Kak or one.
I think that how we would do it to be honest. Um, so Here I suppose the the question is mostly let's just do argu one here.
So, if I do this now, um, oh, we don't have a name for this.
Uh, search duck go something like that.
Uh here we'll just do try around this because it's uh failing when you add the same highlighter all the time. So we're just going to do that. Then we're going to do this just to okay debug 169.
Kari 29.
Well, it's not that one. That's We know that for sure.
Uh, it's not percent try, I guess. Uh it's actually this.
Yeah, let's try that.
So if we do search duck go now and I type just uh Jmap, right? So we search for Jmap like that.
Now I can do search.go Go uh jmap specification wrong argument count. Okay. So I need variable arguments for this basically.
Okay.
I'm going to let's do this.
params.
Uh I think the the documentation said something about uh commands.
Fine. Declaring new commands. This one.
So it said something about params being able to be like a range, right? So min and max with both min and max omittable.
So we could do one to infinite essentially.
Okay, let's try that one dot dot.
And how do we do this then? Right?
Because now the question is how do you refer to multiple arguments then? Hakon define command arg commands.
Yeah, this page is literally just a it's just a manual.
Doc expansions is something we can execute. Apparently.
Ah. Or arg at.
Okay.
So now if we search for Jmap specification.
Bam.
Okay.
We like that.
So now we're going to also make a command that lets us view one of these in W3M by just putting the cursor on the URL and then that's it really.
uh you basically just say you know hey open w3 on the current URL I think that will be neat to be honest it's a good kind of general utility to be honest and now we can just sort of search duck go inside of cocoon this now leads to well we probably want to view the pages also in cocoon and so that's where we're going now. Um, let's make a command for this, right?
Uh, override dock string uh, view a web page in W3M.
I mean, sort of view a web page dump.
Yeah, let's just do that. Rams if I've ever tried. Yeah. Yeah. I used to use e- mics also.
Um I mean I have but um honestly it was a it was a fair amount of time ago. I I kind of have return to Emacs every now and then because I really do love org mode as a as a thing.
But um yeah, Emacs, I would say one one of my main issues with Emacs is it has been historically pretty slow and annoying.
Also, I really hate Elisp. Uh but that's a you know cuz I I really like lisps, but I have never liked Elisp. I think it is probably one of the worst lisps that has been made. But I do like the concept of Emacs. you know that it's like a little operating system for for uh as an editor in in some ways, right? It kind of it's it's sort of like what we're trying to do here in some some ways.
Yeah. If you're if you like Emacs, I understand, you know, because I really I think that Emacs, the philosophy behind Emacs, I I I like the maximalist view of Emacs is what I will say. Um, where you just say, you know, I really want to do everything in EMAC. I want to send email. I want to listen to music in a little Emacs module. I wanna I want to control my computer from Emacs. I don't really want to leave Emacs. So, if you could just, you know, if we can just sort of create plugins for everything that I want to do, that would be great. And so, in many ways, I think Emacs is a great candidate for what I'm trying to do with Cocoon.
in that way. It's just a different editor, but you can do the same thing where you say, "Hey, I wanna I want to just live in Emacs.
Just let me live in Emacs."
And so, I think that's probably how I would uh characterize what we're doing right now. I I would I I think you can just sort of do that in Emacs and it will be great as long as you like Emacs, you know.
But yeah, Emacs to me is um it obviously got better when when I found out you can just install evil mode. Um then I tried Spacemax uh for a while and uh this really gave me an appreciation for having discoverable functionality.
So, you know, you press a key and it tells you here's what you can do instead of just this this implicit kind of old Vim feeling of no, you just need to know that this particular sequence of keystrokes does this particular thing instead.
This obviously translated into which key.
So, which key um obviously is that component where it tells you, hey, here are your key bindings and here here's what each one of them does. And so, when you press one key, you go into a new menu that says here's here are the alternatives that you have narrowed down now and so on. So, I really um that part I really appreciated with Spacemax um and tried to get that elsewhere as well.
And that's obviously the impetus for using the user menu in cocoon. Right? So if you you press space here, clippy tells us that we have make, we have config, we have format buffer, we have select and we have go to, right?
Yeah. Which key is obviously it should have always been part of of Emacs to be honest, right?
Yeah. I think um our our cocoon experiment is going to maybe fit in a little bit more with the Unix philosophy in that cocoon is really not doing much in the end. It's just sort of it's just delegating to a bunch of programs and some of those programs we w we write ourselves and some some of them we we just find right like this duck go uh command and and so on and you know we're going to try to work with that right this one will not have any params I think we can we can just skip that uh we will however right so now we just have the name so let's say W3M view whatever it doesn't matter so much what the name is I suppose uh FIFO and here we want the W3M buffer I think we're Just going to do this.
And then we're going to do W3M dump.
Uh, and then and here we do want this val selection again.
I think that's going to be it to be completely honest.
Something like that, right?
Is that it? I think maybe that's it.
Wrong argument count to define command.
Oh yeah, that's because we have this uh Yeah. So now if we were to go back to these results here.
Oh, now I have actually made it I made it so that we okay that's interesting actually.
So we have now made it so that we have to select the URL which I guess is fair.
I mean what if I do this now? Okay.
Right.
Okay.
It it remains to be seen how useful this is, but you know, yeah, I've read some of uh I don't know how to pronounce this guy's name, Jee.
Uh I've read some of his stuff a long time ago. I'll be honest, I don't even remember. But it it it often seemed a little bit kooky to me.
But uh yeah, I do like it though, to be honest. I do like when people really, you know, like um this um not I mean I prefer when people have a a little bit of a they they're not so safe in in what they're doing, right? It's more, you know, they try to really do something more than just uh have whatever everyone else's opinion is to be honest. So here I'm wondering, should we actually add the auto kind of select behavior? I think we should, right?
because I don't like that we have to actually select these URLs ourselves to be completely honest. I think it's a little bit annoying.
I want to just sort of be parked on a URL and then then it should figure out what the actual thing is instead.
The question though is like okay how how tedious is that? Because in a way, okay, now okay, I'm I'm kind of convincing myself now that because one of the one of the tenets that I personally kind of see with Cocoon is that you actually want to see what you're going to be operating on first and then you do something with that. So with that in mind, it actually makes more sense to specifically mark these URLs yourself.
Now we could make that more easy.
We could make that easier by, you know, having, you know, some utility for that.
But it actually makes more sense to not do this kind of implicitly because the whole idea or one of the ideas for cocoon is you should see what we're you're working on and then you should do something with it. You either make changes or you filter something etc and and so on. So maybe maybe it doesn't make sense to implicitly do this.
What is this actually?
So if we do G this we jump to H Yeah, this will work. Honestly, this will work pretty well for a lot of things. Like if you're if you're just doing some web searching, etc., and you just want to find something out pretty reasonably. Uh you do a web uh a DDGR call for the search, right? So we duck.go search duck.go like this um with just some search terms whatever it might be and then we get the duck.go go buffer in that buffer we can just look at the URLs and say okay I want to view this URL uh sometimes we will not be able to and that's fine uh we will just open it in a browser instead and so on right this kind of makes sense now we can spend more time in cocoon we can do basic stuff in cocoon we don't really have to leave to do other stuff and so on I don't have to open a new tab I already have I don't know how many hundreds of tabs tabs.
I have so many tabs that I have tab groups.
I have tab groups here.
And each of these probably I don't know how many tabs there are in here. This is the hang on which tab am I in right now.
Main which is the tab that where or it's a group where every a bunch of tabs go and so on. I usually have a stream group where I just sort of have stream stuff, which we're going to jump to now, I suppose. Uh, I don't know how many tabs I have here. That's just a shitload.
If we did want to actually see every tab in there, we could go to that, but I don't want to see that because this there's too many.
But yeah, now we have to now we don't have to open new tabs. we can just view things in cocoon instead. This I really like.
So what more can we do? Like basic stuff um basic utilities that you kind of want, right? Eventually, you know, I mentioned the whole music thing, right?
before. Eventually, what I think I'm going to do um is I'm going to also add the capability to uh mess around with MPC or NCM PCP or whatever. Uh or the MPC is the actual demon that runs the the music, right?
And then we're going to we're going to add controls for that as well.
So we can we can control you know volume stuff like this from cocoon. And this is it it's neat because it's so basic right because you can just literally do this from the command line anyway.
I really like that.
Oh also also yes. Okay. This is a this is a good idea. as well. I mean, for me, it's a good idea.
Obviously, you know, okay, I'm going to let's uh I'm going to show you what I mean.
So, I have a com uh I have a CLI app here installed called Obsidian CLI because I use Obsidian for notes and stuff. So, what we're going to do is we're going to create a command that creates a new note in in Obsidian from a selection. So, you just have a selection here and you just make a new note from that.
Um, so that means of course we have defined command override.
That's getting tedious to do.
Uh, do string create a new note in Obsidian.
Obsidian create.
Yeah, let's just do that.
Ah, once again missing that.
And here we want I we don't really need a FIFO certainly. We want the NOP pretty much uh I mean probably a no age I'm assuming here because I don't think we need a FIFO for this necessarily.
Uh there's no real uh useful output to get from this, right? So let's just say Obsidian CLI clea uh create and then path.
Okay, path is actually going to be an argument arg one and um oh this is a shell context. So this is going to be kak arg one.
Um and we're going to is we're going to quote that like this. Um content is going to be quoted kak selection. I think like this something like that. We'll see. It's not super important to be honest.
Um, and that's these things. And then we want new open overright.
I think it's like this.
Let me look at this a little bit. I think I have this somewhere.
Create path content. Open new tab.
Okay.
How do you buffer delete delete buffer?
Um, create open new tab.
Oh. Uh, right.
I wonder if this will work. We'll see.
Um, how would we Let's just try it with something, I guess. Um, what would be a good candidate for this?
[ __ ] Uh, let's just do literally anything, right? So, oh, hang on. I haven't sourced. Uh, there you go. OBS create.
And then we have one argument which is going to be let's say just uh test note MD and if we look at my obsidian nothing has happened wrong argument count oh yeah we don't have params one There.
Right.
So, I probably need a name actually.
Let's do this. Um, sure. Name and path. But shouldn't you be able to just do path?
Well, let's Okay, let's try this. Name is equal to uh What if we do this? Uh, base name of kak arg one.
Oh, visual mode. This is I'm I'm never going to unlearn this apparently. So, let's do this and then create our test note again.
No, it's still untitled.
What if I execute this myself.
is create. Yeah. So we have name is equal to just uh test note md uh and path is test no note md and the content is equal to kak uh arg one or no not really uh selection [ __ ] selection This did nothing.
That's interesting.
So, here's, by the way, what I'm seeing in Obsidian, right? So, we're seeing an untitled note, but it has the right contents. We know that part works. That part works just fine. Um, it's the name that really isn't working out here for us.
And just to confirm, uh, let's see here that this is, uh, sourced. Let's do this.
Yeah.
Okay. So, let's try to figure out what that is.
Uh base name here should work just fine, right? So if we for example we say base name test note MD it returns that right. So that should be fine.
But I think maybe this expansion here might not be working out and that would be a different story, right?
No, I don't think that would be a thing actually.
I feel like this uh normally wouldn't really be an issue anyway, right? So, if we just take a look at for example, let's say Obsidian CLI create, we just do path, right? So, test note and D like this.
And then we say content. And then we just say cat uh for example kac rc.
Literally just this.
And then uh open new tab overrite.
Yeah, this created a note with a title.
So, we really should not be needing is a directory.
Oh, what?
Well, that's kind of weird.
So, when we set the path, uh, that really kind of messes up some stuff there, right?
Maybe we need to do this.
Folder already exists.
Surely it's not trying to put it here, right? No.
I mean that folder doesn't already exist though.
Okay. So path is maybe not the thing we want actually. Uh obsidian CLI.
Hello Kristoff.
So here we want uh help for create right and this is going to be so it says file path here right which I interpret to mean okay let's try this one more time and just say path like this and we're going to do open new tab overrite By the way, this content did not work.
Now it worked. All right. So, this is what I'm seeing in Obsidian right now.
And here we have test note and so on. So we know that this should work just fine if we do open new tab overwrite and then path only and then we do content like this and it should work just fine and we do know that the selection worked just fine before. So from that perspective we should be set up already. Now the path is here open yeah new tab open overrite etc. So now if I were to say for example, hey, we're going to do this entire section here, Obsidian create test note MD, it's still untitled. What do you mean?
What am I missing here?
Create new tab. Create. Open new tab.
Overwrite path.
Did I not source this? Maybe still untitled. Uh, that's a little bit old, isn't it?
Is it in the right path at all?
No, it's not in the right path. That's why.
So, the path here really is the the problem if anything.
Kak arg one.
I thought that this was how this actually worked.
Um, Okay. There's no mention here of of of that at all. That's kind of odd, isn't it?
H.
Uh well my experience with duck.go go is that it's not meaningfully worse than Google certainly.
And Google has really only gotten worse over time, for sure.
Also, I don't really I'll be honest, I don't like using Google stuff in general.
Um, could it be ARG Zero?
Cuz they might be using this um it might be zero indexed. Let's try that uh like this.
also uh the reason I'm using duck.go here is because it just has a CLI tool that I've installed as well. So I can just dump search content inside of the buffer to be honest.
So that's mostly it to be honest, but you know.
Okay, so that's still not work. Oh, hang on. I didn't source the No, that's still not working, though.
So kak or what? What then?
Corg shell.
No, this is just a man page. Everyone has like 50 different versions of the man page online, but that's not the stuff that I'm looking for. I can access the man page on my [ __ ] computer. Why is everyone making websites to just show the man page?
Doesn't that seem a little bit odd to anyone else?
Let's try this with uh with Google.
Oh, is it just dollar one? No.
Surely that's not the case though, right?
Actually, maybe it is. Let's see.
I mean, that would match shell behavior obviously, but that that can't really be the case, right? Can it?
We'll see.
Oh, that works. Yeah, we have our our test note, etc., etc. with content and it's just our selection.
Okay, that is definitely good.
Let's see.
Despite Google don't Google Google going down the [ __ ] it's still the best out there.
Search is just generally kind of not super useful to be completely honest.
Uh I feel like pretty much every alternative is not not really good enough to be used all that much.
I feel like my entire search experience has probably become a lot worse in the last I don't know how many years certainly for finding like actual human created uh content with uh with some oomph behind it espe especially you know you can find a [ __ ] whatever zero to blog uh tutorial for pretty much any language out there but can you find anything of any real value. Not really to be honest.
Um, I kind of struggle to think of something that I would actually seriously think like search is the the absolute best for this except maybe finding like stores or something.
Yeah, I pretty much only use it to to figure out like, hey, what's the what are the parameters for this thing?
because I can't find them in some better place. Obviously for Cocoon, the first thing we do is just go to the docks and that's it.
Uh if we can't find it in the docks, well, odds are we're really not going to find much of any value anywhere else to be honest. Like here we ended up on um and by the way, so this is I should clarify this is one of the reasons I like um I like Dr. go that you know if I really want to search Google I just do either bang g or I do gbang and I can you know if I can't find it via duck go first okay you know I'll just search Google and that's it so it's not really an issue in that respect so if you think about it like well using duck go then is really strictly kind of better because I can search Google anyway and get anonymized results because it's not my browser accessing them really which means it's not going to be overfitted to who whoever the [ __ ] I am right so yeah I you know if you haven't used bangs on Dr. go, you're you're missing out because for example, if if we wanted to just say search Wikipedia, we would say cocoon like this.
And so this is this is maybe half of the reason why I use duck.go in general, right? Because if I want to search Wikipedia for something in the browser, I'll just do bang w and just say, you know, Republic of Congo or whatever and, you know, go straight to it instead of taking a [ __ ] long ass trip to Google and then clicking the first result and having to look at their [ __ ] AI response, which is useless to me, Right? It doesn't make any sense to not go straight to Wikipedia. And now I I here I have a perfectly good way of doing it just by using this uh bang syntax on duck.go.
And this applies to a lot of stuff, right? So for example, if you really don't want to set up your own search and you want to say, hey, I want to find out something about Arch Linux.
Bang Arch.
Now you can search for Arch Linux documentation.
Just like that.
Uh free game. What's that mean?
So, what more can we add to Cocoon?
Ah, okay. Yeah, I'm not hip enough to get the the slang here, but yeah, bangs uh bangs on Dr. go are really really good. I do recommend it.
It's uh it's a useful feature. So having duck go as a search engine that you do use sometimes can be very useful.
Yeah, I you know at the core of it I like I said before I think search has become so useless in general because the web is just full of [ __ ] now. Um and so I don't really think that even you know are you going to try to tell me that Google gives you good results? I don't believe you. you know, uh I think that there would have to be some kind of revolution that really filters out just a [ __ ] ton of noise. Uh all the SEO optimized garbage that's out there would have to be somehow you would have to come up with a new ranking system.
you know something like Marinolia for example that would be a probably a search engine that it's probably the best you know hope that we have of something that you know returns something that actually makes sense u focusing on you know high knowledge content for example Yeah. I mean, Google searches are literally paid for, right? They hasn't been fair since since they've made the first literally the first version.
as as long as people can pay to be on, you know, a certain place in the Google rankings, then, you know, it's not actually there's no there's no concept of fairness at that point.
Anyway, anyway, web search sucks. That that is definitely the case. I I agree with anyone who says that. Um, what do we want to do more here? We want neat small utilities that we can use from Cocoon that work with Cocoon that sort of let us do some basic stuff. I do want to make that, you know, music thing, but I haven't really bothered kind of uh making sure that MPD works correctly.
or did I use moped? I don't know. I don't remember anymore. Now, the only music I listen to, actually, I will give you this tip.
Uh the only m music I actually listen to now is like, you know, every now and then I'll I'll just be reminded that there's a good song on YouTube or whatever. So, I'll play that just from a tab. Or I actually go to the musicforprogramming.net net and I I play a total of three songs from this list.
It's um episode number one, episode number two, and episode number three.
That's it. And the good news is, you know, you can download the music here just in a MP3 file. So if you do want it locally, you can just do that as well, which I will. Actually, I already have all of these songs on in Dropbox, but I haven't set them up so that MPD plays them or uh finds them yet.
Um and this is this is basically it. And specifically uh episode number two and um yeah specifically episode number two is very noise uh oriented. It's sort of very ambient kind of you just have it on and it just creates a little bit of a you know I don't know what to call it droning almost soundsscape for you while you work on stuff.
And um I would characterize maybe all three of these as being that type of thing. I can't actually speak to any of the other ones. Obviously, there's a lot. I should probably play some of these other ones to be completely honest. But, you know, this is a good if you do want to just have some music to listen to, I would recommend this. Uh, and again, you can download the MP3 files as well, so you can just have it on your on your stuff.
Actually, one of the I wrote a script to download all of the music from this website automatically and and, you know, check for like updates and stuff.
That was a long time ago though. Very long time ago now.
Yeah. So that's this. What more do we want here?
Do I have lookup on my No, I do not.
Uh let's say ln s code lookup.
Oh this is not defined actually.
Yeah, before I forget, I really should fix that. Um fish.
Do I have any interesting keys here?
Hopefully not.
Oh yeah, I did mean that. In fact, [ __ ] Okay, hang on.
I always forget this.
So there's this space that you have to have there. There's it's just one of those things.
There you go. So now we have olden root obviously. Um this would mean for example that we can say lookup olden root core let's say strings right so if we are in kak right and we want to do stuff with that so kak RC define command override do string.
Look up a olden module pram one olden dock something like olden do let's say docin and And here we do want the FIFO again.
And the name should be Doc Odin.
Something like that.
Yeah, I think that should work fine. Um, here we won't look up.
Uh, hang on.
How do we get just an in value? Is that a thing? Can I do this? Maybe.
That's curious actually. Um, actually This actually kind of reminds me we probably should make this a prompt with shell completion.
And then we execute look up on the result. I think that's actually more more accurate to be honest. Um, so here we actually want to go back to one of our other commands because we built something like this before and I suppose it was maybe we have this complete core but maybe that's not quite the thing.
So, we have prompt menu.
This is kind of what we're wanting, right?
Prompt menu, shell script candidates.
And the candidates are generated from from this here.
Right. So here we would say FD target D or type D rather. And can I do a is this a shell context implicitly? Maybe olden root something like that. Let's try that.
Yeah, this actually we would want core here by default probably because otherwise we're going to get a lot of results. So we don't really want this.
Well, we could Well, let's just do core package. And then here we actually want instead of edit obviously the command should be uh foame let's say olden lookup lookup Obviously, we can pull some of this down here a little bit.
Maybe.
Wow. If I could What am I doing?
Okay, we don't need this one.
So, five for name and look up and then we had that val text.
Uh that's not entirely correct, right?
We want um lookup and then in olden roots or something like that.
I I I'm pretty sure this section of this is going to simply not work at all, but we're going to work with what we have right now and and let that sort of we're going to work it out somehow anyway.
The core, let's just try something, right? I mean, what's the the big deal? Wrong argument count.
I'm always missing a backslash. In fact, so now if we were to execute doc Odin, let's say we do just uh strings.
Oh, I don't know why I'm taking params for that one.
That doesn't make sense.
Um, docin.
Okay, we're getting no uh no completions. This means that this is this particular thing is not working here. If we were to execute that fd-ten root core, this does give us no output. So clearly that's not working at all.
Is it possible here that we can do en olden root?
Not really.
How would that work? So, uh, expansions, right?
In This is a good man page by the way. This or doc page, right? This one is u full of stuff that we we've been kind of wondering about to be honest.
I suppose what I could do is just sort of do this.
Would that work?
Not really.
So okay let's try to rethink this even a little bit further actually because commands I remember had a section on defining declaring new commands right if we look at that here we actually shell script Candidates can be passed to define command actually.
So then the question here becomes how do we use that define command. So here they're saying we should use complete command.
Complete command.
So what we would have let's say we had params one for this command and then we just said we would make it this here justif I'm going to move that there. So, we have FIFO name olden lookup lookup etc. And the lookup here would literally just be uh just arc one, right?
But then we set up completion for this via complete command.
Complete command.
How does that even work though?
Complete command.
Let's say dash menu. I think that usually works out fine. And then the command name is doc Odin.
And the type would be file for example.
But then what what do you do with that cuz if if we have this now does this even parse I mean it parses but then okay so let's say I say docin Now we get a file file completion in our directory and that's cool I guess.
But how do we get it to be what we want it to be? Uh is env? Let's see.
No parse error.
Uh, val.
Let's see.
client and doesn't echo anything.
That's a little bit old, isn't it?
So, maybe this doesn't work at all. Uh, echo.
Sure.
Okay. So, that doesn't work at all. Uh, uh, how do you even cuz clearly A home would exist obviously for us. So uh we do have this complete Odin core where we're using Odin root but this is obviously because we're also we're in a bash context here.
So I'm assuming that there's a little bit of that happening as well and maybe that would be the solution.
But I I mean do we have to actually call a script?
And this presupposes by the way that this is even the the correct way to do this which we can kind of verify right.
So home code uh home goes code.
So if we were to do this, does that even change anything at all? Doc Golden.
No, that doesn't change anything. So that's clearly not the the way to go anyway to be completely honest.
So that means maybe we have to skip that whole thing as well and go for what was the the thing here.
Only variables actually mentioned in the body of the shell expansion. H. So hang on. Echo.
H.B.
Client env.
Uhhuh. Val client en something. Does that mean that we can also access those thing with those things with uh [ __ ] client in something? Okay.
Echo.
Nope.
No, that doesn't work either.
Isn't that a little bit odd? Shouldn't it be client and home?
H.
That's a little bit odd. I feel anyway. Um, we have this one and we want maybe shell script candidates to be honest.
Maybe that's the one shell script candidates instead of file. Oh, but then of course we want some kind of thing here to run.
And this is going to be F D T D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D I think What did it say here? So, it will not lead to any search results.
If you want to search for all files inside of the blah directory.
What happens if we do full path?
Nothing. Yeah.
Uh I can probably ask FD to do relative, right?
D- relative path.
Not quite.
Right. Base directory is what we want actually.
So basically this command line would be fine.
4CT slash Okay, whatever. Dude, I don't have time for this.
What am I missing here?
Oh, well, okay, that's interesting. uh source our fish file.
What am I even doing there? Um, why wouldn't this Actually, am I what am I missing here?
Well, So here we could just say let let's do this um opa let's just say we run our kak config scripts complete.
Let's just say complete in core and then we're going to rewrite that a little bit to kind of work with this. Otherwise, we could maybe try this this way and see what happens.
Not really.
Oh yeah, because Oh, hang on. That's obviously not going to Fair enough.
So we are going to ls1 or actually let's do ft here.
um K RC. And here we're going to copy this line.
I think this should be fine.
And if we really really wanted to, we could literally just jump into like push the olden root core essentially do I think I modified the wrong file.
Shell script candidates requires a shell script parameter. Okay. What is debug?
What's that even really mean? A shell script parameter.
Oh, let's try out our script. By the way, Why is it not there? What am I Hang on.
What am I missing there?
Oh yeah. Okay. Ch mode.
Okay, that's giving us reasonable output. I think requires a shell script parameter.
You know, I don't really know what that's supposed to mean, but I suppose it has something to do with the So, if we go to commands, you have the parameters here.
And I suppose that's them saying, "Hey, you've got something wrong." But I I thought that we I mean it's this requires a shell script parameter.
Oh, there you go.
Not quite though, right? Because Oh, no.
It's It's there.
Right.
Okay. We are definitely getting somewhere.
So what we actually want here is val client env root slash whatever is there.
Oh, core.
There you go.
There you go.
We've got it.
And here we can do whatever we want.
Right here we can do whatever we want.
For example, what I can do now is do this, you know, with our whole create obsidian create note, right? And I could say, you know, okay, what is this thing?
It's um strings do MD like this.
And now look at my obsidian. Bam.
How do you scroll in obsidian? I thought control D was going to be down. What?
Ctrl F is search as well. Does it not support Vim keys properly? I don't even remember.
We are stitching together commands. Huh.
Isn't this exciting? Isn't this really, really cool? we can build basic stuff that just gives us, you know, documentation. So, just for those who might not know, the lookup tool was a tool that we built uh a few streams ago.
So, it's it's this tool here.
Um, if we go to to actually look at the source, it's pretty straightforward stuff.
uh you know we have our declarations and so on.
So what is a declaration? It has a name some attributes and a type. Uh a name is just a string. Attributes is declaration attribute. Declaration attribute is private package p you know private file etc. What is what can a declaration be?
It can be a procedure union a distinct type. Uh we would add enums here obviously.
um and so on and so forth. And we have just made a program that essentially just goes through a package and parses the package and and gets declarations out of it and so on and outputs those declarations uh in a markdown format.
Um which we saw in the in in cocoon, right? Um so here uh in my other buffer this one this is the output of that and here we could actually set the file type.
We could set the file type right. So if we for example do this temporarily set option buffer uh file type markdown probably we get this and let's let's put that in the command right because I think we should be able to do that probably um set option buffer set option buffer.
So, how do you set it for another buffer?
Maybe FO actually has this.
Okay, let's let's try something. I'm going to see if I understand some part of this, right? Because there's a there's an interesting thing that I have seen before that I'm not entirely sure if that's the the thing. So, set option local uh file type markdown.
Let's try that. local is like inherited or something.
So well that's how I I understand. We'll see. We'll see what that is about, right?
So for example, now let's just say bytes, right?
Yeah.
Oh, hang on. This could be from before.
Uh, let's delete this buffer and do a new one.
Okay, so that didn't work. That did not work.
Um, how do we set file type other buffer.
Well, okay. Let's do something radical here and literally just say Well, no, that won't be a thing. No, we'll just set it for the current buffer if we set that after, right? No. Okay, that's not going to be the thing.
Options Scope can be global, buffer, window or current.
Current relates to the narrow scope in which the option is already set. When the option is a list or map, multiple values can be given as separate arguments can be omitted altogether in order to empty the option.
Oh, buffer equals. Okay, hang on.
No such buffer olden lookup.
Okay, so hang on.
Maybe I skipped the quotes.
Oh my god. Why am I editing that part?
This one here.
There you go.
This is actually really good.
This is actually really good. Who could have known when we wrote the lookup tool that we were going to just shove the results into cocoon and just, you know, get it like this.
And here we can search, of course, like we can do whatever we want here.
Right. So if we're curious about builder in it here, bam.
And again with this we're quering our local odin version, right? So the that all of this is up to date with what we have and so on. Uh we are we don't have to leave cocoon to get documentation for stuff. We don't have to go to the source either really right if we're just wondering about more let's say you know superficial things and so on then we can actually you know get it from here I do see a few bugs in the output by the way so you'll note here that stuff with the default values seems to not be parsed correctly so this is something we could fix in the lookup tool uh so this allocator is context allocator by default obviously and lock is uh you know current call location basically these are default values and they don't actually work here uh I happen to know that these things so it's not that you know that that bad from that perspective but it is obviously a bug so we'll fix that for But yeah, this is really good. This is really good. We're just getting, you know, a bunch of really good output here. And we get uh we get a completion list here. So regardless of regardless of what I'm wondering about, right, we can really just pick anything from core at this point.
and and just get it. So, we're all good on that front.
And we could easily, you know, make this support vendor as well, right? We could even have doc Odin, you write core, it gets this, you write vendor gets this, right? You just have to know which one you're looking for. And I don't really want to mix them, you know, in in when I'm writing small applications and so on.
uh you know 95% of the time I'm just interested in core and so on.
Uh what's uh a library here that we could hash and this is also actually a great way to even just explore the standard library also.
Right. So here we can just go crypto hash. Bam.
So yeah, this is really good. Uh very good.
This kind of also means that probably these buffers are going to participate in autocomplete, which means this actually solves part of our autocomplete situation as well. Uh probably.
So that yeah, this is interesting. This is uh this is good. I'm going to actually end the stream here. So this is a short one uh for today. Uh most likely tomorrow I'll be back and we will uh we'll try to extend this even more. I do want to create some programs for serving cocoon autocomplete suggestions.
We will see sort of how deep we go with this. Um but it will basically that will be the first real I think live program that we'll have. Uh I don't think it will be uh an application that just runs.
It might be just um it just runs and gives the results and then it exits. Maybe we'll see. We'll see what the simplest thing is first and then we'll you know work on it after.
So yeah, uh also we'll probably fix some of these lookup bugs here where uh apparently default arguments are not being being output correctly.
So yeah, yeah, that's it for for today and um I'll probably hopefully I will see some of you tomorrow. Again, this was a short stream, only two hours. Uh not like what was it yesterday? Five hours. But yeah, tomorrow uh more Cocoon stuff. Uh more Odin stuff for Cocoon.
And so yeah, because now we're kind of set up to explore the standard standard library, um solve problems that way and so on.
Thank you for watching and uh have a nice day.
Related Videos
VALORANT's Latest 'Exclusive' Tier Bundle is Rough...
KangaValorant
17K views•2026-05-28
Flight Attendant Mocks Poor Looking Black Woman — Mid Air Announcement Exposes Her Real Power
SkyboundStories-b4r
184 views•2026-05-28
I FIXED My Friend’s Blown Turbo RX-8… Then Sold It
Cameron-RX8
134 views•2026-05-28
NewsWatch 12 at 5: Top Stories
NewsWatch12
1K views•2026-05-28
Simon Jordan & Danny Murphy deliver PREDICTIONS for Arsenal's Champions League FINAL with PSG
talkSPORTArsenal
6K views•2026-05-28
Botting is OUT OF CONTROL in Classic WoW (Again)...
SolheimGaming
108 views•2026-05-28
The "AI Job Apocalypse" is CANCELLED!
WesRoth
9K views•2026-05-28
STREET FIGHTER 6 - INGRID Story Walkthrough @ 4K 60ᶠᵖˢ ✔
RajmanGamingHD
12K views•2026-05-28











