 Hello everyone Does anyone use emacs? All right anyone else Okay Hands for Vim Awesome, okay, and a big big noise so heckles, please now Just so we can get that out of the way All right as as you all know we can actually run Vim inside of emacs So you could come on over so Rumour has it that emacs has some of the best Get integration in an editor as an emacs diehard. I've been using it since the 90s I Would say no no it doesn't but it's really good all the same some of the best I've seen is an IntelliJ And the reason why is because they stole every single possible idea from this Plus the blind text plus fugitive So they're pretty smart at absorbing features and in a way That's why they're similar to emacs because we just suck all the features in so The big one is magic That's our grand central for Get integration, but we have Get gutter Probably everyone's seen some version of this in something Sublime text. I think was the first thing to have this Maybe but it's everything now, right? I think you've got it in Vim you've got it in IntelliJ And it's a just set of changes on the side It's pretty handy get time machine. So that's live in buffer View of the history of your file which is also quite handy and Smurge is Kind of secret source actually spinning emacs since the 90s And it's just a nice way of dealing with conflicts So you can just jump quickly through your file find the conflicts So keep mine keep theirs keep more or revert to base now BC mode is a little mode that's kind of It's not get specific. It's version control agnostic. So actually what's the CVS SVN HQ VSS you name it But that's for really kind of die-hard people who've been using it for a really long time and have had to work on Over here over there there there and just really hate using anything else like me So let's look at magic. This is magic's repository view I would recommend never ever using this because what I've done here is set up all the folders that I have get reposed in Shappens to be to that. I care about one's my workspace and one's my Let's go at the top Emacs D so the emacs D is like a 5,000 commit history over 10 years The rest are significantly smaller, but it's an easy way for me to jump to my projects But normally I'm gonna be working on one project at a time So let's go and look at one It's fun. So This is the Magic status view so we'll get to that in a moment now to get help you read the lovely manual Here Which is big pretty big not that big and It's searchable as a single file, which is quite nice Also, you can press the question mark any time and you just get a help screen It's vimish in the way that it's Model you press single keys at a time to navigate through No, um, yeah yoga So the repository list that I mentioned you can set this up just by using the custom ice cream, which is a Kind of an attempt at a gooey ish Click and fill in the forms kind of config thing for emacs, which is fine for the Contra I mean aficionado you can actually set up with emacs lisp But probably that's a Talk for another time But you can get a big list of all your repositories and if you have many that aren't in sync What they're gonna do is not only hit all the repositories and get them for you and list them It's also gonna check upstream with everything and then show you how many Up and down you're out, which is kind of useful Not for me, but maybe for some people it's Something you want to be in touch with But my tip is always know which repository you're supposed to be working with and I don't do that and hence We use magic status as a kind of home So this is a home for a project to emacs theme so This is what happens when we press the key, so let's do this question mark we get all the top level Kind of commands. We're gonna go through most of these Quickly they're not Any different from what you'd be doing on the command line. Let's pop back here. So fetching and pulling so I press question mark so we get it fetching and pulling Luckily, I have a cursor I can move it around so normally fetch and we can pull from origin elsewhere or all remotes We can also fetch in the branch or an explicit ref spec and we can fetch from a sub module Normally, it's just a P. So we're gonna fetch and then pull from origin Get finished so if ever I want to see what actually happened I can press dollar and I get a basic command line output so imagine that magic and Emacs is always going to be trying to be a shell. It's not going to be trying to be a gooey Now if we wanted to pull from somewhere else or all it's pretty straightforward Just hit a for all and just fit elsewhere and we can actually specify remote just on the fly Look at merge strategy in a moment in branches There are other options you can set but I think really We're gonna look at that in something else. So Yeah, so we can say prune deleted branches as we pull By doing dash P and we set it on Now in every single one of these little menus we get these common commands For setting defaults and also saving them. So they then turn into your conflict Staging and un-staging. So let's make some changes to a file EL So I'm gonna change some colors just for fun. Let's decrease the hue on this by steps Let's make the red blue because you know, that's good And the purple can be something else Whoops made the purple green So say that and we'll pop back into the status. So you'll can notice That's a bit bit of a shame Can we do something about that? Yes, we can Set the internal border to 100. Okay There we go. So you got git gutter popping up there as purple. So there's changes in place I remove a line I get a red If I add a new line I get oh, okay, I already had lines there. So I've got to do something else. All right, I Use blue is green because I yeah, I'm a Japanophile So off we go and we'll go back to the status And I'm gonna give that its own buffer over here. Oh Oh Let's try that again, and I think that borders a little bit too big. So I've got unstage changes here So let's go and look at our preso again and see what we got so we can stage and unstage files Stage Unstage S and U I Can look at the diff Just by pressing tab and Roll through and it will it will basically break it up into hunks So you knew that so let's stage a hunk Right so that big hunk gets staged and the other state the other hunk is not stage so we can pop over here It's in the stage view and the unstage has this Now let's say I want to unstage this one Just these lines Okay, unstage so now The unstage changes has that line and the other hunk So it's relatively granular now if I wanted to say I'll look you know kill that I can also discard it So when we go back to the file, actually, we're just we're gonna kill all those changes because they're useless So we pop back into thing so our new files our new lines have gone and We do one here so that we can see it nice and easily Okay, kill those changes This one's there and we're gonna kill that and now there's no changes so committing It's not the most exciting thing in the world There is a git commit mode that can enforce certain things for us So let's go and change something. I'm gonna add magenta So that's ff 0 0 ff. It's a horrible color back in here so Pop there. We can see that we've got our version change and we've got the The thing ready to go So we're just gonna stage the whole thing okay, so the cool thing about commits are all the options that we've got access to in here and Remembering that we can use our common commands to set defaults and save them so if you want to stage and modify all as Like as protein then you can just do a About an empty You save a boost We can bypass git hooks We can add sign off We can reset author. We can override the author. We can sign using PGP. I'm not gonna do that now We can reuse another message and so on and then when you go back if you haven't saved them None of those remain just nice So we do a commit and then we have an unpushed commit sitting ready to go to origin master So we're behind it and we can tag it And I'm gonna do the tag now because I haven't actually got it in the presentation So we can create delete or prune tags So if there's no commits actually attached to the tags anymore, they can get removed We can do a force push on it on a tag we can sign the tag and we can annotate the tag with a note Just the normal stuff, but it's all kind of just there. Just kind of handy So we're gonna say 0.1 point six one Place it on master There we go So as I said, we're never gonna push that but we can amend it whoop and No, really so if we do want to reset it We'll deal with that in a minute. So push No, I'm not gonna push it But we can go and look at the push. So we have push force with lease push force No verify dry run. Well, we do dry run, right? That'll be fine. And we can also configure a bunch of variables. So what variables do we have? branch master description you can actually set descriptions and Set your emotes set your merges set the rebase mode true false You can set the push remote now interestingly Magic has changed its Push strategy or its merge strategy your upstream default is the branch you branched from So you branch from master into a feature and do your stuff and then you think oh, I know I'll push to a copy of this To my origin make sense, right? No, it's gonna push back to master if you just do a straight push So you must configure it first Original versions of what the earlier versions of magic didn't do that and There was also a versioning snafu about a year ago so It was like a bad version number. So whenever you did an upgrade it magic wouldn't be included So I discovered that The use cases that they were you know supporting had been long long changed from what I was used to and So they had a bunch of changes like this and it Flipped me out But it's not so bad you're pushing locally so you can Get out of it. Yeah, quick look at remoting. I go back here Okay, so a nice command look so Remoting is on M. I think yeah, we can add a new remote rename it remove it or set the URL We add one we just give it a name so Jojo and you set the remote URL It will remember some history, but it's not specific So whatever we've used in other things we can do so I can suddenly accidentally push to the wrong repeat repo and So, yeah, why not so we won't do that because that might that might make me sad later But it's all relatively straightforward now I did have right the back at the front. I'm sure we're not we're not gonna go there Um You can clone a repo from inside Emax There isn't much in the way of help there You simply say I want to clone a repo and it says give me a URL and that's it So you've still got to go and find your URLs and bring them in or you know know what they are by heart And type them up, but it won't give you like github Helpers, but writing one is really easy. So you can generally find that whatever you've got there If you want convenience to do something customized either for your project specifically or for a specific domain like getting stuff in github or Bitbucket or GitLab or wherever you can write a wrapper in you know very very short time Of course, you've got to spend a lot of time learning Lisp first, but it really isn't that hard And it sounds like a joke, but it's actually not It's really easy So let's look at the log. You don't believe me, do you? This is the log now we can configure this to be all kinds of fancy There's some nice things in it. So if it brush control W On the the line in the log it will copy my current char Into my clipboard or into my kill ring. So I have like a cyclical clipboard So I can go and do something else and they say oh, you know, I'm gonna rebase to this commit But if I do want to rebase I can hit rebase interactive and I can say Despite emerge in the rebase rage, I actually want to abort. Thank you for the warning So we're gonna do a pretend rebase We'll go back to this one So no really that's never gonna push. So we're gonna actually Drop that So there's actually control K So it does a nice decorated strike out For my nasty commit that I don't want so then when I'm done I can if I wanted to do something like squash I could do that But I'm I want that so we'll do this It's not So now we'd want to do the prune on the tags to get rid of the old tag, but that's about it Now the log has all kinds of nice stuff so I can say like a color graph. I can show signatures. I can show dips So go back to the log Now the diff is gonna the log will take a little bit longer You took a couple of seconds, but we can see the diffs in line in the thing just you know It's kind of nice but again, it's not Completely radical and there's a bunch of other tools to do this. It's just that what we do have is Really nice searching and the ability to filter and put this everywhere and every buffer behaves the same way so Can I ask who knows about get log? Searching dash capital G, right? Yeah so Regardless of whether you're using emacs This is super nice. So you can go and search every single diff in your commit log for a string or Regix I Think I think there is an option for it. I normally Keep it limited to strings, but you could do that now. I'm not going to do this because it takes a really long time But we get Search changes here and search messages, but basically it's a grep So I believe you can do regexes, but yeah Something to try at home You can limit to an author so you can just check your own stuff for that guy that keeps doing those bad commits And you can also limit the number of commits. So the default is 256 But obviously you can you know do what you like You can also trace the line evolution and I have no idea what that means anyone Trace line evolution. You know this Beautiful that is awesome. Thank you. Okay, and you can also limit to a file or files So that's pretty nice and that just adheres to globbin rules, right? Yeah So Now I could say I'm not going to do the search for a string because it takes a bit too long But do try it. It's very cool There's also change logs now. I never use this, but we can do a action Refresh Okay, never mind. We'll skip that So resetting Okay, well, we could have done the rebase interactive to get rid of that nasty commit with a reset so we'll do another nasty commit quickly and We'll reset it for fun So I'm going to take out all my bright colors Pop back into the status and then we'll stage it and commit and say What am I up to? Okay So what the hell am I up to so I want to reset that so I could just do a reset head Which will give me back. Oh, no, I don't have any stupid Without diffs, please go back minus you Okay Now I think here I can do a reset To here Yeah, okay, and then if I quit there then I get back to the stage thing so Obviously, that's fine and then I can just Kill that normally or I can do a reset hard So I do shift X and it's a hard reset when you do a shift shift X You get a bunch of options. So you can do that kind of stuff branching and check out Be no, let's branch So here I would need to so these are on set. So when I Do create a new branch? It's gonna Make it master. So we're gonna say We can check out or we can just check out a new branch. We can say oh No, oh Sorry, let's try that again Okay Branching see create. Okay. So sorry. This is create from so where where are we rooting our branch from so it doesn't default to where you are You can specify that so but they will provide the default from where you are so we'll create the ono branch and It says push is missing So they've changed it yet again So if I want to try and push Push ono on to So it remembers that we set Jojo as our last remote So it's gonna try and do that so it's actually changed again from this master or pushing back to the parent branch Which is good, but we've got the wrong one. So well That's news to me. That's good Hands who knows how to use branches. Okay. All right. Okay. I thought that would be a full hands I Think this is slightly out of scope, but We can just Diverge from whatever the current line of development is start working on the files in the repo change commit commit commit Push to a remote push to many remotes, but we're not on the main track anymore or on any other track We're on our own little track and gets cool because it can converge these changes back Through various strategies merging or rebasing Hands for rebase everyone know how to rebase Shall I do this? I guess I should do this quickly. So Let's do it like this Hmm This could be tricky. Yeah, this is tricky All right, let's go to scratch Okay, look at this wonderful diagram And every time I do plus I'm finishing some work. Okay, so I'm adding a commit So we're going to just call these One two three four five six And that's me working on these pieces right so we give those proper names in real life But we're gonna just number them now if I was to say Start branching off here. Oh, that's gonna be fun Okay, luckily, it's gonna let me do stuff We're gonna say Hey, all right So I'm gonna start doing stuff commits here And I want them to be one and two and whatever but I've obviously given them real names in real life, but Three now if I Happen to want to merge back with Let's call this Origin And this is me. Okay Now There's two ways I can do this. I can merge In which case I would Create a commit That basically gets merged back into six, which is normally fine. There's a lot of people that don't like this and The main reason is I think it's because messy to get these Tracks all diverging and it's crazy now What I would like to do so I'm not gonna do a pure rebase here I'm gonna do something called a squash and then a rebase So I've done all this work on me And I've gone from A to B. Okay, and that's basically a piece of work the rest of them is what we would generally think of as Work in progress and we probably don't need to keep those separate now. This is a Large topic of controversy in the get community. So I don't want to say anything definite use whatever workflow you like because it's your choice or your team's choice or your boss's choice and Never let it be said I'll get out of the way of that shit. So I Don't want that commit anymore. I don't want that come any more. I don't want that came any more And what I want is this to be a single commit So I would squash it so all the work contained in that branch is now here And that's effectively what a rebase is now The point of the a here is this is where we started right was it one or two because I've forgotten anyway It was too right. Yeah. Anyway, um when we squash Time that's not fair Time goes backwards. So the squashes do this Because the timestamp on a and the earlier commit gets to be the parent of the elements So what it would do when you squash them. So you remember I picked and dropped My fake commit that one was afterwards So it would have gone back in time now All these other guys are working on two three four and five and six and that these are these are pieces of work They may have some effect on the files that I've changed in my journey from A to B So what I want to do is catch up and not jump in on them and make a big mess so it's clean Again controversial and open for discussion to group all that work together into one piece So we squash and then We do something called a fast-forward Which is enough basically another name for a rebase in most people's books And we end up here and then what that does is become Seven and we kill that branch. Was that clear? I've never done that before I've drawn bloody rebase diagrams on windows and whiteboards and Done interpretive dances, so it's you know So hopefully that was instructive if not, I'm sorry So what are we what have we got left? Oh Lord submodules, so I guess the room also is Submodules hands was that just like no You hate them, right? Yeah Okay, and The other one everyone loves is sub trees is a quite new relatively speak well two years, right? Anyone? Yeah, you know you love sub trees So they're not really so so opinion, right? Are they interchangeable? They are not good. Thank you Um, and I think I said something like that here they are for distinctly different purposes now Submodules, oh This is far too much How we doing on time We good Um Submodules I want to include another lot library in my code base In most cases, this is a really bad idea you want to just have that dependency as something that you import a build time and That's a separate thing But there's a possible set of reasons why you'd want to include it in your code base So that other people can check it out and they all check it out together and it's but you will lock Your code to a specific version of the module code That's important. It's not just like a random download of that repo. So There's a need to sometimes update and To sync and to fetch and also to D in it and get it out of it It's definitely not a topic that I can cover with an interpreted dance so I stress the importance of Finding out about them and probably avoiding them as much as you possibly can right Manage your dependencies in a better way. I would say unless there's no choice Subtrees are when your code that you are taking care of is split into pieces and You're kind of developing them all and the fly together. It's a really bad way to do it I think as well, but it It's a possible strategy and the world is full of different strategies. So Find out about these things as well. I Really don't want to teach you anything about subtrees because what I could teach you is about that much Because I don't know but as always Whoops, okay Not that one Where you go? Okay, this one Submodules and subtrees are both covered And we can do things like squashing and ignore joins and rejoins and prefix and add messages to our merge And annotate and branch on to and all kinds of stuff But I definitely don't consider it a playground for fun, and that's the end of sub modules and subtrees. I Really don't even know why I put this in here. It's just to look cool, right? Back in the olden days before we had git Before we even had subversion we would do things with a version control tool called CBS I Can't even remember what CVS stands for anymore But it was horrible if you created a folder you couldn't delete it If you wanted to merge things together You best get like a massive like thing of purple drink and code in and you'd be okay It's just horrible, but One of the ways we cope with it was by creating patches So this has been a constant in almost every version control system is what a diff looks like Diffs look the same no matter what version control system you're using Unless they've really gone off the reservation and they want their product to just disappear so if you're using mercurial or bizarre or git subversion whatever a dot patch file, which is basically the text that makes up a diff Will apply to every single one of those repos so even if you're not working on the same Vertical control system somebody else. Hey, share your patches and What emacs does because it's kind of a workflow that a lot of emacs developers have been using for a long time the core product developers is to send a patch by email to a Branch manager or a release manager and to go. Yeah, that looks good and merge it basically like a very very old school Stone-age version of a git pull request on GitHub. In fact, they look so similar. It's scary Point being emacs makes is almost painless and almost as much fun as a pull request And we know how much fun pull requests are but I think patch files are probably showing me my age So This is outside of the magic status area. We can do get blame inside of our file So let's go and look at something. Hopefully we can find something. I didn't work on so we can blame somebody else or something All right, there's a bunch of upstreams on here. Oh Wow, okay So let's go and look All right, we'll look at CLS report in Hammerspoon if you use OS X Hammerspoon is awesome. So this is basically window management or automation and If you like driving things with a keyboard, it's super cool now So there's nothing special about this. It's just a normal text file with objective C in it and if I say magic blame I then suddenly decorate it with the Ha Little things that explain that Chris Jones worked on this and he doesn't like doing atomic commits What else we've got? Actually forget headers. Let's try modules No, okay Current really That is Surprising oh Never mind. I'm in the wrong place so dot M Now, this would be better. Okay Actually, it would be a mentosian code to be nice. So magic blame All right, still no atomic commits, but never mind So we can see as McGill and Chris Jones have been working on this feverishly adding some Functions that are exposed to lure which is nice and we can go and look directly at the commit and roll through everything that he committed altogether, which to me looks a bit unrelated but we can see Basically whenever there's a line in our code that makes no sense We can go look at it and we can view the commit and then from the commit message Decide how insane the developer was when they committed it, which is always a worry. So Normally though when you do a git blame you'll find that you did it or at least I do But that's because I can't remember what I did on Friday Get gutter Think we've covered this. Oh, oh, no, it's not working Okay, it's working right so I can do get gutter Pop-up so I can view the change It's not the nicest pop-up. We do have choice of pop-ups, but I honestly don't use this very much. So We can also Revert the hunk and say revert. Yes And it's gone or rather it's back It's convenient because you can change your files back when you're actually in them rather than going to somewhere else are going What was I doing? So let's have a quick look at this This is the git time machine and this is just my work. So we're gonna go back back back into time 2016 September Well, we can go so far back 2015 July hopefully we'll see some stuff disappearing in front of us. Oh Yeah, that should I should disappear in a minute. Yeah, all those disappeared and it's a much earlier version back in well It's version one. This is so much more meaningful when you're actually looking at a file that you wrote But Effectively, it's gonna save you popping into github or whatever and doing a click the history button And then scroll through and press page to go to the next page So you can just roll through Again, I stress that you know, obviously if you're a keyboard aficionado and you like Vim fugitive has similar tools That's awesome. You should use that Emacs generic version control commands. We can revert view revisions View the root diff get pull various things tons of tons of stuff But it's not so visually There for you We can do patrol X V And because I have which key on I can see a blue command. So We've got two pages Whoops Troll X V H next Not so many so we've got Commit and push diff various things. Okay Smurge who's done a Conflict resolution cool. How much pain was it? How many commits were in the rebase or in the merge, right? Keep your branches very short lived please and then you don't have to do this and you don't have to worry about how good the tools are If you if you feature branch Aim to have that feature done today If you can't rebase at the end of the day So that you keep up to date with everyone on master. So pull master back and rebase it. So you pull forward Otherwise you have 30 40 60 100 300 commits to reconcile with your branch And that's not good but sometimes You inherit some work from someone who's insane and Then you have to deal with this and it's none of your fault. So Having good tools is really really helpful. So let's go and have a look see At this so Now I'm ill-prepared. I Didn't get this bit done Let's pop into Google and grab ourselves a conflict diff and a conflict file Get see what we can get all I need are these little things here so We're gonna pretend this is ever so novel and there's lots and lots of different changes But imagine you've got all of these commits. Sorry all these conflicts to deal with Buried in your code It's not fun We're gonna say that this is just mark down No, not my down. Let's make it Ruby for fun Okay, so it sort of almost looks like real real code. So we're gonna say Switch on Smurge mode So I have a special Well, I have a special Set of shortcuts. So these aren't defaults But I can go to the next one the previous one I can keep all I keep mine and I keep the other and So just going Down it's gonna jump straight there. So there's any intervening lines don't care They're not conflicted. So who cares right? Now I always want to have mine because obviously I do the best work And then when I've been drunk the night before I always want to keep the other guys So we're gonna go and say other Except I quit the mode So there we go next So yeah, it won't let you just jump straight through the more like that. Oh mine is better there There's there's Now I'll grant you maybe you can't read all the differences and all the nuance between them But chances are you're going to know that There's was probably the right stuff or yours was for the right stuff There will be some cases where it's not but you want to get to those quickly So having a tool that you can just jump straight to the next diff. It really helps and then we can have a result file There are eight planets, right? Pluto anyone Okay now in closing and I did get to this at the beginning magic is not the reason you should use emacs So why should you it's because it's super programmable If something else comes out that has as much flexibility and is built in the same language you customize it with get it But that's not at him. It's not sublime Sadly, it's not then if there was something else that had an even nicer language than lisp I Would use that but here's the thing. I've been using emacs since I was in my 20s I'm not in my 20s now. I didn't even start using lisp with it until I was in my 30s If I hadn't invested 10 years in Customizing it and basically writing an editor with it. I Probably wouldn't use it But then these guys led by Sylvain Brenner in Canada built space max which is basically Vim but with Emacs lisp as a back. So if you do use Vim You might want to check it out Because it's really good. Oh by the way Even when it's not even mode you can actually do some pretty sweet editing stuff And I have a thing called emacs gifts where I noodle away and record about 70 different little videos So you can watch it do stuff. So take a CSV file for instance and then Pivot it. So there's the fields and there's the values Or something else or this or that space max and any questions It's right about two years old now, it's pretty mature. I would say it's still maturing But they've done a pretty good job The key features are this extensive Vim mode style Customization and packages that target specific languages. So if you use Python or C or Ruby or whatever They basically a group packages together now. I Don't use it And I have problems with it But I think it really benefits from having a big a really big and vibrant community behind it Who are building a single config? But that serves many purposes so One thing that emacs has lacked for All the time that's been around is a very very active community There's a lot of crotchety old guys who don't like change and really really resist changing their Their crooked hands shit It's one of the reasons why it took me ten years to really adopt it as my daily driver But it's so powerful. I can ignore that this the main maintainer or The former maintainer likes to eat his toenails in public and has very strange beliefs about all sorts of stuff Anyway, thank you. That's a wrap