From 76add7750985d5c26eadb89659079820ec04ad6f Mon Sep 17 00:00:00 2001 From: Sacha Chua Date: Sun, 4 Dec 2022 10:52:11 -0500 Subject: Automated commit --- ...thin-emacs--sibi-prabakaran--main--chapters.vtt | 43 ++ ...recipes-within-emacs--sibi-prabakaran--main.vtt | 826 +++++++++++++++++++++ 2 files changed, 869 insertions(+) create mode 100644 2022/captions/emacsconf-2022-justl--justl-driving-recipes-within-emacs--sibi-prabakaran--main--chapters.vtt create mode 100644 2022/captions/emacsconf-2022-justl--justl-driving-recipes-within-emacs--sibi-prabakaran--main.vtt (limited to '2022/captions') diff --git a/2022/captions/emacsconf-2022-justl--justl-driving-recipes-within-emacs--sibi-prabakaran--main--chapters.vtt b/2022/captions/emacsconf-2022-justl--justl-driving-recipes-within-emacs--sibi-prabakaran--main--chapters.vtt new file mode 100644 index 00000000..836e8d54 --- /dev/null +++ b/2022/captions/emacsconf-2022-justl--justl-driving-recipes-within-emacs--sibi-prabakaran--main--chapters.vtt @@ -0,0 +1,43 @@ +WEBVTT + +00:00:00.000 --> 00:00:39.320 +Introduction + +00:00:39.320 --> 00:01:48.520 +Justfiles + +00:01:48.520 --> 00:02:27.680 +Executing recipes + +00:02:27.680 --> 00:02:56.440 +Other features + +00:02:56.440 --> 00:04:19.280 +Comparison with Makefiles + +00:04:19.280 --> 00:04:52.400 +justl.el + +00:04:52.400 --> 00:06:17.280 +Executing recipes in Emacs + +00:06:17.280 --> 00:06:36.600 +Options + +00:06:36.600 --> 00:06:57.320 +Eshell + +00:06:57.320 --> 00:07:15.520 +Going to the recipe line + +00:07:15.520 --> 00:07:39.560 +Re-executing recipes + +00:07:39.560 --> 00:08:56.600 +Example + +00:08:56.600 --> 00:09:34.680 +justl-exec-recipe-in-dir + +00:09:34.680 --> 00:10:02.040 +End diff --git a/2022/captions/emacsconf-2022-justl--justl-driving-recipes-within-emacs--sibi-prabakaran--main.vtt b/2022/captions/emacsconf-2022-justl--justl-driving-recipes-within-emacs--sibi-prabakaran--main.vtt new file mode 100644 index 00000000..cd239aa8 --- /dev/null +++ b/2022/captions/emacsconf-2022-justl--justl-driving-recipes-within-emacs--sibi-prabakaran--main.vtt @@ -0,0 +1,826 @@ +WEBVTT captioned by sachac + +00:00:00.000 --> 00:00:04.240 +Hi everyone, I am Sibi Prabakaran + +00:00:04.240 --> 00:00:09.560 +and welcome to my session on Justl Emacs Mode. + +00:00:09.560 --> 00:00:11.640 +A bit about me, I have been working + +00:00:11.640 --> 00:00:12.880 +as a Haskell Engineer + +00:00:12.880 --> 00:00:15.600 +at FPComplete for the last 4 years. + +00:00:15.600 --> 00:00:17.400 +I am based out of India. + +00:00:17.400 --> 00:00:20.680 +I occasionally blog at my website psibi.in + +00:00:20.680 --> 00:00:23.560 +where you can find more information about me. + +00:00:23.560 --> 00:00:25.000 +I have been using Emacs + +00:00:25.000 --> 00:00:26.920 +for more than a decade now. + +00:00:26.920 --> 00:00:28.160 +I help in the maintenance + +00:00:28.160 --> 00:00:31.080 +of the Terraform client for LSP mode. + +00:00:31.080 --> 00:00:33.960 +I have also authored dhall-mode and rego-mode + +00:00:33.960 --> 00:00:35.000 +which are the major modes + +00:00:35.000 --> 00:00:39.320 +for the respective languages. + +00:00:39.320 --> 00:00:40.680 +Before jumping into the demo + +00:00:40.680 --> 00:00:42.040 +of the Emacs package, + +00:00:42.040 --> 00:00:44.160 +I would like to give a brief introduction + +00:00:44.160 --> 00:00:46.280 +about justfiles and what it is. + +00:00:46.280 --> 00:00:49.000 +I will also try to compare it with Makefiles + +00:00:49.000 --> 00:00:53.640 +as it takes a lot of inspiration from it. + +00:00:53.640 --> 00:00:55.640 +What you see currently in the buffer + +00:00:55.640 --> 00:00:57.320 +is a sample justfile. + +00:00:57.320 --> 00:00:59.480 +If you have previously used Makefiles, + +00:00:59.480 --> 00:01:00.480 +you would be able to see + +00:01:00.480 --> 00:01:02.280 +that there is quite a bit of similarity + +00:01:02.280 --> 00:01:03.560 +between them. + +00:01:03.560 --> 00:01:05.080 +Anything that starts with hash + +00:01:05.080 --> 00:01:07.120 +is a documentation comment. + +00:01:07.120 --> 00:01:09.160 +You can see that I have the first recipe + +00:01:09.160 --> 00:01:10.920 +which is named as default. + +00:01:10.920 --> 00:01:12.520 +So if you run the just executable + +00:01:12.520 --> 00:01:14.120 +without any arguments, + +00:01:14.120 --> 00:01:15.400 +by default it is going to run + +00:01:15.400 --> 00:01:17.200 +the first recipe. + +00:01:17.200 --> 00:01:18.440 +This recipe's definition + +00:01:18.440 --> 00:01:20.080 +calls the just command + +00:01:20.080 --> 00:01:21.920 +in turn, with the two arguments, + +00:01:21.920 --> 00:01:24.080 +namely --list and --unsorted, + +00:01:24.080 --> 00:01:25.680 +which basically asks just + +00:01:25.680 --> 00:01:27.800 +to list down all the recipes + +00:01:27.800 --> 00:01:29.680 +in an unsorted order. + +00:01:29.680 --> 00:01:32.400 +Each line of each recipe is executed + +00:01:32.400 --> 00:01:33.920 +by a fresh shell. + +00:01:33.920 --> 00:01:35.120 +That pretty much + +00:01:35.120 --> 00:01:36.360 +is the high level overview + +00:01:36.360 --> 00:01:38.520 +of getting started to use this tool. + +00:01:38.520 --> 00:01:40.760 +This tool assumes the presence of a shell + +00:01:40.760 --> 00:01:43.480 +which is bash in most GNU/Linux systems, + +00:01:43.480 --> 00:01:44.840 +but you can configure it + +00:01:44.840 --> 00:01:47.160 +to explicitly use any specific shell + +00:01:47.160 --> 00:01:48.520 +you have in mind. + +00:01:48.520 --> 00:01:50.480 +Let me in fact go and try executing + +00:01:50.480 --> 00:01:52.600 +the first recipe. + +00:01:52.600 --> 00:01:53.760 +I will first execute it + +00:01:53.760 --> 00:01:55.160 +without any arguments, + +00:01:55.160 --> 00:01:59.000 +which will force it to run the first recipe. + +00:01:59.000 --> 00:02:01.800 +As you can see, it listed all the recipes. + +00:02:01.800 --> 00:02:03.200 +Now I can actually execute + +00:02:03.200 --> 00:02:04.200 +a particular recipe + +00:02:04.200 --> 00:02:06.640 +by passing an explicit recipe name. + +00:02:06.640 --> 00:02:08.400 +Let me execute the hello recipe now + +00:02:08.400 --> 00:02:11.920 +which will basically print "hello world". + +00:02:11.920 --> 00:02:15.320 +It works as expected. + +00:02:15.320 --> 00:02:17.040 +As you can see, that's all that's required + +00:02:17.040 --> 00:02:18.600 +to get started with this tool. + +00:02:18.600 --> 00:02:20.348 +You create a file named justfile + +00:02:20.349 --> 00:02:22.800 +in a directory, define some recipes + +00:02:22.800 --> 00:02:23.640 +and then run them + +00:02:23.640 --> 00:02:27.680 +via the just executable. + +00:02:27.680 --> 00:02:28.440 +Note that there are + +00:02:28.440 --> 00:02:30.680 +various other features in justfile. + +00:02:30.680 --> 00:02:32.240 +You can define variables, + +00:02:32.240 --> 00:02:33.280 +mark some variables + +00:02:33.280 --> 00:02:35.520 +to be exported as environment variables, + +00:02:35.520 --> 00:02:37.280 +have optional parameters + +00:02:37.280 --> 00:02:38.800 +that can be passed to a recipe. + +00:02:38.800 --> 00:02:40.960 +You can also set up dependency + +00:02:40.960 --> 00:02:42.480 +between recipes + +00:02:42.480 --> 00:02:44.920 +and also write scripts within a recipe + +00:02:44.920 --> 00:02:46.800 +in a language of your choice. + +00:02:46.800 --> 00:02:48.560 +I won't be going into the details, + +00:02:48.560 --> 00:02:50.120 +but I encourage you to go through + +00:02:50.120 --> 00:02:51.640 +the very helpful manual page + +00:02:51.640 --> 00:02:56.440 +to learn more about it. + +00:02:56.440 --> 00:02:59.200 +Also, let me compare it with Makefiles. + +00:02:59.200 --> 00:03:00.800 +I do think it's kind of unfair + +00:03:00.800 --> 00:03:02.160 +to compare both the tools + +00:03:02.160 --> 00:03:04.760 +since make is a build automation tool + +00:03:04.760 --> 00:03:07.520 +whereas just's goal is a task runner, + +00:03:07.520 --> 00:03:09.320 +and since just doesn't try to be + +00:03:09.320 --> 00:03:10.440 +a build system, + +00:03:10.440 --> 00:03:12.480 +it can avoid the associated complexity + +00:03:12.480 --> 00:03:15.080 +that comes with the tool like make. + +00:03:15.080 --> 00:03:17.040 +There is one nice historical fact + +00:03:17.040 --> 00:03:18.200 +about just. + +00:03:18.200 --> 00:03:19.560 +The initial version of just + +00:03:19.560 --> 00:03:21.640 +relied on make command being available, + +00:03:21.640 --> 00:03:23.360 +so it was basically + +00:03:23.360 --> 00:03:25.440 +a glorified wrapper around it. + +00:03:25.440 --> 00:03:26.440 +But it was removed, + +00:03:26.440 --> 00:03:27.760 +and justfile doesn't have + +00:03:27.760 --> 00:03:29.680 +that dependency anymore. + +00:03:29.680 --> 00:03:31.680 +If you are using make as a task runner + +00:03:31.680 --> 00:03:33.400 +then you would have to use + +00:03:33.400 --> 00:03:35.400 +something called phony targets. + +00:03:35.400 --> 00:03:37.240 +I don't want to go into the details, + +00:03:37.240 --> 00:03:39.240 +but makefiles have good reason + +00:03:39.240 --> 00:03:41.040 +for why they need something like that. + +00:03:41.040 --> 00:03:44.080 +Since justfile is not a build system, + +00:03:44.080 --> 00:03:45.200 +it doesn't have to deal with them. + +00:03:45.200 --> 00:03:47.400 +The error message + +00:03:47.400 --> 00:03:48.680 +and user experience of this tool, + +00:03:48.680 --> 00:03:50.480 +in my opinion, is better. + +00:03:50.480 --> 00:03:52.760 +To show you a concrete example, + +00:03:52.760 --> 00:03:54.920 +justfile errors out by default + +00:03:54.920 --> 00:03:56.400 +if you have duplicate recipes. + +00:03:56.400 --> 00:03:58.840 +This is in contrast with make + +00:03:58.840 --> 00:04:00.720 +where I believe it prints out + +00:04:00.720 --> 00:04:01.760 +a warning about it, + +00:04:01.760 --> 00:04:03.840 +but still executes the target action. + +00:04:03.840 --> 00:04:06.600 +Justfile also gives you the ability + +00:04:06.600 --> 00:04:08.200 +to easily create scripts + +00:04:08.200 --> 00:04:10.680 +written in any language within a recipe. + +00:04:10.680 --> 00:04:12.680 +My personal opinion is that + +00:04:12.680 --> 00:04:14.200 +if you are using makefile + +00:04:14.200 --> 00:04:15.200 +as a task runner, + +00:04:15.200 --> 00:04:17.440 +you might want to check out justfile + +00:04:17.440 --> 00:04:19.280 +to see if it will suit your workflow. + +00:04:19.280 --> 00:04:25.000 +With that, I'll move on to justl.el, + +00:04:25.000 --> 00:04:26.800 +which is basically an Emacs package + +00:04:26.800 --> 00:04:28.120 +for driving justfiles. + +00:04:28.120 --> 00:04:29.920 +I started writing this tool + +00:04:29.920 --> 00:04:31.200 +around a year ago + +00:04:31.200 --> 00:04:33.720 +when my usage of justfile increased. + +00:04:33.720 --> 00:04:35.440 +The objective of the tool + +00:04:35.440 --> 00:04:37.480 +is to reduce the usage of the CLI + +00:04:37.480 --> 00:04:40.040 +and drive the execution of the recipes + +00:04:40.040 --> 00:04:41.480 +natively within the editor. + +00:04:41.480 --> 00:04:44.000 +Let me take you back to the justfile + +00:04:44.000 --> 00:04:45.240 +which we saw previously. + +00:04:45.240 --> 00:04:47.320 +This time we will drive it + +00:04:47.320 --> 00:04:48.840 +within the editor itself, + +00:04:48.840 --> 00:04:51.400 +instead of executing commands via vterm + +00:04:51.400 --> 00:04:52.400 +as done previously. + +00:04:52.400 --> 00:04:54.640 +So the idea is you either + +00:04:54.640 --> 00:04:56.000 +open the justfile, + +00:04:56.000 --> 00:04:57.840 +or any other file in the directory. + +00:04:57.840 --> 00:04:59.160 +That doesn't matter, actually. + +00:04:59.160 --> 00:05:00.720 +Once you do that, + +00:05:00.720 --> 00:05:02.360 +you call the justl command. + +00:05:02.360 --> 00:05:06.640 +Now as you can see, it lists down + +00:05:06.640 --> 00:05:07.520 +all the recipes, + +00:05:07.520 --> 00:05:09.280 +along with the description if present. + +00:05:09.280 --> 00:05:11.520 +You can move on to different recipes + +00:05:11.520 --> 00:05:13.080 +by your usual keybinding. + +00:05:13.080 --> 00:05:15.680 +And for executing a specific recipe, + +00:05:15.680 --> 00:05:18.240 +you have to press the e keybinding, + +00:05:18.240 --> 00:05:19.720 +and that will run the recipe + +00:05:19.720 --> 00:05:21.600 +and show its output + +00:05:21.600 --> 00:05:23.400 +on a special buffer named *just* + +00:05:23.400 --> 00:05:25.000 +which is built on top of + +00:05:25.000 --> 00:05:27.040 +the compilation mode available in Emacs. + +00:05:27.040 --> 00:05:28.760 +Let me actually try + +00:05:28.760 --> 00:05:30.240 +executing the hello recipe + +00:05:30.240 --> 00:05:32.440 +which we previously executed in vterm. + +00:05:32.440 --> 00:05:38.160 +As you can see, + +00:05:38.160 --> 00:05:39.680 +it executed the recipe + +00:05:39.680 --> 00:05:41.120 +and the "hello world" output + +00:05:41.120 --> 00:05:42.400 +is visible in the just buffer. + +00:05:42.400 --> 00:05:44.400 +You can also see that there is + +00:05:44.400 --> 00:05:45.880 +other metadata like + +00:05:45.880 --> 00:05:47.480 +when it started executing + +00:05:47.480 --> 00:05:49.520 +and when did it finish executing. + +00:05:49.520 --> 00:05:51.520 +If a recipe execution fails, + +00:05:51.520 --> 00:05:53.160 +it will also change the color + +00:05:53.160 --> 00:05:55.760 +and print the corresponding exit code. + +00:05:55.760 --> 00:05:57.320 +Let me actually show you + +00:05:57.320 --> 00:05:59.080 +by modifying the hello recipe + +00:05:59.080 --> 00:06:03.600 +and making it exit. + +00:06:03.600 --> 00:06:08.400 +As you can see, + +00:06:08.400 --> 00:06:10.480 +it clearly indicates the error message now. + +00:06:10.480 --> 00:06:12.720 +That is a pretty much + +00:06:12.720 --> 00:06:14.240 +a good high level overview + +00:06:14.240 --> 00:06:15.680 +of how to execute recipes + +00:06:15.680 --> 00:06:17.280 +using this Emacs extension. + +00:06:17.280 --> 00:06:21.720 +If I press the h or the ? key, + +00:06:21.720 --> 00:06:23.520 +it will display the various ways + +00:06:23.520 --> 00:06:24.160 +to drive it. + +00:06:24.160 --> 00:06:27.480 +Now as you can see, + +00:06:27.480 --> 00:06:29.320 +you can pass various options to it. + +00:06:29.320 --> 00:06:31.600 +I find the dry run option effective + +00:06:31.600 --> 00:06:34.560 +whenever I have to print the recipe contents + +00:06:34.560 --> 00:06:36.600 +without actually executing the recipe. + +00:06:36.600 --> 00:06:39.720 +There are also various ways to execute it. + +00:06:39.720 --> 00:06:42.960 +You can use Emacs's eshell to execute it + +00:06:42.960 --> 00:06:45.040 +by pressing the E keybinding. + +00:06:45.040 --> 00:06:48.400 +Let me try executing the hello recipe again, + +00:06:48.400 --> 00:06:50.760 +but this time via Emacs's eshell. + +00:06:50.760 --> 00:06:54.840 +As you can see now I have an eshell instance + +00:06:54.840 --> 00:06:57.320 +where it executed the just hello recipe. + +00:06:57.320 --> 00:07:02.440 +You can also directly + +00:07:02.440 --> 00:07:03.680 +go to the recipe line + +00:07:03.680 --> 00:07:05.000 +by pressing the return key. + +00:07:05.000 --> 00:07:08.040 +So let's say if I want to + +00:07:08.040 --> 00:07:09.360 +go to the recipe build app + +00:07:09.360 --> 00:07:12.160 +all I have to do is press the return key + +00:07:12.160 --> 00:07:14.400 +and it will go to the just file + +00:07:14.400 --> 00:07:15.520 +with the proper line. + +00:07:15.520 --> 00:07:19.800 +You can also re-execute the same recipe + +00:07:19.800 --> 00:07:21.320 +from the output just buffer. + +00:07:21.320 --> 00:07:23.320 +I find this very helpful + +00:07:23.320 --> 00:07:25.080 +when iterating on certain things. + +00:07:25.080 --> 00:07:26.720 +In my day job, + +00:07:26.720 --> 00:07:29.240 +I often have to work with a Kubernetes cluster, + +00:07:29.240 --> 00:07:30.480 +and I would have to write + +00:07:30.480 --> 00:07:33.360 +resource manifest files for applications. + +00:07:33.360 --> 00:07:36.376 +Having the ability to run the recipes + +00:07:36.377 --> 00:07:37.942 +while iterating on the project + +00:07:37.943 --> 00:07:39.560 +is very useful, in my opinion. + +00:07:39.560 --> 00:07:42.000 +Let me actually show you + +00:07:42.000 --> 00:07:43.680 +an example of what I am talking about. + +00:07:43.680 --> 00:07:46.680 +Let me run the build app recipe now, + +00:07:46.680 --> 00:07:48.400 +which will basically build the manifest + +00:07:48.400 --> 00:07:49.600 +and print it out. + +00:07:49.600 --> 00:07:58.160 +Now let me open one of the application files. + +00:07:58.160 --> 00:07:59.960 +I will open the ingress.yaml file. + +00:07:59.960 --> 00:08:06.120 +So I have this YAML file which I am working on, + +00:08:06.120 --> 00:08:08.600 +and I also have this output buffer + +00:08:08.600 --> 00:08:10.160 +which is basically the output + +00:08:10.160 --> 00:08:11.840 +of the build app recipe. + +00:08:11.840 --> 00:08:14.200 +Now I can basically go through this buffer + +00:08:14.200 --> 00:08:18.320 +and see if everything is alright, + +00:08:18.320 --> 00:08:21.760 +but I find out that I didn't want + +00:08:21.760 --> 00:08:23.920 +the hostname to be emacs2022. + +00:08:23.920 --> 00:08:25.840 +I wanted it to be just emacs. + +00:08:25.840 --> 00:08:29.000 +I can go and fix it in my YAML file, + +00:08:29.000 --> 00:08:34.160 +and then I can go on + +00:08:34.160 --> 00:08:36.160 +to the output buffer + +00:08:36.160 --> 00:08:38.520 +and basically just re-run the command + +00:08:38.520 --> 00:08:40.080 +by pressing the g key binding. + +00:08:40.080 --> 00:08:42.800 +As you can see, + +00:08:42.800 --> 00:08:48.160 +it executed the same recipe again, + +00:08:48.160 --> 00:08:49.440 +and I can see that + +00:08:49.440 --> 00:08:51.280 +the hostname is indeed emacs. + +00:08:51.280 --> 00:08:55.000 +I find this kind of workflow very convenient + +00:08:55.000 --> 00:08:56.600 +while I am working on a project. + +00:08:56.600 --> 00:08:59.320 +Another way of interacting + +00:08:59.320 --> 00:09:00.440 +with the justl extension + +00:09:00.440 --> 00:09:02.400 +is by using the interactive function + +00:09:02.400 --> 00:09:04.280 +justl-exec-recipe-in-dir. + +00:09:04.280 --> 00:09:06.040 +The use case of this function + +00:09:06.040 --> 00:09:07.840 +is executing a one-off recipe + +00:09:07.840 --> 00:09:09.920 +while you are working on something else. + +00:09:09.920 --> 00:09:11.960 +Let me show you an example of it. + +00:09:11.960 --> 00:09:19.800 +As you can see, it shows me + +00:09:19.800 --> 00:09:21.320 +a drop down of various recipes + +00:09:21.320 --> 00:09:22.640 +available in the justfile. + +00:09:22.640 --> 00:09:24.880 +You can choose any particular one + +00:09:24.880 --> 00:09:26.800 +and execute the corresponding recipe. + +00:09:26.800 --> 00:09:28.360 +In this case, I will choose + +00:09:28.360 --> 00:09:29.640 +the build-app recipe, + +00:09:29.640 --> 00:09:31.320 +and we will get the output + +00:09:31.320 --> 00:09:32.280 +in the *just* buffer + +00:09:32.280 --> 00:09:33.200 +which should be similar + +00:09:33.200 --> 00:09:34.680 +to what we saw previously. + +00:09:34.680 --> 00:09:43.920 +So this was a quick introduction + +00:09:43.920 --> 00:09:45.120 +to what justfile is + +00:09:45.120 --> 00:09:46.800 +and how to drive them within Emacs. + +00:09:46.800 --> 00:09:48.600 +Hopefully it was helpful + +00:09:48.600 --> 00:09:50.160 +and it would encourage you + +00:09:50.160 --> 00:09:51.480 +to use justfiles in your workflow. + +00:09:51.480 --> 00:09:53.800 +Thank you for allowing me to present. + +00:09:53.800 --> 00:09:55.480 +I am available in IRC + +00:09:55.480 --> 00:10:02.040 +if you have any questions. -- cgit v1.2.3