[LC76] Can we make a browseable command list in Sublime Text?

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] [Music] do [Music] do do [Music] [Music] [Music] [Music] do [Music] [Music] [Music] do [Music] [Music] hello fellow blind text fanatics odat nerd here welcome to the live stream for the october 14th it's a wednesday normally we would do this on a tuesday but uh i had an appointment yesterday a scheduled appointment with my ophthalmologist specifically i was only supposed to be going in to get some retinal imaging done which more or less involves walking in the door sitting in a chair uh resting your chin on a little ledge they shine a light in your eye tell you not to blink but then you leave it's really uh that quickly uh but uh they called me just before my appointment said there's an opportunity for you to see the actual doctor today as well can you get here a little bit early and do that i said yes that stops me from having to schedule another appointment for a couple of weeks and find my way to the doctor's office again uh and that a particular exam requires your eyes to be dilated nine ways from sunday they were as big as dimes my irises uh so while the dilation was mostly gone by the time streaming was gonna happen i always find when that happens uh that i my eyes still feel fuzzy and wrong and a little bit of a headache because it was an exceptionally sunny day of course it was very rainy in the morning when i went for my morning walk stopped raining just as i got home uh started being extra sunny and then it got even more sunny as my my wife and i were on our way back from the doctor and i was squinting and my eyes were running the whole time so uh we are uh i decided i didn't want to put a stream off i thought i'd do it today instead of yesterday or uh putting it off for a whole week so here we are now uh my original plan for this evening was to actually work on an override audit tomorrow which is what we worked on last week but uh i had a thought and unfortunately tweets were already queued up to go and i could not uh i didn't stop it in time for something that might actually perhaps be a fun thing to be doing on tonight's uh tonight's stream uh and that is an extension pardon me uh two uh a plug-in that's in the stealthy and hasty scraps repository uh for generating a complete command list in uh sublime text uh and i thought you know would be cool if we leverage some of the new stuff in a savant x4 or subtext 4k as we perhaps call it to make uh a better if you will version of that that allows you to browse the command panel because then you could narrow in on particular commands easier if you kind of knew their name if you could filter on them and you could also open the appropriate plugin file and perhaps we'll see how she goes and jump you to that actual location so i thought we might give that a shot for this evening and see where it takes us and if that doesn't take a long amount of time at all or it seems like it's not something that will actually work the way we like then we can continue on with that override audit so i think we should uh go from there and so let us begin hello fellows of blind eggs fanatics odd news here welcome to the live stream for this evening now i did schedule and uh for a while there the idea was to work on override audit tonight and i decided we're going to be working on something just a little bit different and of course i covered that in the introduction to the stream but uh sometimes we uh trim things to to jump right into the stream proper so this is just a little bit of a referral now we actually have screen to look at here so in the stealthy and hasty repository and i can't remember hey i didn't add it in here but so i could provide a link to that if anybody's interested just let me know in the chat or in the comments of the messages but this particular plugin was taken from the stealthy and hasty scraps repositories we can see here it was written uh it's a variation of something that's written uh for that stack overflow answer that's mentioned right there um and the idea was actually i believe i also mentioned it this particular thing i just realized in one of the plug-in videos late last year finding the source for commands and basically it's for doing something like this we can go generate command list and this is a list of almost every command not every command but almost every time i'll get to that in just a moment for all components that are available in sublime and so we can see based on you know things like the default package has a command named echo in a file named our module named echo in the default package and there's also the increased font size degrees font size in a file named font uh install package control is the command is in that location hello ashwin uh and so on now this doesn't contain all commands uh for a couple of reasons one commands that are in the core uh don't show up in here because they're not exposed to the plug-in host the same way that other commands are and this is currently in my user package and it's blem text for that runs in python 3.8 that's a different plug-in host than python 3.3 and the two of them don't intermingle with regards to code that is actually available here so if we were to look override audit doesn't appear as a package anywhere in here even though it is definitely uh something that actually exists and the inverse would be true if this plug-in was running in a 3.3 package then uh it would override audit would show up in there and 3.8 packages wouldn't show up which i think ah includes all of the default packages that ship with sublime that have plug-ins because they're all set to run in the python 3.8 host including the default package but it might get a pass and be exposed to both because it's functionality that's important to be in both so i thought and this is something that actually came to me while i was walking the dog before the stream started i was looking in this earlier specifically because of this kill ring and killing yank someone in the discord asked what does add to kill ring do and i checked using strings on the binary to see if that was something that was in the core and it wasn't and i thought maybe that command went away but it definitely seems to do something and then i generated a command list and saw that it's in this file so then i went to look at kill ring and uh here it is in here and we can sort of see what it is it's actually doing it's grabbing regions of text and adding them to a ring which it seems like nothing actually does anything with the yank command will put stuff in will uh invoke the the command to put stuff into uh there the add to killrain command puts text in directly as we can see and uh in mark.pi if i did this this one delete to mark calls the add to kill ring command and a lot of the default macros do as well but nothing else in default or in the well this is the default package nothing in the vintage package either actually accesses this command so that was weird but it got to me thinking that it's nice to be able to generate this and scan through it but wouldn't it be nicer if there was just a list and you could filter and we have new action the command uh through the uh quick panel now for panel completion items which i don't think are actually in snappy yet so we could actually uh display stuff perhaps a little bit nicer so i thought why not see if we could adapt this code that generates this into something that's a browsable command list it seems like it might be an interesting diversion for things and if it seems like it's totally impossible we could always do override audit if for some magical reason i managed to finish something like this in less than two hours time we could still work on override on it but it seems like it might be an interesting thing now instead of an issue with this is that commands from 3.3 plugin host won't show up in here but you can execute commands so there might be a funky way to do stuff with to uh get our plugin command to execute a command in the 3.3 plugin host that invokes our command back with its own stuff as1 says i believe those were introduced in the 2000 builds commitment to functionality emacs yeah i everything that i know about kill rings and yank buffers is 100 you know the world of bim so i was expecting there to be a paste command well there's a paste command let's see in vim yy yanks and p maybe it's put instead of paste i've always thought of it as paste to copy lines and paste them somewhere else or delete lines and paste them somewhere else but there is no such thing i that i had that similar thought too that's what made me think maybe it's something that was added for the vintage package but the vintage package doesn't have anything to do with it either and there aren't any key bindings that do anything with it either except for one i added because i was curious what would happen if i turn on command logging and bind this will something happen and yes it gets real mad because you didn't provided the argument forward which it definitely requires so yeah it's uh it remains a mystery i'm kind of hoping that one of the devs maybe even john might pop in and say something about it i imagine at this stage it has to stay there forever because there might be something that relies on it i can't imagine what that would be but you never know now i don't think we have a quick panel item in here do we oh no we don't oh and i have a powerful sneeze that's coming oh that's better um so i think we might do yeah they're they're used in the default macros they put stuff into the kill ring but they don't do anything as a matter of fact this window was created not from the appropriate thing but i imported it and then deleted some texts just to see it appear in there so it's kind of anything that could potentially be used by something but i was unable to find any reference to that command or specifically to importing the actual kill ring global that if they put stuff into because that seems to be the way to get anything out of it sort of like the uh the paste from history has a similar object that's all i want probably this one unless i'm just remembering the name of the class we're interested in thus trigger details annotation kind we can define our own kind should we like i think that will allow us to throw some nice uh annotations on some things so let's play with that first and see where we go now i guess i should point out um actually uh let's see if i have a window here uh whoops i think in this repository in sublime scraps it should be in plug-in so again i believe this is linked in one of the and that's bright one of the uh plug-in videos this one right here paste this link in the chat in case anybody wants to look and see as food for thought one could leverage result file regex and result line records to jump to the plug-in file yeah that would also be a good idea to implement in that too this one is pretty simple because of it was created for that so that link is to the plug-in that we're actually interested in uh presuming that i as a moderator for my own stream i'm capable of doing that and it generates this stuff we should also point out that uh the list of all classes that represent application commands window commands and text commands are known to the actual underpinnings of the plug-in system in sublime plug-in that's the bit where as it's bloating things actually you can see them up here as it's loading classes it looks to see if it has any classes that are subclasses of the command class which is the common base class to all of these three things and if they are the name of the class is thrown in here and then there are methods that actually create these at the appropriate time applicable education commands are created right away when the commands are created with the windows text commands are created there's a few uh same thing is done for event listeners but in that case they have a little bit of extra stuff in them because they have the list of all appropriate callbacks that could potentially exist in all things and then there's a list of these are the things that don't work in the view event listeners which is any event that has anything to do with uh view interesting that on new buffer appears in there but i guess a new buffer isn't associated with a view a buffer is associated with a specific view and if you had a specific view you'd already be able to get its buffer so for the same reason that on new isn't in there that seems to make a lot of sense um and then there's just you know a little bit of glue code in here as we can see i totally booped this from pep 257 it takes the doc strings out of any commands that happen to have them which it's not a lot of the ones in the core uh except for recently added ones and then using the contents of those lists we get the classes we can figure out uh what their module name is their command name arguments and docs and interestingly this get name method here is actually boosted directly from the command class and sublime plug-in command is back here like so it's a little bit uh longer i guess bump it down a little bit to one left like so because i have a dog comment in there that explains this is actually something that's an instance method sublime uses behind the scenes theoretically uh if you wanted to when you created a command you could implement the name command and return whatever string you want and then that's the name that your command would be known by instead of its actual class name not a lot of reason to do something like that there's something that used to be in the underpinnings of package dev that played that kind of uh trick i can't remember exactly what i think the idea was there could be one of two potential classes that are used to provide the actual implementation for a command and they're conditionally included in and because the class name is different that the command name would be different so they have to implement the name method in order to do that there's it's very rare uh in all of the years i've been using spline i've never had to do that except to say hey can i do this and the answer was yes well i could but probably not a good idea whoops i probably should have kept that this is the one open was actually interested in that's less interested in that particular one um and i implemented this here because i didn't want to have to implement or create a new instance of every class every command just to be able to ask its name it doesn't seem like a good idea if anything is going to be creating command classes it should be sublime otherwise things could potentially go pear-shaped i try not to break things where possible so let's say we need a new package for this one other thing um that i have done is you can see there i've modified my salon text for install to have a different data directory than supply spontaneous three for a long time i was just letting it fall back to the other one so that they would share between the two because i still have squad texts to be installed so i can tell people on the forum but um call it command browser uh i decided not to do that because there was a change made to package dev in preparation for some new stuff that's happening that makes its version incompatible with sublime text versions three and four if it's installed for four when you start sublime text three package control says hey i found this package and it's the wrong version you should totally remove it and then it starts throwing away uh dependencies and then you have to remove the package and reinstall it and then when you go back to four and then it wants to update again it was a giant pain in the butt so i just sort of duplicated my civilian text three config name it's blind text now i have two of them how do you get those random quotes to appear in the terminal which uh which random quotes are those oh there is this one here that is the fortune command it's set to automatically uh throw one of these out you can lose a lot of time just sitting and running these uh but it's part of one of the core profile files and etc i think so that it always uh shows something when you fire things up okay say probably should have done that a smarter way sublime uh if i call that thing again command browser go ahead and that way still wreaking feeling the effects of that sneeze uh so let's see actually probably say whoa okay so we got python version 3.8 and let's touch this and open it from here and is that probably good for now good enough um so what we're going to want to do is uh no there's a reason why i use that other command because apparently i can't type the word import to save my life here we go so what are we gonna test here uh i think let's play with this for a second so class sample command want this to be a window command what does it be application command it really only ever needs to be one right the version of that here is a text command or so that's a window command but because it it's a window command uh because it generates a view into its own window um but we're not going to generate a view we're going to open a file so we need to worry about that here we'll close that for the time being go back to here and save that user keys sample command so this is an example of the binding that i added if you press the key oh it's mad it's so mad so yeah that's definitely a command that exists that's not totally just some weird holdover that does nothing incidentally that whole idea of commands not appearing from the 3.3 host in 3.8 and vice versa sort of wreaks havoc with package dev's ability to provide auto completions as well which is a bit of a bummer so let's say we did that it's definitely running cool so we're good um now i guess there was a reason for that to be a window command and that's this show quick so we need a list of items uh on select definitely has to be a i wouldn't do that with self.pick uh no we can't i like to do this this way so that i don't have to save the items in an instance variable i don't know if that's necessarily good or bad that's kind of irritating though and do we need any flags let's see uh mono space keep up focus loss don't care on highlight i don't think we care about that either so that's probably good so oops nice now if we were to look at this we could create our own quick panel items using this action panel item i've been doing too much other stuff still cool oh and this is another thing that i implemented today actual real uh console clear that is sweet thanks to a new setting has been added to control what the length of the scroll back buffer in the console is and probably some other panel views as well if i had to guess because i think people complained that regular output panels also have a length limit on them which kind of shocked me but first item is to trigger ban details and annotation and if it did that trigger details annotation and we need our own custom kind i guess anybody remember how that works let's do this whoops that's too fat that did not do what i wanted you said kind application is equal to sublime dot kind id what what would be the type of annotation that represents an application command a window command and a text command a variable a navigation a name space a function type i'm down with that oh and the last thing here is this right i only played with this very briefly back when it was originally included maybe we want a capital a on that so it looks a little nicer i assume the other part of that annotation doesn't arrive uh in that uh so this would be oh wait let's do that again the trigger is the text that's actually searched so that would be the command name right and what would be put in the details of this thing be a documentation comment if there was any not sure how long that can actually be i would assume it's just one line i would assume does it make sense to have multiple uh things there does it make sense to have different uh i assume the color of that comes from kind right i thought this was function now it's red instead of the thing multiple lines is the list oh hey well i didn't even realize that was you that said that normally it's ash when that comments like that that would be kind of neat so i suppose something like this um maybe i should do that in the right spot huh before i break stuff i've noticed i have a disturbing tendency to use double quote strings in some places in singles quote strings in other places and i blame the work that i'm doing in node.js because everybody wants single quotes there and now it's bothering me that i never decide the arguments in the details yeah that i guess that makes sense doesn't it i don't really want to display uh one of the first thought that i had on this was using the uh input handler and then could display the doc comment in the preview area but most commands don't have one so it doesn't seem like that really provides a lot of uh juice there such as it is what's the longest most gnarly one of these things we could actually see expand tabs let's throw that in there oh oh i whoops commented that part out look better with uh whoops the actual stuff oh uh well i have this uh oh we'll just ask to have no idea what we're trying to accomplish i have this uh plugin that generates a list of all commands don't have the same key bindings here in across all packages uh that in response to somebody asked a question on stack overflow a long time ago and it occurred to me that uh having something like this that would allow you to browse by command name uh to narrow in on stuff might be kind of a neat uh thing to go now i'm thinking if the annotation over here is like a for application command and w for window command and t for text command and maybe that part doesn't need to specifically lay it out over there maybe that would be a place to actually put you know like default.echo or something well you know whatever the actual module that this thing was stored inside of the idea being that when you choose one of the items from the list it'll open the plugin and jump you directly to the place where that command is actually defined or alternatively it could copy the arguments to the clipboard to make it easier to create a key binding package name in the annotation which which one is the annotation now i totally lost track of what i was doing oh and uh shoot having this giant font what a wrong window bro details ah just just the package name and not uh the actual module two as technically you probably don't care so much what module a thing is actually in if it's going to open it for you i like your idea of the plug-in source better yeah cool this is uh it's one of those things where i like to just sort of play around with the idea of what uh what it could actually do and then go from there the path of the plug-in in the end uh yeah i don't theoretically you can figure out the file name i assume the module name generally follows the package name but to be honest i don't have that much knowledge of the super underpinnings of the whole operation that seems like it's actually that's not too shabby let's make a that is long and ugly do a little bit of this whoops window and text let's say is this last part here only displayed in the quick panel or in the auto completion panel thing i assume let's go ahead and grab one of these this is one of those areas where i was like should you subvert the actual system of uh what the annotation is supposed to have just to provide pleasing colors or or no i kind of like the idea of just being able to tell if you're a plug-in author you care otherwise you really don't right so it does not really necessary to provide more information than that and then it follows the regular scheme for how everything else tool tip on the kind does that work in here no that shows you how often i use my mouse to hover over stuff oh that's the kind information is the function there huh right i think that would actually do not too shabby now the other the other issue with this such as this is that because this is running in the 3.8 host the 3.3 commands don't show up in here but i had this theory that there was one plug-in in a sister package that was a 3.3 package that had a command that when you invoke it it just immediately it gathers information from its plug-in host for commands that it knows about and then invokes another command that's in this package with that as arguments it could shoot that information over interestingly it should be using the full name provided by the api oh the uh the tool tip there in other words it should oh that's in that case we might have just found an issue there does it display in here too doesn't look like it oh that one does type type never got to narrow it in on the but those ones aren't oh function whoop i'm helping so command name so then this is going to be the arguments let's make this a little bit shorter and module that'll look a little bit uh yeah everything still works that's cool oh oh yeah i guess i should probably actually implement that method if i'm going to actually hit enter on there huh oops i broke it there that's nice that's better we'll get rid of all of that evidence that terrible bug never existed and you can't prove it except for looking back through the history of the thing okay now we need to boost some code out of this bad boy uh not sure how much this will actually be required also let's do this too that looks nicer and i like these more up here for gucci symbol project the tooltip doesn't have the full name of the kind info mostly for size and the simple index yeah please uh feel free to interject at will i i like uh the the inside knowledge if you will about this sort of thing like we were wondering earlier what the purpose of the add to kill ring command is because it looks like commands put stuff in to the kill ring but nothing ever seems to take it out is that like a vestige of the older version of sublime that's still there for compatibility reasons with packages that might decide to do something with it or was it part of vintage or something the kind of information that isn't technically needed to work anything but it gnaws at you man it gnaws at you this looks like something that's probably interesting wait what did i grab there oh yeah right i'm not sure how much of that might actually still be necessary for this but easier to uh easier to work it that way pretty sure i don't care about trimming the documentation straight and get commands i'm glad i documented this so much and yet still can't quite remember exactly what it is that it's doing so it gets probably going to need that kind of action to stash this information arguments probably going to want that i probably could have just copied that or put it directly in this other one but you know that one's in my user package so i don't want to mess with it too much let's throw that in there and uh that is probably not required something like that too i would imagine uh so if you throw this in here whoa sure why i expect that to expand out i think it's an interesting the kill ring is sort of an interesting little you know i didn't realize that that was there immediately my mind starts going to how can i take advantage of things that i have cut in the past but then i'd have to investigate more exactly how big the ring is and what it is that it's doing oh made that unhappy huh oh right oh i should probably ah that was dumb let's do that the correct way there oh all right i guess i was using that after all i also searched the forum for random st knowledge just because you never know when it becomes useful and it's much more fun recently oops i'm recently into looking how bookmarks work yeah i've looked into that in the past as well there was somebody that on stack overflow that was incredibly irate that when you create a bookmark it's bookmarks the start of the line and not the exact cursor location and i think i don't really use bookmarks that much myself uh and he was very angry about it on stack overflow and i provided him like a four-line plug-in that swapped how bookmarks work uh to do it the way that he wanted and he was all like thanks i guess can't please everybody all the time but never hurts to try oh we don't want the doc string i'm gonna say that part is not that interesting good news i have a wall of text and it might be 3 000 lines a lot nope it's less than 3 000 lines long that's cool the default oh it's keyed by package is it you see i've already forgotten exactly how this thing works to begin with which is an interesting one was that i actually uh wrote this thing i actually use it fairly frequently when someone asks questions on stack overflow or in the forum like i bet you i could figure that out by looking at the actual command and then i can never remember what file is actually located inside of um decode the command each one has three now i don't know the way that this was originally written man that is rough the different the breakdown was set by text commands window commands and application commands so that when it generates this it could group them out which is something that i added in there specifically because thanks dude and if you can see my dog is uh laying there on that rug in the smallest possible position that he could fit there's a bigger rug back there but you know why stretch yourself out when you can stay in a tiny little ball and apparently he has an issue that there's somebody in my hallway or sorry his hallway um but i found uh as i was referring to the command list that i wasn't sure what kind of command it actually was and then i'd have to open the file to see so i rejiggered it to display it this way so probably that is not strictly required we just need to know what package they're in and even then that actually might not be or maybe it would really need to get it to stop after one but yeah let's say we don't technically care about that because the actual type of the command is actually in the list right text in the html package is the text command in that module with that name here's an interesting thing is one of these things the file that this thing is actually stored inside of that i'm not sure swap this first let's say we don't need it by command type we just need that oh wait uh that should be a list then right you're gonna guess you append a list i'm gonna say you probably want something like that that's probably a little bit nicer certainly a lot shorter than it was a moment ago a command browser it's an application command in the command browser class in the browse module with the name of sample with arguments none it works so if we were to temporarily gank that and bring it up here just sort of need to convert it into stuff like that right as the list of items oh and actually should that be no that this one actually needs to be a dictionary because it's keyed on the package name in case of overrides do you want them to navigate to the original for the overridden python file uh i'm gonna say no because in order to get at the over the original source for the thing that hasn't been overridden you have to look up the sublime package file open it as a zip file and pull out the appropriate thing so that you can display it in a buffer which is something that override audit does so that it can get at the source version to set up the incremental diff so that you can see what's different but for the purposes of something simple like this that is not on the immediate radar although it might be interesting to have the information that override audit has to know when something is an override or not probably this one to be able to tell you that if you were looking at the paste from history command it has been overridden that could be interesting but i don't think well technically i guess the package info class could have information about that sort of thing uh so that's not entirely undoable if it detected that if it tried to import the appropriate thing from override audit and it worked then it could use the class the whole the override audit has a package info class that completely wraps all of the information about a particular package where the source packages are whether it's unpacked or not and all that good stuff so that technically uh could allow something like that and i just copied some text to the clipboard okay so we need to convert this right into an actual list of items and the command dictionary is keyed by the actual classes so or sorry four call that classes packages right now something like so using javascript typescript and python all in short proximity to each other really messes with my head about what the apis look like i'll say that oh i guess we need to iterate all of the stuff don't we probably want something like that right and then for because that's going to be a list is this one of those things that could totally be condensed down into the world's most heinous list comprehension it's probably faster but i don't know that i want to break my brain with something like that and how did we say we're gonna eject these things in here uh name of the actual command it's the first thing and then the second thing was the arguments oops which is arcs throw them module third maybe there was a reason to separate it up i commit by the three different types of commands for that kind annotation that might have been an idea i never understand how did that print statement get in that javascript file i have done that more times than i care to count and then after i spend two days working on typescript and and javascript i come here and immediately start console logging things that reminds me i have a standard i've tried to standardize on a snippet with cw for console right that expands out to the appropriate thing for whatever language i'm in like printfs and c and stuff apparently i never gotten around to doing that in python i'm sorry comment that okay well so far that's kind of working that needs to have the package name thrown onto the module how ugly is that so ugly but that totally works uh and kind uh i want a little bit of this action we can't look at this oh no nice there all right now we got something going on here some commands have argument lists that are perhaps a little robust for the purposes of this i guess but on the whole not terrible so don't care about that or that or that that's gonna bug me if i don't tweak it okay now you can use limited mini html in the description if you want to format the rx's monospace is that one of those situations where i could probably split that into multiple lines too somehow right yeah the arguments in the exec command they are that's definitely your stress tester for something like that and let's do this right uh is there something in here that's you know if there was a file in here it probably wouldn't point out the right thing right so okay so will said the description can be a list of many html strings or even if they weren't if it was just a list of strings but that would make it nice to mark that up i guess the issue there is coming up with a clever way to split it oops that doesn't make it any wider does it sort of the maximum based on that but that's kind of worrying why does this appear so many times oh yeah that's right yeah every item in the list would be the same height that way i'm kind of surprised that it doesn't dot dot dot fade down those long strings out actually ah why are there that many execs is this doing something wrong or is it seeing one for every time some other plug-in imported the symbol i don't see it should fade them yeah that's what i would have thought it doesn't it doesn't seem like it is but i'm not one for visual visual stuff and my visual acuity is not the greatest i must say ah this okay so this one just appears multiple times [Laughter] what a piece of junk this software is bite your tongue this is the preeminent text editing software i'm solely converting people uh in my head office in toronto into using sublime because they see me using it in live well not live streams in uh zoom things and stuff apparently i can navigate around files faster than they can navigate around in vs code which probably has everything to do with me being more familiar with my tool than they are with theirs but i'll take what i can get in converting people over what's the good solution to this apparently being seen so many times could this be a set instead how bad does that blow stuff up real bad oh right right because that's not what that's supposed to be right probably this other part if it was going to be anything should be a set right if it was going to work at all which yeah and the chad is expressing disbelief that will called sublime a piece of junk i don't think he was being serious what's the magic no an ad all right ah dicks are unhashable all right so let's not go that route then is that actually faster i don't know i'm referring to the bugs i wrote in quick panel item i see go back to that so i don't go blind out the side is there a reason just thinking this is storing things by package but it doesn't need to store them by package because package is part of the thing that they're in it could sort them by name and store them by name instead and all commands should be unique in that regard right so this could actually keep them on command and not on package to get around that are you getting class objects back in python uh yeah if i do that to display all of the stuff okay let me clear that i have it set to print if the command name is exec so by iterating through i'm guessing window command exec is showing up six times uh in the list of all classes but i would bet that one two three four five and then the original so i would expect that let me close that so that's not so awful one of these is the actual command itself and the rest of them are ones that are seen because they were imported by each of these particular modules you know like from default.exec import exec command which adds the same class to the module table multiple times i think i've seen that before okay let's give her a try where's the code for that uh here whoops nope that's totally the exact same class every time but yeah i think i've seen that before as uh way way back even before the newer builds back in sublime text three i think i can't remember exactly the details but i remember seeing before that this appears in the module table once for every time anything imports it like right now there are six of these i bet you if i did something up here like so add a little bit of uh get rid of that now there's seven one two three four five six seven which i imagine because this is imported this class is now visible to this module and there's probably no way for the plug-in loader to be able to determine that unless it already knew that it saw this class somewhere else that's probably more down the rabbit hole than anybody technically needs to get i would think but if i don't really care about any of that just said decoded name we didn't have that in there then it would just display all these by their command name the command name would have to be unique no matter what right and that's probably going to break all kinds of stuff now unsurprisingly does this show the underscore jump command that's a good question let's put that back to the way it was a second ago whoops it's too far jump back jump forward add jump record so no unless one of those is the one that you were talking about from the history list the new commands that are for people to be able to navigate so yeah let's get back to that that stored them in by their name then this outer part doesn't need to be here right i assume that looks a little something like this and then all of these become details oh huh shoot the bass commando sd4 respects python idioms and doesn't register classes starting with an underscore ah interesting that's right yeah it also respects uh underscore underscore all too right we're living the good life in the new plug-in host all we need to do is convince everybody with an old package that they need to upgrade to the newer one what silliness have i wrought all oh right right it should probably just be equals decoded i guess if that's how we're gonna play it right there now there's only one and the structure is probably smaller and cooler that's a result too so that's always good let's get that print out of there do that one we don't need that one neither details that's the module part so does this have to be sublime.html for it to be considered phdml oh right is that working by accident i guess let's try that does that actually do anything i can't tell if that's mono space now let's get rid of that too that's better well it doesn't have spans in it so presumably it's interpreting it so the next question becomes what to do with this now that we actually have it should picking the item jump you to the place that the place where it's defined that was my original idea but then oh i guess we can give her a try right let's jump to oops i guess we need to open file command for that expand snippet like variables such as so that would be another bug count three plus looks like the tracker is going to get a surge of issues after the live stream well that's the sort of thing where i'd like to you know verify that i didn't do something dumb there does pre-work different didn't look like it no where's the console neither oops that back to where it was packages uh package name uh crook uh it's a quick panel item cool pre is not one of the supported tags yeah oh yeah that's right package control doesn't do stuff like that and it looks like it's got some italics going on in there too yeah there's an idea does that seem bolder i don't think so it does look italicized though maybe it's something to do with the font that i'm using or the font my distribution has decided is the one that maps to the one that the theme is actually trying to use here which is probably a better way of saying that but yeah that that definite that one definitely seems to have had some effect i kind of like that i wonder if that could be cooler by not providing the defaults there but i kind of like the idea of seeing that command name the details is the argument oh i guess an issue with that is having to unhtml it over here if i wanted to actually i don't care to do anything with the arguments i just need the annotation is the module right uh this is the adaptive theme with the default monica color scheme or sorry the default mariana color scheme that i have an adjustment on to make the background just a tiny bit darker but yep adaptive i think with the new quick panel item pc can show even richer information about packages it could i think one of the limitations on that is that whole anything that's in one row has to be in all rows so you sort of get into that you know how much information do you want to show thing because you're sort of taking up space item dot what was it again outputs let's do that too it should pick a monospace font but maybe there's a font config issue yeah let's see here if i do that since i totally clobbered my console i still haven't gotten around to tracking down what plugin is printing that so that i can remember what the hell reason i put it in place to begin with i just remember that i was helping somebody oh hey it tells you where merge is located now that's cool that doesn't have any fancy information about fonts does it nope but that could well be i never really play too much with uh fonts like that per se i just sort of let it go with what it's what it wants to do it seems to be fairly readable not fairly it seems to be readable enough for me but that definitely be interesting to see how that might be working for someone else that is the okay what if we did this i was kind of expecting more action there oh i guess maybe if i printed it huh the number of times i swear syntax all the arguments that people are having about semantic syntax highlighting and whether it will be slow or fast or usable for lsp to be able to do that i can't even pick up on the idea that that was the wrong color because i forgot the parentheses there i'm operating on a whole other wavelength but that totally works huzzah now i guess an issue with this such as it is instead it does not return the view this way let's see i kind of suspected that would be the case let's look into the oh yeah live streaming showing people plug-in development and finding bugs since sometime in late 2018. [Music] don't care about that we don't care about that do you care about that and uh maybe we should try that again in a way where no file name on that huh i'm not sure if that means that the actual let's try that instead cool okay so the uh here is we set a setting on this view with a very specific name with the name of the class that is providing the actual command then we could have a view event listener that is applicable applies to that particular setting and in its on load it could navigate to the appropriate symbol to jump the cursor to that location so that it would not only open the file it would take in the actual command that implements the thing that seems like it would be neat uh is any of the things in here the actual class name itself ah okay man what are the art what are the uh attributes on a command command format then again underscore underscore module doesn't apply in there either does it am i flashing back to a different language that oh right well i'm not gonna lie i wasn't expecting that to be the result of that operation i probably just needed this no that does the same thing color me confused that knows the full name of the thing i guess i could actually look at the uh did that is that not something i did oh i was during it never mind i'm the smart party a little something like that this could be item class then pick it up no huh is that not what i called that or is it just an empty string nope oh i guess if i did it in the right spot huh still no did i not just verify a minute ago that that part worked what if i did this actually loaded that's tricky we need to be clever about capturing the appropriate view uh no because probably if i did this it would actually work right yeah so the reason that doesn't work is because item class is actually oh that's unfortunate it was saying that the whole time and i never noticed it wasn't yes yes it was all right i think that's a little bit of a sticky widget there to actually get the class name if we're actually using quick panel items in there and that's the list of items that we're actually checking unless oops escape there oh right right right there stop that from confusing the heck out of me this is capturing the actual items array but maybe it should capture no i can't capture command dick because it wouldn't be in the same quarter so that's no good so the way this is currently written it wants to capture the list of items that was provided to the quick panel so that when it gets told what index was chosen it can actually find the thing i guess the other way to go about this would be to do it like this then i can just look it up by name directly from the thing right dot field whose name i forget trigger that actually work this way well now i'm just confused oh right right right now that it's not one of those this would be something like that except that's not called module because why would it be why would i have used a longer name than that okay now except for the part where it's broken which is intriguing in its own right make sure i'm not missing any obvious errors oh the uh right right okay the module does the module no longer have that one package default module oh i guess not i guess we were we were combining those together inside of the quick panel item weren't we so okay now something's real unhappy about what we've done here something like that the name was not replaced as much as one might have thought that it was maybe don't be a bonehead i'll probably do a thing yay cool you need this print no do we need this print no we need this print no that makes that look nicer [Music] and a little bit bad action ourselves a new event listener incidentally the topic of the most recent videos on my other channel linked down below or we're talking about why you might use what event listeners are what you can use them for and why you might use one over the other and an example of that would be this make your instance only jump into existence whenever the settings object has that particular item when this view is loaded we can oh see i did it again i used single quotes for one and double quotes for the other ah i want to shoot myself sometimes gordon knows how many times i've done that in this code this one is not me i just copied that from somewhere else from zabon plugin.pie as a matter of fact way back in the day um so i guess a potential issue with that is once the file is already loaded it's not loaded again but it is focused again so that's nice so we probably need something like that so if you open that it's loaded uh and then oops oh yeah that one's an old one we need to get rid of that one need to do that too so with no file it was loaded and that's still cool we chose this i guess no that doesn't actually detect it right a little bit more work would have to go into that but we can fiddle with that i assume that's something that will work enough i'm not sure what the best way to handle that particular thing would be but all we got to do now is class name oh the symbol is self dot view dot settings get jump to close then clear the particular setting so that our instance will go away but in the meantime indexed symbols lookup symbol in all locations where the symbol is defined across all open files so we could theoretically call this for the name of the class to get a list of all of the locations which are going to be absolute file path file path relative to the project and the third is the two elements of the row and column inside of that file so one of those would tell us what we want to know about the location of the thing in the file and then we just have to make sure that if there's more than one entry that that is returned inside of we just have to capture the last one i'm sure that not the last one the one that actually represents the file itself i presume if it was the name of a class i don't know because it might appear multiple times might it oh new ap oh there is isn't there yeah i haven't uh i haven't uh updated this in this thing with all of the new stuff are those new apis in the linked documentation for upcoming stuff let's take a look in the symbol file right something that tells you the definition of a particular symbol the other way to do that i guess would be to find all of the meta.class.pythons or the entity name class pythons find the one that matches the class name and then jump to that region which i guess is also tricky for the purposes of like we need a command for that right that stuff's not in the official documentation yet the the new official documentation which is sort of kind of the reason why it's not in here yet uh although i do have various stuff on the go for digging through there and putting stuff in here but you know so many other things to do i'm using it not being available in that documentation as a an excuse if you will for not diving into that more but now would be the great time for having something like that should have focused the other view whoops is that not in here no it's probably in here isn't it where is it i guess i could actually take advantage of some of this stuff couldn't i i imagine that's the magic of that window one of those nice oh look here it is next simple regents to me name region swanky swank is there a command in here that jumps to looks like this is totally the magic that i want to pull off here right i could just call this and have it navigate directly to the proper location see that is a window command whoops what if i what if i could remember the name of the thing long enough to actually type it in no huh not gonna lie i kind of thought that would do something go to this command doesn't have a command suffix on it ah that reminds me that i have a bunch of stuff in the scraps repository that i have to fix that for because i never noticed it until somebody else pointed it out go to reference go to what if there weren't any unable to find class what class what are you talking about oh is it just called echo how about now unable to find echo command go to definition okay swank now i'm curious what that one was doing that it was unable to find it i guess technically that doesn't actually i don't even need to do the magic of finding the view i guess i got it i got to make sure that the file actually loaded first ah no ah it's it's terrible they gotta at least be the same inside the same thing right that symbol okay cool uh i think that did anything the cursor is still at the bottom of the file does that need does there need to be a little bit of a delay in there because let's see if i was to pick these font size it opened the file but the cursor is down at the bottom but now that i did it no that didn't uh it didn't seem to do anything either so maybe that is just uh neither here nor there unable to find echo command does it need to have time to actually index the view after the file has been loaded i suppose so that it can actually find the thing well now it's not saying that it's just uh it's taking me to the file but it's not necessarily taking me to the location actually i guess that's probably the magic of opening the file right oh for the second time it makes the makes sense because it's not unloaded anymore right okay but yeah it says unable to find echo command in the status bar very briefly before that happens where is the code that opens the view uh we're calling the open file command so that it'll open the resource file from inside of the package file without having to manually do that it worked one time so it gathers the thing it creates the resource with that structure calls it captures the active view sets that class in so that the view event listener will trigger its own load at the bottom where it does self view run command go to definition but does that have any effect on anything i mean it'll only work the very first time because the buffer's not loaded but it's definitely saying unable to find echo command in the status bar yeah that's why i put a will said in the thing that if the file hasn't finished loading the symbol won't be present yet which technically well the file has finished loading but it hasn't had a chance to index yet right i would imagine that takes a probably an insignificant amount of time but probably happens after the file is loaded or concurrently with it so the thing isn't done uh and then there's the issue of when to actually pull it i think that's where this probably needs a little bit more magic in it because doing it this way in on load only allows it to work the one time after that it won't so i guess you probably need to boost this stuff out into its own helper function so that it can happen there and this can say if view dot is loading is false just call the function directly it would be nice to have a second level of filter to filter by view window or application we could that should be fairly simple to add especially if i put back some of that stuff that i pulled out because that information was definitely present in here uh if you wanted to find just application commands when you list symbols for open files it actually goes through the list of open sheets and searches for simple regions in each on the fly huh so in theory that should work jumping to just to make sure that i'm not crazy and oh that's it worked that time that one time because i did it there let's just make sure i didn't do something stupid there oh it doesn't need to index them at all oh that's i thought it was actually going to the index to look that stuff up i guess not if it's symbols that's different than indexed symbols isn't it interesting maybe we've got bigger problems than i thought is the view being closed yeah i was just thinking it's only going to work once so whatever this does should be it's uh in some sort of helper function that gets triggered from on load but then also can be called from the place where the file is open but i suspect that we're running into an issue of this being none or something uh picked class oh echo disappeared from the list oh it's up there now neat oh i guess uh did the list reordered itself pick the class no okay it definitely worked that time and that time it said pick the class increase font size command jumping to increase font size command but the cursor is at the bottom of the file not at the actual symbol so let's try this first um let's see what did we actually put here well i guess technically for the purposes of doing this we probably don't need um a lot of magic here let's do this view dot oh let's put that there view is loading then move that over else whoa this and then that has to go to this oops all right so turn on command login so let's give this a test here it's def that part is definitely working so if i pick say decrease font size to do command go to definition on decrease font size but the cursor's down here unless it just tries to focus it but not necessarily select it and then just to test if i did it came back to it but this time it did focus it so that sort of seems like if it's actually loading it has a hard time finding it but then after that it doesn't let's try that again decrease font size cursor is down at the bottom down there and then decrease font size and it jumps there and that probably doesn't need to be there jumping to go to definition open file go to definition so now let's clear that so that time it called open file that just focused the file didn't have to open it it picked it and immediately went there and the cursor jumped to that location then we picked decrease font size it opened it it picked the class it couldn't open it it ran some extraneous stuff because the new file opened it said it jumped it was going to it said it went there but it didn't yeah tr sounds like some sort of race condition i had a similar uh oh indeed so for example anytime you find yourself doing something like this and typing in some sort of delay and hoping it's enough you've very much done the wrong thing perhaps even more so because i broke it okay oh sheeps that would explain some of that action all right smart party well that delay was very prevalent but it totally did a thing what if we tried the old default zero hey now it still works so we just had to leave the event and then immediately come back almost strikes is one of those situations where the information has been calculated by some external thread but hasn't had a chance to be integrated with stuff because it was busy doing something else first sort of like uh things i've seen before and other people have as well i can't remember who it was when i was working on the help editor thing if you create a package resource from inside of a command load resource won't see that resource until after the command exits even if you do the same sublime set timeout zero so that just immediately cycles back and does it again although there's no guarantee that that's actually how that works but i think that's actually i mean i probably got more prints in here than one technically requires whoops yeah let's get rid of those ones too now i'm just sort of weirded out that echo isn't at the top of the list anymore but i guess if it's just a list of things that isn't necessarily sorted that doesn't really mean anything does it i'll probably have to sort the list by the command key or something actually i guess you why can you sort a quick panel item probably i guess i don't know enough python off the top of my head to pull something like that off but that doesn't really matter if the idea is you're probably going to want to do something like this anyhow this is the select color scheme command cool i think that's actually fairly useful as a thing at least to you know someone like me that spends a bunch of time nerding out looking at default implementations of things and helping people with stuff i totally this morning spent a bunch of time looking into that ad killer ring command just because it was more interesting than emails that were happening on a monitor over there where someone was unhappy that someone's database that's not mine wasn't doing the thing that it was supposed to do and for some reason people kept talking to me about it sublime is way more interesting is one of those extraneous commands doing something it is in fact a collection yes not in this particular file which extraneous commands were you talking about there well this particular thing is a list so yeah i imagine you have to that's not something that i can do off of the top of my head but now you can call a sort function and give it the magic like lambda or whatever that gets invoked so that it could go on quick panel item dot trigger to sort it that way so that the list of stuff would be in a particular order let's see actually i probably could edit it then this that probably would have been a faster way to pull that off accepts two arguments was one of those affecting the view selection i don't think so i think just the go-to definition nothing else should have any effect on the selection i don't think that's the only thing that's actually oh well uh i think a timer to zero would push the definition selection ah i get you yeah that only seems to be required in the on load there but maybe this maybe the selection wasn't set up yet depending on i don't know anything about the internals of that where's the this return oh it sorts the list in place all right that's handy no is that not a built-in thing oh what does the file look like without go to definition if i just load it and then don't do anything here uh leave that part out so all it does is destroy the view listener oh right hang on let me uh let me comment that aborted attempt out the selection ends up being that's not useful way at the bottom of the file it's the very last line that's not something i think that just happens for well even if you do this oh no i guess not i've seen that before where oh this this i think uses perhaps maybe a different no i can't be using a different thing can it uh see the cursor when i did that ends up at the bottom of the file which seems to happen fairly frequently one of the things i did in override audit when you do stuff is make sure that it jumps the cursor to the top of the file so because that's more what you would expect but that seems to be fairly of course lord knows what else might be running in this operation that could be screwing with it but i'm pretty sure i've seen that even in sandboxed copies that are you know completely bone stock but it's interesting that for echo it doesn't do that but for longer files it does that's weird oh i picked the wrong yeah is this only with files being loaded from dollar packages uh yes yes indeed otherwise i would have used the other uh the actual method instead of the command and then it would return the view directly but uh you can't open stuff from packed archives that way although i do have some code in override audit that knows how to pull those sorts of things out as complicated as it is to open the thing as a zip file is that more like what we're looking for does it make sense to have the command list sorted i imagine it probably does here's that time someone wanted an exec command that would kill a build if it didn't finish in a certain period of time that's so you know so will in the chat here is saying that uh we should probably make open file not put the selection at the end that sounds like another bug i've always just sort of assumed that it was done that way on purpose it's bothered me for a long time mostly because when i open a file and start typing the selection makes it jump all the way to the bottom in fact one of the things that i added in override audit was the idea that when you create a report it forces the cursor to be at the top because otherwise you know the append puts the cursor away at the bottom and then the same thing would happen although i say it bothered me for a long time but it took me a while to actually get around to adding the one line of code that jumps the cursor back to the top of the pile the only issue with this as such is that override audit commands don't appear in here because it's a python 3.3 command right um but if there was a command that was an application command with a python 3.3 name then or yeah if there's a python 3.3 plugin that just gathered this information and then called the python 3.8 version it could add extra commands in that seems like would actually be pretty good for opening a file from a sublime package that shouldn't be the case yeah i probably i would imagine the thing that bothers oh ah apparently i have some annoying printing going on in there oh sorry the command log it's it totally logged the append that i threw that in there let's turn that off uh what was i saying there now i've totally forgotten oh the uh the whole idea that uh you get this unable to open message here which for me always made perfect sense because i'm imagining in my head the implementation of this is the thing tries to actually load the file that you gave it and then discovers that it's not there but then it notices that it's in the package directory so it pulls it out of the uh appropriate thing and opens it that way and sets up the view so yeah i imagine i can imagine in my head that the way that code is structured that there's something that's involved in opening a file and that would generate an error but then something else that called it checked the return value so i've i've never you know had an issue with this but this seems to annoy the jeebers out of a lot of people certainly uh you know often there's a problem on stack overflow or something and someone will say you know something's not working and someone says hey check the console do you see any error messages and there's a yeah i tried to open it says it had an error opening my preferences but they opened anyway and then you have to politely say that probably has nothing to do with why your python code isn't executing but good to know that's totally not a problem i think i guess the mind does wonder what sorts of things people are doing in packages to get around something like this i mean one of the things that i really like about sublime is how i could i decided i wanted a list of commands that's all annotated and you know here it is i can see where it is what arguments that it actually takes jump directly to it although that one may or may not work uh because i'm not entirely sure what this one was actually trying to do that's been sitting in there for quite some time but will knows why it isn't working real time debugging this are the the fun internal mechanism open files implementation waits for the empty file to load and then inserts the file content sort of like the old append type operation oops that's cool let's try something here uh really let's reload this is the python 3.3 package that you were listening to the onload event at that point the contents haven't been inserted yeah interesting one of the fun things for you know being a nerd and playing with stuff like this is trying to think of you know of all of the problems that i've seen in all of my many many gray hair inducing years of software development trying to sort of intuit how things might be working behind the scenes based on what it is that you're seeing so it's nice to actually get you know sometimes actual correlation that yeah that is exactly what's happening or no it works completely different than that does f string work instead of it it will work in the newer builds that have the python 3.8 runtime but it won't work in legacy stuff so primarily i don't use that because i never really did any python development at all until i started using sublime and then i wanted to create plug-ins so i had no choice but to learn python so that i could do that and that was python 3.3 which doesn't have f strings so all of my knowledge is mostly uh garnered from there so we're going to have to get better at that so package control has a really long module list now the fun thing is override audit commands appear in this one but the echo command doesn't oops which is actually kind of neat this seems like a very clever end run on pulling something like this off this sample command could assume that it's running in the 3.8 plug-in pipe or plug-in environment and just gather the list of commands like this and do something with it but what if there was another command in the python 3.3 plugin host in a different package because it would have to be that did the exact same thing but it just called this command when it gathered the list and provided this command a dictionary with all of the information that it gathered then this one could add to that dictionary and have the full command list the only potential issue there is shuffling a gigantic dictionary of stuff across in arguments to a command that's probably not i mean it's not the sort of thing i would want to do on a regular basis but one doesn't spend their whole day looking up commands i assume or the only downside to that is having to have a second package to be able to do it but i wonder if that's what automatic package reloader is doing because it has its own little as a matter of fact i think it might actually install itself as a 3.8 plug-in and then also install a 3.312 but i forgot that i actually had that in the thing and i could just do that the easier way it's also really cool that that automatically skipped it over to the other plug-in host too what time we got oh that's actually not too shabby i think we did pretty good uh we got something doing that the thing that we thought we wanted it to do we found some number of bugs in sublime or at least logical inconsistencies i think what's the count they're like five or something some of which may potentially be related to my atlantic distributions crappy font choice but all in all that's actually not too terrible of a of a night pretty good considering you know this time yesterday i had a headache because i my eyes had been dilated in the world that looked so fuzzy for so long i'm going to push this button now i think we are going to uh call the stream there it is getting kind of late and we have gone through the two hours in record time i like and uh with record uh viewership as well so i'd like to thank everybody that watched for coming in especially will it's nice to have a sublime dev uh in the wings providing information and telling you when you're doing something a little silly or you know occasionally pointing out a bug i guess which isn't something that i expected to have happened uh so thank you all for watching uh next stream should be on tuesday um i'm not envisioning that i'm going to be called back to any sort of medical establishment on this kind of short notice what with the world at large being the way that it is and we will continue on perhaps with more modifications to this or with the planned thing that we were going to do working on the next release of override audit and until uh then uh remember you can subscribe to this channel and ring the bell notification icon if you want to know when i'm going live and hop in or you can subscribe to my other channel which is linked down in the description below where we do weekly sublime text videos every monday uh lately focusing on plugin 101 but probably got some other juicy tutorials of other another nature coming real soon now at least i hope so we'll see uh we'll see what the world brings until then though this is odat nerd asking you to please have a sublime day and a sublime night too do do you
Info
Channel: Terence Martin
Views: 654
Rating: undefined out of 5
Keywords:
Id: JiLa7R8OYhE
Channel Id: undefined
Length: 141min 30sec (8490 seconds)
Published: Thu Oct 15 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.