diff options
author | EmacsConf <emacsconf-org@gnu.org> | 2023-12-03 07:20:44 -0500 |
---|---|---|
committer | EmacsConf <emacsconf-org@gnu.org> | 2023-12-03 07:20:44 -0500 |
commit | 2ba7da1442ea8616fd099b96d3a37af7d2900ec2 (patch) | |
tree | 347a2115aa412dbfc13140b12d799b946df4d0b1 /2023/captions | |
parent | 314cac098677ef561087e0c14cf56a3a38344545 (diff) | |
download | emacsconf-wiki-2ba7da1442ea8616fd099b96d3a37af7d2900ec2.tar.xz emacsconf-wiki-2ba7da1442ea8616fd099b96d3a37af7d2900ec2.zip |
Automated commit
Diffstat (limited to '2023/captions')
5 files changed, 4230 insertions, 0 deletions
diff --git a/2023/captions/emacsconf-2023-doc--literate-documentation-with-emacs-and-org-mode--mike-hamrick--main--chapters.vtt b/2023/captions/emacsconf-2023-doc--literate-documentation-with-emacs-and-org-mode--mike-hamrick--main--chapters.vtt new file mode 100644 index 00000000..33f318c5 --- /dev/null +++ b/2023/captions/emacsconf-2023-doc--literate-documentation-with-emacs-and-org-mode--mike-hamrick--main--chapters.vtt @@ -0,0 +1,71 @@ +WEBVTT + + +00:00:00.000 --> 00:00:57.760 +Introduction + +00:00:57.760 --> 00:02:14.080 +Org Babel and literate programming + +00:02:14.080 --> 00:04:53.479 +This presentation + +00:04:53.480 --> 00:06:55.779 +Getting started + +00:06:55.780 --> 00:07:23.499 +README + +00:07:23.500 --> 00:08:10.459 +Writing a code block + +00:08:10.460 --> 00:08:40.319 +:results none + +00:08:40.320 --> 00:10:36.959 +Confirmation + +00:10:36.960 --> 00:13:52.600 +Running blocks automatically + +00:13:53.000 --> 00:16:05.699 +Export options + +00:16:05.700 --> 00:17:25.739 +Substituting constants + +00:17:25.740 --> 00:20:02.960 +Getting the properties + +00:20:03.060 --> 00:21:05.239 +Macros + +00:21:05.240 --> 00:22:09.019 +Properties in practice + +00:22:09.020 --> 00:23:42.009 +Using a prefix + +00:23:42.010 --> 00:27:14.149 +Switching distributions + +00:27:14.150 --> 00:30:16.199 +A tour + +00:30:16.200 --> 00:31:09.249 +TeX and LaTeX + +00:31:09.250 --> 00:32:00.059 +Other prerequisites + +00:32:00.060 --> 00:36:20.609 +Caching + +00:36:20.610 --> 00:39:29.439 +Looking at the PDF + +00:39:29.440 --> 00:42:31.989 +Errors + +00:42:31.990 --> 00:42:45.200 +Final thoughts diff --git a/2023/captions/emacsconf-2023-doc--literate-documentation-with-emacs-and-org-mode--mike-hamrick--main.vtt b/2023/captions/emacsconf-2023-doc--literate-documentation-with-emacs-and-org-mode--mike-hamrick--main.vtt new file mode 100644 index 00000000..71fa30f7 --- /dev/null +++ b/2023/captions/emacsconf-2023-doc--literate-documentation-with-emacs-and-org-mode--mike-hamrick--main.vtt @@ -0,0 +1,2759 @@ +WEBVTT captioned by jc, checked by sachac + +NOTE Introduction + +00:00:00.000 --> 00:00:04.320 +Hello, everyone. + +00:00:04.320 --> 00:00:07.280 +This talk is on literate documentation + +00:00:07.280 --> 00:00:10.320 +with Emacs and org-mode. + +00:00:10.320 --> 00:00:12.080 +I'm going to take just a moment here + +00:00:12.080 --> 00:00:14.279 +to unpack what I just said. + +00:00:14.280 --> 00:00:17.800 +Emacs, as most of us probably already know, + +00:00:17.800 --> 00:00:21.360 +is a powerful text editor and list programming environment + +00:00:21.360 --> 00:00:23.480 +from the 1970s. + +00:00:23.480 --> 00:00:25.800 +Chances are, if you're attending this talk, + +00:00:25.800 --> 00:00:28.819 +you already know a bit about Emacs. + +00:00:28.820 --> 00:00:32.640 +org-mode is an Emacs major mode and authoring tool + +00:00:32.640 --> 00:00:36.360 +that helps you write documents in a plain text markup + +00:00:36.360 --> 00:00:37.739 +language called Org. + +00:00:37.740 --> 00:00:40.200 +These Org documents can be exported + +00:00:40.200 --> 00:00:42.520 +to a number of different document formats, + +00:00:42.520 --> 00:00:48.520 +like HTML, PDF, ODT, Markdown, and more. + +00:00:48.520 --> 00:00:51.160 +org-mode has a lot of features. + +00:00:51.160 --> 00:00:54.240 +It can be an outliner, a to-do list manager, + +00:00:54.240 --> 00:00:57.760 +an agenda, organizer, and much more. + +NOTE Org Babel and literate programming + +00:00:57.760 --> 00:00:59.600 +Today, we're going to be demonstrating + +00:00:59.600 --> 00:01:03.360 +what I consider to be org-mode's killer feature called + +00:01:03.360 --> 00:01:04.840 +Org Babel. + +00:01:04.840 --> 00:01:07.879 +Babel allows you to take human language prose, + +00:01:07.880 --> 00:01:11.400 +computer language source code blocks, and their outputs + +00:01:11.400 --> 00:01:13.840 +and weave them together seamlessly + +00:01:13.840 --> 00:01:16.160 +to form a cohesive document. + +00:01:16.160 --> 00:01:19.080 +It is seriously cool. + +00:01:19.080 --> 00:01:21.880 +Literate documentation is a play on the term + +00:01:21.880 --> 00:01:25.280 +literate programming, popularized by Donald Knuth + +00:01:25.280 --> 00:01:27.379 +in the early 1980s. + +00:01:27.380 --> 00:01:29.280 +Knuth's literate programming idea + +00:01:29.280 --> 00:01:31.920 +was that computer programs could be + +00:01:31.920 --> 00:01:34.880 +expressed in a natural language and be + +00:01:34.880 --> 00:01:38.800 +human-readable documents rather than written exclusively + +00:01:38.800 --> 00:01:40.799 +for machines to read. + +00:01:40.800 --> 00:01:43.000 +In a traditional program, you might + +00:01:43.000 --> 00:01:45.680 +have a bunch of machine-readable source code + +00:01:45.680 --> 00:01:48.560 +and a handful of human-readable comments, + +00:01:48.560 --> 00:01:51.600 +which attempt to describe what the program is doing. + +00:01:51.600 --> 00:01:54.360 +Literate programming flips this on its head. + +00:01:54.360 --> 00:01:56.680 +A literate program is a document that + +00:01:56.680 --> 00:02:01.160 +describes how the program works with machine-readable source + +00:02:01.160 --> 00:02:02.880 +code blocks inside of it. + +00:02:02.880 --> 00:02:04.800 +These source code blocks are later + +00:02:04.800 --> 00:02:08.440 +tangled out of the document and submitted to the machine + +00:02:08.440 --> 00:02:14.080 +either to be compiled or interpreted and ultimately run. + +NOTE This presentation + +00:02:14.080 --> 00:02:15.600 +Throughout this presentation, you'll + +00:02:15.600 --> 00:02:19.400 +see my browser window here on the left side of the screen. + +00:02:19.400 --> 00:02:22.240 +And on the right side, I've got a terminal session + +00:02:22.240 --> 00:02:23.960 +running tmux. + +00:02:23.960 --> 00:02:28.039 +This allows us to have a virtual terminal window connected + +00:02:28.040 --> 00:02:35.040 +to two separate Linux machines, one running Ubuntu Server 2204 + +00:02:35.040 --> 00:02:39.720 +and another running Fedora Server 38. + +00:02:39.720 --> 00:02:43.240 +I've specifically chosen these two distributions for my demo + +00:02:43.440 --> 00:02:46.720 +because they are representative of the two dominant flavors + +00:02:46.720 --> 00:02:49.880 +of GNU Linux, Debian and RedHat. + +00:02:49.880 --> 00:02:53.120 +In both cases, these are bare-bones server additions + +00:02:53.120 --> 00:02:55.440 +with the stock packages installed. + +00:02:55.440 --> 00:03:00.200 +I've manually installed a few packages like Git, emacs-noex + +00:03:00.200 --> 00:03:04.000 +to get the terminal version of emacs, and tmux. + +00:03:04.000 --> 00:03:06.000 +But otherwise, these Linux installs + +00:03:06.000 --> 00:03:08.719 +are what you'd get right out of the box. + +00:03:08.720 --> 00:03:12.480 +For this demo, I've created a literate org-mode document + +00:03:12.480 --> 00:03:16.360 +that describes how to build GNU Emacs from its source code + +00:03:16.360 --> 00:03:19.939 +on both Debian and RedHat-based systems. + +00:03:19.940 --> 00:03:22.920 +While both operating systems are very similar, + +00:03:22.920 --> 00:03:25.440 +they differ substantially on which packages + +00:03:25.440 --> 00:03:29.080 +are installed out of the box, how optional packages are + +00:03:29.080 --> 00:03:32.600 +named, searched, and installed, and of course, + +00:03:32.600 --> 00:03:34.240 +the distributions have different names, + +00:03:34.240 --> 00:03:36.800 +like Ubuntu or Fedora. + +00:03:36.800 --> 00:03:39.200 +I chose building Emacs from source + +00:03:39.200 --> 00:03:41.640 +as a topic for this demonstration + +00:03:41.640 --> 00:03:43.800 +because while the process is largely + +00:03:43.800 --> 00:03:46.880 +the same on both RedHat and Debian, + +00:03:46.880 --> 00:03:49.360 +there are a lot of minor little differences + +00:03:49.360 --> 00:03:52.680 +that need to be accounted for, which really prohibits you + +00:03:52.680 --> 00:03:57.120 +from hard coding names of packages and package management + +00:03:57.120 --> 00:04:01.200 +tools and distributions into your document. + +00:04:01.200 --> 00:04:05.320 +I suppose you could create two versions of the same document, + +00:04:05.320 --> 00:04:09.960 +one specifically for RedHat and one specifically for Debian, + +00:04:09.960 --> 00:04:13.280 +but that would be really tedious to maintain. + +00:04:13.280 --> 00:04:16.280 +Like if, for example, you updated some prose + +00:04:16.280 --> 00:04:18.720 +in one document, you'd have to remember + +00:04:18.720 --> 00:04:20.280 +to do it in the other one too. + +00:04:20.280 --> 00:04:22.920 +And if you weren't careful, the two documents + +00:04:22.920 --> 00:04:25.259 +could drift out of sync. + +00:04:25.260 --> 00:04:27.720 +In this demo, I'll show you techniques + +00:04:27.720 --> 00:04:30.960 +for creating dynamic, literate documents that + +00:04:30.960 --> 00:04:34.619 +can change based on parameters and constants embedded + +00:04:34.620 --> 00:04:38.439 +into the non-exported regions of the document. + +00:04:38.440 --> 00:04:41.800 +I'll show how with a single org-mode source document, + +00:04:41.800 --> 00:04:44.800 +you can press a couple of keys to configure + +00:04:44.800 --> 00:04:48.720 +it to export a RedHat-specific version of my building + +00:04:48.720 --> 00:04:53.479 +Emacs from source essay or a Debian-specific version. + +NOTE Getting started + +00:04:53.480 --> 00:04:55.320 +All right, let's get started. + +00:04:55.320 --> 00:04:58.720 +We'll begin by firing up a new terminal Emacs session + +00:04:58.720 --> 00:05:00.639 +on my Ubuntu machine. + +00:05:00.640 --> 00:05:04.600 +Now, I installed Emacs on this machine using apt-get. + +00:05:04.600 --> 00:05:07.960 +And doing that, you get version 27.1, + +00:05:07.960 --> 00:05:10.640 +which is, hey, only two major versions + +00:05:10.640 --> 00:05:13.010 +behind the current version of Emacs. + +00:05:13.011 --> 00:05:15.000 +This is another reason why I thought + +00:05:15.000 --> 00:05:18.080 +writing a guide on how to build Emacs from source code + +00:05:18.080 --> 00:05:19.719 +might be a good idea. + +00:05:19.720 --> 00:05:22.720 +You can get a much newer version of Emacs on Ubuntu + +00:05:22.720 --> 00:05:25.800 +if you install it via Snap, but, uh, Snaps. + +00:05:25.800 --> 00:05:28.239 +Don't get me started. + +00:05:28.240 --> 00:05:30.921 +Now, I wanted to use a completely vanilla + +00:05:30.922 --> 00:05:34.619 +terminal mode install of Emacs for this demonstration + +00:05:34.620 --> 00:05:38.040 +because my personal Emacs config has a ton of packages + +00:05:38.040 --> 00:05:41.199 +installed and is heavily modified. + +00:05:41.200 --> 00:05:43.640 +I want folks to be able to follow along + +00:05:43.640 --> 00:05:47.579 +with a bog-standard, out-of-the-box Emacs config. + +00:05:47.580 --> 00:05:49.520 +The Emacs config on this Ubuntu machine + +00:05:49.520 --> 00:05:51.200 +has just two settings. + +00:05:51.200 --> 00:05:55.240 +I require org-tempo because my fingers are hardwired + +00:05:55.240 --> 00:05:58.719 +to use some of the handy shortcuts that it provides. + +00:05:58.720 --> 00:06:00.520 +And I also turn off the menu bar + +00:06:00.520 --> 00:06:03.139 +because I just can't stand to look at it. + +00:06:03.140 --> 00:06:07.040 +Let's begin by opening a file called buildemacs.org, + +00:06:07.040 --> 00:06:08.480 +which will be the source code + +00:06:08.480 --> 00:06:11.079 +for our literate org-mode document. + +00:06:11.080 --> 00:06:12.840 +Now, in preparation for this talk, + +00:06:12.840 --> 00:06:14.960 +I've already written this document, + +00:06:14.960 --> 00:06:17.979 +and we'll take a look at the finished product + +00:06:17.980 --> 00:06:19.160 +here in a bit, but let's first take a look + +00:06:19.160 --> 00:06:22.408 +at how we might approach this task. + +00:06:22.409 --> 00:06:24.400 +We'll start at the top of the document + +00:06:24.400 --> 00:06:27.119 +by filling out some export keywords. + +00:06:27.120 --> 00:06:30.520 +These keywords are something that every backend exporter, + +00:06:30.520 --> 00:06:35.000 +be it LaTeX or plain text or ODT or whatever, understands, + +00:06:35.000 --> 00:06:38.120 +and they're essentially document metadata. + +00:06:38.120 --> 00:06:42.120 +As you can see, I'm typing `#+` + +00:06:42.120 --> 00:06:43.760 +followed by a couple characters + +00:06:43.760 --> 00:06:45.880 +and then `M-TAB` to auto-complete. + +00:06:45.880 --> 00:06:50.360 +If you hit #+ by itself and then M-TAB, + +00:06:50.360 --> 00:06:53.119 +you can see all the possible completions. + +00:06:53.120 --> 00:06:55.779 +And as you can see, there's a lot. + +NOTE README + +00:06:55.780 --> 00:06:58.520 +The next thing we're gonna do is make a README section + +00:06:58.520 --> 00:06:59.760 +at the top of this document. + +00:06:59.760 --> 00:07:02.240 +This section is intended for folks + +00:07:02.240 --> 00:07:04.280 +who are looking at the org-mode document, + +00:07:04.280 --> 00:07:06.679 +trying to figure out what it's for. + +00:07:06.680 --> 00:07:09.600 +We don't want to actually export the section heading, + +00:07:09.600 --> 00:07:13.859 +so we're gonna tag it with the :noexport: tag. + +00:07:13.860 --> 00:07:15.640 +And then here, we just write something quick + +00:07:15.640 --> 00:07:17.760 +to let folks know that this document + +00:07:17.760 --> 00:07:19.800 +can potentially execute code + +00:07:19.800 --> 00:07:23.499 +and just a little something about what the document is for. + +NOTE Writing a code block + +00:07:23.500 --> 00:07:26.059 +Okay, so now that we've written some text, + +00:07:26.060 --> 00:07:29.599 +let's try our hand at writing a code block. + +00:07:29.600 --> 00:07:31.288 +I'm getting pretty sick of looking at + +00:07:31.289 --> 00:07:32.939 +the default Emacs theme. + +00:07:32.940 --> 00:07:35.440 +All that blue and purple in the document + +00:07:35.440 --> 00:07:37.879 +makes it look bruised. + +00:07:37.880 --> 00:07:40.320 +Let's make an Emacs Lisp code block + +00:07:40.320 --> 00:07:41.400 +that switches the theme + +00:07:41.400 --> 00:07:44.560 +to one of my favorite built-in themes, Leuven. + +00:07:44.560 --> 00:07:48.400 +Leuven was created by my man, Fabrice Niessen, + +00:07:48.400 --> 00:07:52.120 +who I personally have learned a ton of org-mode stuff about + +00:07:52.120 --> 00:07:54.039 +just by studying his work. + +00:07:54.040 --> 00:07:56.360 +Now, if we cruise back up to the code block, + +00:07:56.360 --> 00:07:58.840 +we should be able to hit `C-c C-c`, + +00:07:58.840 --> 00:08:00.379 +and have it execute. + +00:08:00.380 --> 00:08:03.880 +And there you have it, a high-contrast color theme + +00:08:03.880 --> 00:08:06.979 +that was designed to look great in org-mode. + +00:08:06.980 --> 00:08:08.080 +So that's great and all, + +00:08:08.080 --> 00:08:10.459 +but there are a couple of things I don't like. + +NOTE :results none + +00:08:10.460 --> 00:08:13.599 +First of all, we don't need to see a #+RESULTS block here, + +00:08:13.600 --> 00:08:15.280 +and that's because we're not really interested + +00:08:15.280 --> 00:08:18.720 +in what the Emacs Lisp function `load-theme` returns. + +00:08:18.720 --> 00:08:22.200 +I mean, it's great it returned t and all to indicate success, + +00:08:22.200 --> 00:08:23.720 +we just don't need to see it. + +00:08:23.720 --> 00:08:26.560 +We can slap a `:results none` header arg + +00:08:26.560 --> 00:08:30.039 +on the code block to keep things nice and clean. + +00:08:30.040 --> 00:08:32.560 +There are a lot of different header args, + +00:08:32.560 --> 00:08:35.360 +and I often confuse and misremember them. + +00:08:35.360 --> 00:08:38.920 +So I'll always refer back to the org-mode manual + +00:08:38.920 --> 00:08:40.319 +when working with them. + +NOTE Confirmation + +00:08:40.320 --> 00:08:42.160 +The second thing I don't like is that + +00:08:42.160 --> 00:08:45.999 +when we hit C-c C-c to execute the block, + +00:08:46.000 --> 00:08:49.600 +Emacs prompted us if we really wanted to run the block. + +00:08:49.600 --> 00:08:52.040 +Emacs Lisp is Emacs' mother tongue, + +00:08:52.040 --> 00:08:53.920 +and I don't wanna be hassled when speaking + +00:08:53.920 --> 00:08:55.379 +my native language. + +00:08:55.380 --> 00:08:57.520 +There's a variable that controls this + +00:08:57.520 --> 00:09:00.680 +called `org-confirm-babel-evaluate`. + +00:09:00.680 --> 00:09:03.960 +And this can be either set to t or nil + +00:09:03.960 --> 00:09:06.840 +to either always confirm or never confirm. + +00:09:06.840 --> 00:09:10.920 +If however, you provided a lambda, an anonymous function, + +00:09:10.920 --> 00:09:14.560 +Org will call your function with the name of the language + +00:09:14.560 --> 00:09:16.840 +and the source block that it's about to run. + +00:09:16.840 --> 00:09:19.080 +And your function can make the decision + +00:09:19.080 --> 00:09:24.200 +about if Emacs should ask you for confirmation or not. + +00:09:24.200 --> 00:09:27.840 +What I'm doing here is setting `org-confirm-babel-evaluate` + +00:09:27.840 --> 00:09:30.539 +as a "file local variable". + +00:09:30.540 --> 00:09:33.320 +This means whenever the file is opened by Emacs, + +00:09:33.320 --> 00:09:38.059 +it'll set this variable to be a lambda that returns nil, + +00:09:38.060 --> 00:09:42.859 +meaning don't confirm, on Elisp code blocks. + +00:09:42.860 --> 00:09:45.920 +As you can see, the variable is currently set + +00:09:45.920 --> 00:09:50.879 +to its default value of t, meaning always confirm. + +00:09:50.880 --> 00:09:53.640 +Now if we save the buffer, exit Emacs, + +00:09:53.640 --> 00:09:55.040 +and pop back in again, + +00:09:55.040 --> 00:10:00.120 +`org-confirm-babel-evaluate` should be set how we like it. + +00:10:00.120 --> 00:10:02.640 +We were however prompted for confirmation + +00:10:02.640 --> 00:10:04.400 +on setting the file-local variable, + +00:10:04.400 --> 00:10:06.280 +which controls if we're prompted + +00:10:06.280 --> 00:10:09.699 +for Elisp source code block evaluation. + +00:10:09.700 --> 00:10:12.679 +I feel like there's a Yo Dawg joke here somewhere. + +00:10:12.680 --> 00:10:15.240 +When we were prompted, we hit the exclamation mark, + +00:10:15.240 --> 00:10:18.400 +which automatically marks this variable as being safe. + +00:10:18.400 --> 00:10:21.520 +So you won't be bothered the next time you open this file. + +00:10:21.520 --> 00:10:26.760 +This variable is called `safe-local-variable-values` + +00:10:26.760 --> 00:10:29.560 +and if we pop over to our .emacs file, + +00:10:29.560 --> 00:10:32.520 +you can see that Emacs' customize tooling + +00:10:32.520 --> 00:10:36.959 +helpfully updated this variable in our config file for us. + +NOTE Running blocks automatically + +00:10:36.960 --> 00:10:38.120 +Now that's great and all, + +00:10:38.120 --> 00:10:42.120 +but I really don't like having to hit `C-c C-c` + +00:10:42.120 --> 00:10:45.160 +on that source block every time I open this document + +00:10:45.160 --> 00:10:47.739 +just to bring up the Leuven theme. + +00:10:47.740 --> 00:10:50.520 +Let's have this source block run automatically + +00:10:50.520 --> 00:10:53.179 +every time the document is opened. + +00:10:53.180 --> 00:10:54.999 +Now I know what you're thinking. + +00:10:55.000 --> 00:10:57.640 +Shouldn't you just put all of this configuration stuff + +00:10:57.640 --> 00:11:01.159 +in your .emacs file and keep it out of the document? + +00:11:01.160 --> 00:11:04.760 +Well, that's what I've done with my personal Emacs config, + +00:11:04.760 --> 00:11:08.160 +but we want this document to be able to be used by folks + +00:11:08.160 --> 00:11:11.040 +with a completely vanilla Emacs setup, + +00:11:11.040 --> 00:11:13.440 +or even a completely tricked out Emacs setup, + +00:11:13.440 --> 00:11:16.059 +so we can't assume anything. + +00:11:16.060 --> 00:11:19.800 +The idea is if the Emacs user who opens the document + +00:11:19.800 --> 00:11:22.400 +agrees to setting all of the variables + +00:11:22.400 --> 00:11:24.359 +and running all of the code within, + +00:11:24.360 --> 00:11:26.560 +they'll be able to export the document + +00:11:26.560 --> 00:11:28.840 +as well as run all of the code blocks inside of it + +00:11:28.840 --> 00:11:30.799 +just as we intended. + +00:11:30.800 --> 00:11:33.880 +And the differences in base Emacs configuration + +00:11:33.880 --> 00:11:35.979 +will be completely minimized. + +00:11:35.980 --> 00:11:39.080 +Now it's worth pointing out that the file-local variables + +00:11:39.080 --> 00:11:43.023 +we're setting here are local, in this case, buffer-local. + +00:11:43.024 --> 00:11:45.280 +The configuration we use in this document + +00:11:45.280 --> 00:11:48.280 +won't override someone's carefully constructed + +00:11:48.280 --> 00:11:49.499 +org-mode setup. + +00:11:49.500 --> 00:11:50.800 +The first thing we're gonna wanna do + +00:11:51.000 --> 00:11:53.080 +in order to make this block execute + +00:11:53.080 --> 00:11:55.988 +when the document is loaded is to give it a name. + +00:11:55.989 --> 00:11:58.800 +It's always a good idea to give every source block + +00:11:58.800 --> 00:12:01.337 +you create in your document a unique name, + +00:12:01.338 --> 00:12:03.400 +even if you don't refer to it elsewhere. + +00:12:03.700 --> 00:12:06.960 +I do this because when I'm debugging my documents, + +00:12:07.160 --> 00:12:10.019 +Emacs will prompt me about running a block. + +00:12:10.020 --> 00:12:12.960 +If the block has a name, Emacs mentions it, + +00:12:12.960 --> 00:12:15.960 +and I know there's a problem with the result caching + +00:12:15.960 --> 00:12:17.840 +or something with the "foo" block. + +00:12:17.840 --> 00:12:20.280 +But if the block doesn't have a name, + +00:12:20.280 --> 00:12:22.160 +it can be really hard to figure out + +00:12:22.160 --> 00:12:24.579 +which block Emacs is complaining about. + +00:12:24.580 --> 00:12:27.459 +So I always name my blocks. + +00:12:27.460 --> 00:12:30.360 +Now we're gonna add another file local variable, + +00:12:30.360 --> 00:12:32.115 +but this one is special. + +00:12:32.116 --> 00:12:34.360 +If your "variable" + +00:12:34.360 --> 00:12:36.320 +just happens to be named "eval", + +00:12:36.320 --> 00:12:38.760 +it means that Emacs should evaluate + +00:12:38.760 --> 00:12:40.800 +the Lisp expression that follows. + +00:12:40.800 --> 00:12:43.240 +Here we'll use the progn function + +00:12:43.240 --> 00:12:46.040 +to sequentially run two elisp functions + +00:12:46.040 --> 00:12:48.760 +and return the value of the last one executed. + +00:12:48.760 --> 00:12:53.320 +The first function is `org-babel-goto-named-source-block`, + +00:12:53.320 --> 00:12:55.440 +which jumps us to the startup block. + +00:12:55.440 --> 00:12:59.280 +The second one is `org-babel-execute-src-block`, + +00:12:59.280 --> 00:13:02.092 +which executes the current source block. + +00:13:02.093 --> 00:13:03.630 +That should get the job done. + +00:13:03.631 --> 00:13:05.840 +Now all we have to do is save the document, + +00:13:05.840 --> 00:13:08.199 +exit Emacs, jump back in, + +00:13:08.200 --> 00:13:10.280 +and once we've confirmed that we're willing + +00:13:10.280 --> 00:13:14.239 +to run the new "eval" line in our file local variables, + +00:13:14.240 --> 00:13:15.859 +we're good to go. + +00:13:15.860 --> 00:13:18.480 +Now if we want to add new configuration stuff + +00:13:18.480 --> 00:13:21.839 +to the document, we can just add it to the startup block + +00:13:21.840 --> 00:13:24.880 +and not have to muck about with confirmations + +00:13:24.880 --> 00:13:28.679 +or adding new file-local variables or whatever. + +00:13:28.680 --> 00:13:31.960 +And just like before, we'll let Emacs' customize system + +00:13:31.960 --> 00:13:34.939 +save this decision to our .emacs file. + +00:13:34.940 --> 00:13:37.760 +Now that all that business with confirmations, + +00:13:37.760 --> 00:13:40.080 +file-local variables, and the startup block + +00:13:40.080 --> 00:13:41.120 +are out of the way, + +00:13:41.120 --> 00:13:44.120 +we can get on with writing our introduction. + +00:13:44.120 --> 00:13:47.880 +We'll create a new top level headline called introduction + +00:13:47.880 --> 00:13:51.440 +and explain to the reader of the exported document + +00:13:51.440 --> 00:13:52.600 +what this is all about. + +NOTE Export options + +00:13:53.000 --> 00:13:55.640 +Now as you can see, we've actually hard-coded + +00:13:55.640 --> 00:13:58.280 +the name of the Linux distro in our prose. + +00:13:58.280 --> 00:14:00.880 +I promised you a single document that could be + +00:14:00.880 --> 00:14:03.720 +for either RedHat or Debian distros, + +00:14:03.720 --> 00:14:05.319 +so we can't have this. + +00:14:05.320 --> 00:14:08.840 +Astute members in the audience have probably been uneasy + +00:14:08.840 --> 00:14:11.280 +ever since I hard coded the name "Debian" + +00:14:11.280 --> 00:14:13.859 +in the README section above. + +00:14:13.860 --> 00:14:17.520 +One way of solving this problem is by using exclude tags. + +00:14:17.520 --> 00:14:21.960 +Let's add the `#+EXCLUDE_TAGS` export keyword to our document. + +00:14:21.960 --> 00:14:24.200 +This keyword tells the exporter, + +00:14:24.200 --> 00:14:27.959 +"Hey, if you see a headline tagged with any of these tags, + +00:14:27.960 --> 00:14:29.600 +don't export it." + +00:14:29.600 --> 00:14:33.559 +By default, the tag `:noexport:` is excluded. + +00:14:33.560 --> 00:14:36.480 +And if you'll notice, we tagged our README section + +00:14:36.480 --> 00:14:38.360 +with that tag, so it doesn't show up + +00:14:38.360 --> 00:14:40.339 +in the exported document. + +00:14:40.340 --> 00:14:42.280 +We'll keep this tag in the list, + +00:14:42.280 --> 00:14:47.080 +but we'll also add the tag `:redhat:` as a tag to exclude. + +00:14:47.080 --> 00:14:50.400 +Now it's just a matter of creating two introduction + +00:14:50.400 --> 00:14:53.960 +sections, one for Debian, one for RedHat. + +00:14:53.960 --> 00:14:56.520 +And if you want the RedHat version of the document, + +00:14:56.520 --> 00:14:59.200 +you can just modify the `#+EXCLUDE_TAGS` line + +00:14:59.200 --> 00:15:00.440 +at the top of the document. + +00:15:00.440 --> 00:15:02.339 +Awesome, right? + +00:15:02.340 --> 00:15:03.539 +Right? + +00:15:03.540 --> 00:15:05.544 +OK, this is not that great. + +00:15:05.545 --> 00:15:07.387 +Well, it does work. + +00:15:07.388 --> 00:15:10.081 +And you can see if we export the document, + +00:15:10.082 --> 00:15:12.840 +we'll get something that only references Debian, + +00:15:12.840 --> 00:15:15.188 +and the `:noexport:` and `:redhat:` + +00:15:15.189 --> 00:15:17.450 +tagged headlines are omitted. + +00:15:17.451 --> 00:15:19.319 +This strategy would work great + +00:15:19.320 --> 00:15:22.120 +when the RedHat- and Debian-specific sections + +00:15:22.120 --> 00:15:24.400 +are substantially different, but that's not + +00:15:24.400 --> 00:15:26.198 +the case with the introduction. + +00:15:26.199 --> 00:15:28.640 +We definitely don't want to have to maintain + +00:15:28.640 --> 00:15:30.824 +two distinct introductions. + +00:15:30.825 --> 00:15:34.080 +I also noticed that the export tags are included + +00:15:34.080 --> 00:15:36.519 +in the exported document. + +00:15:36.520 --> 00:15:38.720 +That's a terrible default. We'll fix that, + +00:15:38.720 --> 00:15:42.040 +and we'll also ensure that my email address appears + +00:15:42.040 --> 00:15:43.371 +at the top of the document. + +00:15:43.372 --> 00:15:45.440 +Let's also take this opportunity to get rid + +00:15:45.440 --> 00:15:47.354 +of the table of contents. + +00:15:47.355 --> 00:15:48.867 +We don't need it. + +00:15:48.868 --> 00:15:51.120 +These are all export option settings + +00:15:51.120 --> 00:15:53.800 +and can be modified using the options keyword + +00:15:53.800 --> 00:15:55.508 +at the top of the doc. + +00:15:55.509 --> 00:15:57.480 +The manual is really your friend here, + +00:15:57.480 --> 00:16:00.979 +as there are a ton of export options. + +00:16:00.980 --> 00:16:03.120 +Now when we export the document again, + +00:16:03.120 --> 00:16:05.699 +it should look a lot better. + +NOTE Substituting constants + +00:16:05.700 --> 00:16:09.059 +Now that we've cleaned up the look of the exported document, + +00:16:09.060 --> 00:16:10.640 +we'll take a look at a better way + +00:16:10.640 --> 00:16:13.377 +of solving the problem with the introduction. + +00:16:13.378 --> 00:16:15.518 +Thinking like a programmer for a moment, + +00:16:15.519 --> 00:16:19.734 +what I really want here is a way of specifying a constant. + +00:16:19.735 --> 00:16:22.640 +Rather than hard-coding the name "Debian" or "RedHat" + +00:16:22.640 --> 00:16:24.569 +or whatever into my document, + +00:16:24.570 --> 00:16:28.234 +I want to substitute that text with a symbolic constant, + +00:16:28.235 --> 00:16:31.960 +named something like "distro", that can dynamically change + +00:16:31.960 --> 00:16:36.120 +to "Debian" or "RedHat" or "Slackware" or whatever, + +00:16:36.120 --> 00:16:38.689 +depending on how the document is configured. + +00:16:38.690 --> 00:16:41.640 +In the past, I've come up with some pretty cumbersome ways + +00:16:41.640 --> 00:16:44.640 +of doing this, but eventually I stumbled upon the idea + +00:16:44.640 --> 00:16:46.639 +of using Org-mode properties + +00:16:46.640 --> 00:16:49.409 +as a way of storing these constants. + +00:16:49.410 --> 00:16:53.059 +Like it says in the docs, properties are key-value pairs + +00:16:53.060 --> 00:16:55.169 +that are associated with an entry + +00:16:55.170 --> 00:16:58.379 +and they live in a collapsible properties drawer. + +00:16:58.380 --> 00:17:00.699 +Let's do a bit of cleanup on our document + +00:17:00.700 --> 00:17:02.600 +and we'll put things into sections. + +00:17:02.600 --> 00:17:14.000 +We'll also add a section for document constants. + +00:17:14.000 --> 00:17:19.560 +And that's where we'll put the properties drawer + +00:17:19.560 --> 00:17:25.739 +with the "distro" property. + +NOTE Getting the properties + +00:17:25.740 --> 00:17:27.120 +Now the question is, + +00:17:27.120 --> 00:17:30.099 +how do we reference these properties in the document? + +00:17:30.100 --> 00:17:32.520 +It turns out there's an Elisp function + +00:17:32.520 --> 00:17:35.440 +called `org-property-values`, which does what we want. + +00:17:35.440 --> 00:17:38.840 +If we run it and give it the name of our property, + +00:17:38.840 --> 00:17:42.679 +it returns a list with the string "Debian" in it. + +00:17:42.680 --> 00:17:45.919 +It's worth noting that this function is named + +00:17:45.920 --> 00:17:49.989 +`org-property-values` with values being plural. + +00:17:49.990 --> 00:17:52.889 +In org-mode, there could be a property named "foo" + +00:17:52.890 --> 00:17:55.880 +that has different values depending on which heading level + +00:17:55.880 --> 00:17:57.609 +you're at in the document, + +00:17:57.610 --> 00:17:59.720 +which is why the function returns a list. + +00:17:59.720 --> 00:18:01.289 +For our purposes though, + +00:18:01.290 --> 00:18:04.480 +we can just pull off the first value in the list with car + +00:18:04.480 --> 00:18:05.680 +and we're good to go. + +00:18:05.680 --> 00:18:10.040 +Now we'll make an Emacs Lisp list function called `get_prop` + +00:18:10.040 --> 00:18:11.440 +that does just that. + +00:18:11.440 --> 00:18:14.160 +This function takes one argument called `prop`, + +00:18:14.160 --> 00:18:15.920 +which is the property to look up + +00:18:15.920 --> 00:18:18.519 +and we'll give it a default value of "distro". + +00:18:18.520 --> 00:18:20.960 +So we can hit `C-c C-c` on the block + +00:18:20.960 --> 00:18:23.149 +to verify that it works. + +00:18:23.150 --> 00:18:25.480 +Now we just have to make an inline call + +00:18:25.480 --> 00:18:26.920 +to our `get_prop` function + +00:18:26.920 --> 00:18:29.559 +within the prose of the introduction section. + +00:18:29.560 --> 00:18:31.659 +And that should get us much closer + +00:18:31.660 --> 00:18:35.619 +to not hard coding distro names into our document. + +00:18:35.620 --> 00:18:36.869 +But before we do that, + +00:18:36.870 --> 00:18:39.849 +I need to clean up something that's been bothering me. + +00:18:39.850 --> 00:18:42.909 +By default, Emacs' `fill-column` variable + +00:18:42.910 --> 00:18:44.989 +is set to 70 characters, + +00:18:44.990 --> 00:18:47.720 +which may have been appropriate for 1970, + +00:18:47.720 --> 00:18:51.319 +but it's not great for 2023. + +00:18:51.320 --> 00:18:53.920 +We'll just cruise up to our startup block + +00:18:53.920 --> 00:18:56.539 +and set the variable there. + +00:18:56.540 --> 00:18:58.800 +We'll hit `C-c C-c`, + +00:18:58.800 --> 00:19:02.289 +and now our document will wrap at 100 columns, + +00:19:02.290 --> 00:19:05.829 +which for our purposes, I think is much more reasonable. + +00:19:05.830 --> 00:19:09.320 +The org-mode syntax for making an inline function call + +00:19:09.320 --> 00:19:13.059 +within the prose of your document is `call_`, + +00:19:13.060 --> 00:19:15.000 +followed by the name of the function, + +00:19:15.000 --> 00:19:17.040 +some optional header arguments, + +00:19:17.040 --> 00:19:19.719 +and then the function arguments. + +00:19:19.720 --> 00:19:21.680 +Now, when we export the document, + +00:19:21.680 --> 00:19:26.049 +we see that it's replaced our previously hard coded "Debian" + +00:19:26.050 --> 00:19:29.409 +with the value from the property. Huzzah! + +00:19:29.410 --> 00:19:32.959 +Now this is close to, but not exactly what we want. + +00:19:32.960 --> 00:19:36.720 +You can see that "Debian" is surrounded by a backtick + +00:19:36.720 --> 00:19:37.800 +and a single quote, + +00:19:37.800 --> 00:19:40.320 +which is the plain text exporters way + +00:19:40.320 --> 00:19:43.029 +of showing you verbatim text. + +00:19:43.030 --> 00:19:45.600 +In more sophisticated document backends, + +00:19:45.600 --> 00:19:49.379 +verbatim text is rendered in monospace. + +00:19:49.380 --> 00:19:54.080 +We can fix that by adding a ":results raw" header argument + +00:19:54.080 --> 00:19:56.459 +to the inline call. + +00:19:56.460 --> 00:19:58.239 +Now, when we export the document, + +00:19:58.240 --> 00:20:00.289 +it looks like what we'd expect. + +00:20:00.290 --> 00:20:02.960 +Now this is getting better, but it's still not great. + +NOTE Macros + +00:20:03.060 --> 00:20:05.840 +The `call_` syntax is pretty cumbersome, + +00:20:05.840 --> 00:20:08.560 +and it's a lot to type every time we want + +00:20:08.560 --> 00:20:09.849 +to reference a constant + +00:20:09.850 --> 00:20:13.219 +and not have it be marked up as verbatim. + +00:20:13.220 --> 00:20:17.169 +This is where org-mode macros come to our rescue. + +00:20:17.170 --> 00:20:19.469 +If we head to the top of the document, + +00:20:19.470 --> 00:20:21.480 +we can create a couple of macros + +00:20:21.480 --> 00:20:24.699 +using the `#+MACRO:` export keyword. + +00:20:24.700 --> 00:20:27.600 +We'll define two macros with short names. + +00:20:27.600 --> 00:20:30.240 +One named "p" for "property", + +00:20:30.240 --> 00:20:34.640 +and the other one named "pr" for "property raw". + +00:20:34.640 --> 00:20:39.160 +Org-mode macros are expanded when the document is exported, + +00:20:39.160 --> 00:20:41.640 +and any positional arguments provided + +00:20:41.640 --> 00:20:43.559 +are referenced by their number. + +00:20:43.860 --> 00:20:45.160 +Now in the introduction, + +00:20:45.160 --> 00:20:47.880 +we can use the macro replacement syntax, + +00:20:47.880 --> 00:20:49.800 +which is three curly braces, + +00:20:49.800 --> 00:20:52.760 +followed by the macro name and any arguments, + +00:20:52.760 --> 00:20:55.559 +and then three ending curly braces. + +00:20:55.560 --> 00:20:58.699 +You see why I kept the macro name short. + +00:20:58.700 --> 00:21:01.280 +That's six curly braces in total we're typing, + +00:21:01.280 --> 00:21:05.239 +which still takes up a fair amount of space. + +NOTE Properties in practice + +00:21:05.240 --> 00:21:07.120 +Now let's take a look at how we might use + +00:21:07.120 --> 00:21:09.159 +these properties in practice. + +00:21:09.160 --> 00:21:10.920 +Debian and RedHat distros differ + +00:21:11.120 --> 00:21:12.929 +on how they install packages. + +00:21:12.930 --> 00:21:16.120 +So we're gonna want an "install" property, + +00:21:16.120 --> 00:21:24.579 +where in Debian we use `sudo apt-get install -qq`, + +00:21:24.580 --> 00:21:26.939 +and on RedHat we'll use something like + +00:21:26.940 --> 00:21:33.119 +`sudo dnf install -y`. + +00:21:33.120 --> 00:21:35.329 +Now development packages + +00:21:35.330 --> 00:21:38.049 +also have a different naming convention. + +00:21:38.050 --> 00:21:40.760 +For example, the `ncurses` library on Debian + +00:21:40.760 --> 00:21:43.520 +is called `libncurses-dev`, + +00:21:43.520 --> 00:21:48.259 +where on RedHat it's called `ncurses-devel`. + +00:21:48.260 --> 00:21:49.640 +There are likely going to be + +00:21:49.640 --> 00:21:52.120 +many more little differences like this + +00:21:52.120 --> 00:21:55.339 +that we'll need to solve with properties. + +00:21:55.340 --> 00:21:58.609 +Now I already don't like where this is going. + +00:21:58.610 --> 00:22:00.880 +Switching between the Debian and RedHat + +00:22:00.880 --> 00:22:03.160 +versions of the document is gonna mean + +00:22:03.160 --> 00:22:05.200 +commenting and uncommenting out + +00:22:05.200 --> 00:22:06.989 +a bunch of different properties, + +00:22:06.990 --> 00:22:09.019 +which is pretty janky. + +NOTE Using a prefix + +00:22:09.020 --> 00:22:11.079 +Luckily we can solve this problem + +00:22:11.080 --> 00:22:14.439 +with a little bit of Emacs Lisp. + +00:22:14.440 --> 00:22:16.879 +We'll start by modifying our properties, + +00:22:16.880 --> 00:22:19.140 +so their property names are prefixed + +00:22:19.141 --> 00:22:23.119 +with either `deb_` or `rh_` + +00:22:23.120 --> 00:22:27.719 +to signify which distro the property applies to.` + +00:22:27.720 --> 00:22:31.160 +We'll also create a single property called "prefix", + +00:22:31.160 --> 00:22:34.589 +which will be prepended to the property name + +00:22:34.590 --> 00:22:36.529 +by the `get_prop` function + +00:22:36.530 --> 00:22:39.509 +if the requested property is not found. + +00:22:39.510 --> 00:22:42.200 +This way, when we want to switch between + +00:22:42.200 --> 00:22:45.349 +the Debian and RedHat versions of the document, + +00:22:45.350 --> 00:22:49.029 +we just need to change the prefix property. + +00:22:49.030 --> 00:22:51.379 +So now we'll change the Elisp code. + +00:22:51.380 --> 00:22:55.209 +So we'll use a let expression with two bound variables. + +00:22:55.210 --> 00:22:56.919 +The first one is called ret, + +00:22:56.920 --> 00:22:59.160 +which determines if the initial call + +00:22:59.160 --> 00:23:01.949 +to `org-property-values` succeeds. + +00:23:01.950 --> 00:23:04.039 +The second variable is called prefix, + +00:23:04.040 --> 00:23:06.219 +which is the prefix property. + +00:23:06.220 --> 00:23:09.120 +If the first call to `org-property-values` succeeds, + +00:23:09.120 --> 00:23:11.159 +we return it as normal. + +00:23:11.160 --> 00:23:14.249 +If not, we concatenate the property value + +00:23:14.250 --> 00:23:15.920 +that was passed into the function + +00:23:15.920 --> 00:23:18.969 +onto the prefix and try again. + +00:23:18.970 --> 00:23:23.800 +Now when we call the `get_prop` function with "distro" + +00:23:23.800 --> 00:23:26.360 +as the prop argument, it won't be found. + +00:23:26.360 --> 00:23:29.689 +So the code will slap our prefix tag on the front, + +00:23:29.690 --> 00:23:33.249 +making it something like `rh_distro`, + +00:23:33.250 --> 00:23:35.329 +and it will be found and returned. + +00:23:35.330 --> 00:23:39.999 +Let's see that in action. + +00:23:40.000 --> 00:23:42.009 +All right, now we're talking. + +NOTE Switching distributions + +00:23:42.010 --> 00:23:44.419 +This setup is starting to look pretty good, + +00:23:44.420 --> 00:23:46.040 +but there are just a few things + +00:23:46.040 --> 00:23:48.659 +that I want to add before we move on. + +00:23:48.660 --> 00:23:51.240 +First of all, I think the document should have a subtitle, + +00:23:51.240 --> 00:23:53.960 +something that tells you if you're looking at the RedHat + +00:23:53.960 --> 00:23:56.160 +or the Debian version of the document. + +00:23:56.160 --> 00:23:57.880 +I also think it would be great + +00:23:57.880 --> 00:24:00.520 +if the file name of the exported document + +00:24:00.520 --> 00:24:04.999 +reflected the distribution as well. + +00:24:05.000 --> 00:24:08.040 +I also want to add a quick Debian only section + +00:24:08.040 --> 00:24:11.799 +to the document that explains how it got its name. + +00:24:11.800 --> 00:24:17.739 +Now let's see what happens when we export the document. + +00:24:17.740 --> 00:24:20.439 +This did not work out as we wanted. + +00:24:20.440 --> 00:24:23.360 +As you can see, the macro we used in the subtitles + +00:24:23.360 --> 00:24:24.959 +didn't expand properly, + +00:24:24.960 --> 00:24:28.640 +and as a result, our subtitle didn't render right. + +00:24:28.640 --> 00:24:30.640 +Sadly, you can't use macros + +00:24:30.640 --> 00:24:32.909 +or inline function calls everywhere. + +00:24:32.910 --> 00:24:34.680 +And one place where they don't work + +00:24:34.680 --> 00:24:37.189 +is inside of certain export keywords. + +00:24:37.190 --> 00:24:43.219 +So we're gonna have to hard code them here. + +00:24:43.220 --> 00:24:46.320 +Another mistake that we made is we forgot to update + +00:24:46.320 --> 00:24:49.099 +the `#+EXCLUDE_TAGS` export keyword, + +00:24:49.100 --> 00:24:51.439 +because with the RedHat version of the document, + +00:24:51.440 --> 00:24:54.509 +we want to exclude the Debian tag. + +00:24:54.510 --> 00:24:56.400 +Now when we export the document, + +00:24:56.400 --> 00:24:57.839 +everything should be correct. + +00:24:57.840 --> 00:25:00.619 +The word RedHat should appear in the subtitle, + +00:25:00.620 --> 00:25:04.799 +and the Debian fun fact section should not be present. + +00:25:04.800 --> 00:25:06.960 +Now we just need to add a section to the README + +00:25:06.960 --> 00:25:09.280 +that explains the steps you need to take + +00:25:09.280 --> 00:25:11.000 +in order to switch the document + +00:25:11.000 --> 00:25:12.759 +from RedHat to Debian. + +00:25:12.760 --> 00:25:14.000 +Okay, let's see here. + +00:25:14.000 --> 00:25:18.309 +We have to change `#+SUBTITLE`, change the `#+EXCLUDE_TAGS`, + +00:25:18.310 --> 00:25:20.429 +change the `#+EXPORT_FILE_NAME`, + +00:25:20.430 --> 00:25:23.289 +and change the `prefix` property. + +00:25:23.290 --> 00:25:26.289 +This is OK, but it's not great. + +00:25:26.290 --> 00:25:29.429 +Emacs Lisp can once again come to our rescue. + +00:25:29.430 --> 00:25:32.080 +What we'll do is make an Elisp code block + +00:25:32.080 --> 00:25:35.480 +that will invite the user to hit `C-c C-c` on. + +00:25:35.480 --> 00:25:39.520 +And the code block will essentially make all these changes + +00:25:39.520 --> 00:25:40.919 +in the document for them. + +00:25:40.920 --> 00:25:43.280 +This code block, which we'll call `switch_distro`, + +00:25:43.280 --> 00:25:45.680 +takes one argument called `os`, + +00:25:45.680 --> 00:25:48.689 +which by default is set to "Debian". + +00:25:48.690 --> 00:25:50.760 +It starts out with a let expression + +00:25:50.760 --> 00:25:53.029 +that defines three bound variables. + +00:25:53.030 --> 00:25:55.969 +The `debian` variable is a boolean that is true + +00:25:55.970 --> 00:25:58.699 +if the distro we're switching to is Debian. + +00:25:58.700 --> 00:26:00.360 +Based on the value of this boolean, + +00:26:00.360 --> 00:26:04.169 +we'll set the `noexport` and `prefix` variables accordingly. + +00:26:04.170 --> 00:26:06.720 +The `save-excursion` block tells Emacs + +00:26:06.720 --> 00:26:09.199 +that we're going to be moving around in the document + +00:26:09.200 --> 00:26:11.680 +and to remember to put our point back where we started + +00:26:11.680 --> 00:26:13.429 +when the block finishes. + +00:26:13.430 --> 00:26:16.249 +After that, we essentially go to the top of the document + +00:26:16.250 --> 00:26:19.839 +and search and replace the subtitle, `exclude_tags`, + +00:26:19.840 --> 00:26:22.499 +`export_file_name`, and the `prefix`. + +00:26:22.500 --> 00:26:23.389 +Pretty cool. + +00:26:23.390 --> 00:26:25.029 +Let's see this in action. + +00:26:25.030 --> 00:26:27.869 +If we hit `C-c C-c` on this block, + +00:26:27.870 --> 00:26:30.480 +we should see the document automatically change a bit. + +00:26:30.480 --> 00:26:32.320 +And now when we export it, + +00:26:32.320 --> 00:26:36.089 +we get the Debian version of the doc. + +00:26:36.090 --> 00:26:37.629 +If we want to change it back, + +00:26:37.630 --> 00:26:39.880 +we can just head back over to the code block + +00:26:39.880 --> 00:26:43.149 +and change the default value for the os variable + +00:26:43.150 --> 00:26:47.619 +from "Debian" to "RedHat" and hit `C-c C-c` again. + +00:26:47.620 --> 00:26:49.919 +And now when we re-export, + +00:26:49.920 --> 00:26:52.909 +we're looking at the RedHat version of the document. + +00:26:52.910 --> 00:26:55.859 +Just as an aside, if you ever thought to yourself, + +00:26:55.860 --> 00:26:58.159 +"I should learn Emacs Lisp someday" + +00:26:58.160 --> 00:27:01.289 +Make it someday soon. You'll be happy you did. + +00:27:01.290 --> 00:27:03.769 +Not only is it a fun programming language, + +00:27:03.770 --> 00:27:06.679 +but you can do powerful things with it in Emacs, + +00:27:06.680 --> 00:27:12.149 +which I hope is a point that folks take away from this talk. + +00:27:12.150 --> 00:27:14.149 +All right, that was a lot. + +NOTE A tour + +00:27:14.150 --> 00:27:16.840 +Now that we've spent the past 20 minutes or so + +00:27:16.840 --> 00:27:19.409 +digging into some of the tips and tricks I used + +00:27:19.410 --> 00:27:22.879 +when creating my build Emacs from source document, + +00:27:22.880 --> 00:27:26.279 +we'll say goodbye to this document we've been working on + +00:27:26.280 --> 00:27:27.480 +and we'll start a tour + +00:27:27.480 --> 00:27:29.960 +of the actual literate document I wrote. + +00:27:29.960 --> 00:27:33.080 +A document that I'll demonstrate actually downloading + +00:27:33.080 --> 00:27:35.659 +and building a new Emacs when I export it + +00:27:35.660 --> 00:27:38.959 +on both my Ubuntu and RedHat virtual machines. + +00:27:38.960 --> 00:27:41.689 +I'll also show you how org-mode can generate + +00:27:41.690 --> 00:27:44.519 +slick professional looking PDF files + +00:27:44.520 --> 00:27:46.579 +through the power of LaTeX. + +00:27:46.580 --> 00:27:49.619 +We'll start here at the orgdemo2 directory, + +00:27:49.620 --> 00:27:51.229 +which I've cloned from GitLab. + +00:27:51.230 --> 00:27:55.599 +This repository has all the source materials for this talk. + +00:27:55.600 --> 00:27:59.040 +The buildemacs.org file is where most of the good stuff is. + +00:27:59.040 --> 00:28:01.479 +So that's where we'll start. + +00:28:01.480 --> 00:28:03.360 +There's a lot of file-local variables + +00:28:03.360 --> 00:28:04.800 +that we'll need to confirm. + +00:28:04.800 --> 00:28:06.439 +So we'll do that too. + +00:28:06.440 --> 00:28:07.560 +So the first thing we're gonna do + +00:28:07.560 --> 00:28:10.080 +is hit `C-u TAB` twice, + +00:28:10.780 --> 00:28:13.360 +which will give us a top-level overview + +00:28:13.360 --> 00:28:15.139 +of all of our headings. + +00:28:15.140 --> 00:28:16.600 +As you can see, we've got a lot + +00:28:16.600 --> 00:28:20.119 +of the same familiar export keywords we had before. + +00:28:20.120 --> 00:28:23.099 +`#+TITLE`, `#+SUBTITLE`, `#+AUTHOR`, `#+EMAIL`, + +00:28:23.100 --> 00:28:25.359 +plus a few we haven't seen before. + +00:28:25.360 --> 00:28:27.720 +For example, I've squirreled away + +00:28:27.720 --> 00:28:30.619 +a lot of the `#+LATEX_HEADER` export keywords + +00:28:30.620 --> 00:28:33.539 +in this file called latex.setup. + +00:28:33.540 --> 00:28:36.539 +And I did this just so they don't clutter up the document. + +00:28:36.540 --> 00:28:38.320 +Much of the LaTeX magic + +00:28:38.320 --> 00:28:40.909 +that makes the exported document look good + +00:28:40.910 --> 00:28:42.589 +is in these headers. + +00:28:42.590 --> 00:28:45.119 +LaTeX commands begin with a backslash. + +00:28:45.120 --> 00:28:49.679 +And a common one we use a lot here is `\usepackage`. + +00:28:49.680 --> 00:28:52.200 +This lets us bring in packages like geometry, + +00:28:52.200 --> 00:28:56.539 +svg for the cool SeaGL SVG logo, + +00:28:56.540 --> 00:28:58.440 +`fancyhdr` and fancy verbatim [`fancyvrb`] + +00:28:58.440 --> 00:29:00.689 +to keep things looking pretty fancy. + +00:29:00.690 --> 00:29:03.200 +Using a scalable vector image format + +00:29:03.200 --> 00:29:05.720 +makes it possible for us to do really cool things + +00:29:05.720 --> 00:29:09.269 +like having a scaled-down version of the SeaGL logo + +00:29:09.270 --> 00:29:11.979 +appear in the fancy footer below. + +00:29:11.980 --> 00:29:15.360 +I also include some macros in a separate file + +00:29:15.360 --> 00:29:18.120 +just to help keep things tidy in the main document. + +00:29:18.120 --> 00:29:20.600 +Here I've got the familiar macros + +00:29:20.600 --> 00:29:23.399 +we've seen before for `get_prop`. + +00:29:23.400 --> 00:29:25.520 +But here I use different permutations + +00:29:25.520 --> 00:29:28.160 +depending on if I want results raw + +00:29:28.160 --> 00:29:31.869 +or raw verbatim or just verbatim. + +00:29:31.870 --> 00:29:35.069 +I also have a couple of macros here at the top of the file + +00:29:35.070 --> 00:29:40.280 +that are for pulling strings out of results blocks + +00:29:40.280 --> 00:29:41.920 +and then trimming them + +00:29:41.920 --> 00:29:44.719 +so there's no white space on either side. + +00:29:44.720 --> 00:29:46.440 +Like in the version of the document + +00:29:46.440 --> 00:29:48.429 +we worked on at the start of this talk, + +00:29:48.430 --> 00:29:51.079 +the real document also has a README section + +00:29:51.080 --> 00:29:53.469 +marked with the `:noexport:` tag. + +00:29:53.470 --> 00:29:55.400 +It also has a section about choosing + +00:29:55.400 --> 00:29:57.909 +which version of the document to export + +00:29:57.910 --> 00:30:00.599 +and a code block on how to switch between them. + +00:30:00.600 --> 00:30:03.000 +It's also got a lot of helpful information in it + +00:30:03.000 --> 00:30:05.819 +like what OS and Emacs versions + +00:30:05.820 --> 00:30:09.559 +the document has been tested to "run" on, + +00:30:09.560 --> 00:30:12.329 +a section on the LaTeX prerequisites + +00:30:12.330 --> 00:30:14.080 +and the section on executing + +00:30:14.080 --> 00:30:16.199 +the document's various code blocks. + +NOTE TeX and LaTeX + +00:30:16.200 --> 00:30:19.199 +The latter two sections we'll take a look at now. + +00:30:19.200 --> 00:30:22.579 +Out of the box on Fedora and Ubuntu server distros, + +00:30:22.580 --> 00:30:24.709 +the TeX typesetting system + +00:30:24.710 --> 00:30:27.669 +also by noted computer scientist Donald Knuth + +00:30:27.670 --> 00:30:28.859 +is not installed. + +00:30:28.860 --> 00:30:31.719 +So we'll need to install some packages. + +00:30:31.720 --> 00:30:34.449 +Starting out we'll need the `texlive` package + +00:30:34.450 --> 00:30:37.459 +which gets you a fully featured TeX setup. + +00:30:37.460 --> 00:30:39.289 +This also gets you LaTeX + +00:30:39.290 --> 00:30:42.789 +which can be viewed as a distribution of TeX macros. + +00:30:42.790 --> 00:30:44.899 +You'll also need XeTeX. + +00:30:44.900 --> 00:30:49.779 +This gets you Unicode support and lets you use modern fonts. + +00:30:49.780 --> 00:30:52.809 +We'll also want to install pdfTeX. + +00:30:52.810 --> 00:30:57.209 +This gets us the ability to generate PDFs from TeX sources. + +00:30:57.210 --> 00:31:01.299 +And finally, we're gonna need to install latexmk + +00:31:01.300 --> 00:31:02.400 +which is a Perl script + +00:31:02.400 --> 00:31:05.139 +that knows how to run LaTeX multiple times + +00:31:05.140 --> 00:31:09.249 +in order to properly deal with intra-document links. + +NOTE Other prerequisites + +00:31:09.250 --> 00:31:11.069 +But wait, there's more. + +00:31:11.070 --> 00:31:12.960 +We're also gonna need Inkscape + +00:31:12.960 --> 00:31:15.520 +to rasterize our SeaGL vector logo + +00:31:15.520 --> 00:31:17.339 +at different resolutions. + +00:31:17.340 --> 00:31:20.360 +And we're gonna need the JetBrains Mono font + +00:31:20.360 --> 00:31:23.059 +to make our source code look snazzy. + +00:31:23.060 --> 00:31:24.680 +We'll also need the Inter font + +00:31:24.680 --> 00:31:28.039 +to make our prose look snazzy as well. + +00:31:28.040 --> 00:31:31.299 +I've helpfully added a bash code block in the README + +00:31:31.300 --> 00:31:35.739 +that you can hit C-c C-c on to install. + +00:31:35.740 --> 00:31:38.520 +This really does lock up Emacs for a few minutes + +00:31:38.520 --> 00:31:40.329 +and it's sort of annoying. + +00:31:40.330 --> 00:31:43.040 +When we export the document and turn off all caching + +00:31:43.040 --> 00:31:45.599 +and it actually builds Emacs for real, + +00:31:45.600 --> 00:31:48.769 +Emacs can be locked up for tens of minutes. + +00:31:48.770 --> 00:31:50.880 +There's a package called ob-async + +00:31:50.880 --> 00:31:54.259 +that I've been meaning to check out that might help here. + +00:31:54.260 --> 00:31:55.760 +But since I wanted this document + +00:31:55.760 --> 00:31:58.000 +to work on bog-standard Emacs setups, + +00:31:58.000 --> 00:32:00.059 +I didn't get around to it. + +NOTE Caching + +00:32:00.060 --> 00:32:03.139 +Before we get into talking about running the document, + +00:32:03.140 --> 00:32:06.449 +let's talk briefly about results caching. + +00:32:06.450 --> 00:32:08.839 +We'll take a look at the section of the document + +00:32:08.840 --> 00:32:13.139 +where we talk about Git tags for an example. + +00:32:13.140 --> 00:32:15.760 +The `num_tags` bash code block determines + +00:32:15.760 --> 00:32:19.039 +how many tags there are in the Emacs Git repo. + +00:32:19.040 --> 00:32:21.600 +And when I hit C-c C-c on that block + +00:32:21.600 --> 00:32:25.059 +several days ago, when I was first creating the document, + +00:32:25.060 --> 00:32:28.019 +that number was 183. + +00:32:28.020 --> 00:32:32.169 +That result has remained cached in the document since then. + +00:32:32.170 --> 00:32:34.899 +And you can see a snippet of the SHA1 hash + +00:32:34.900 --> 00:32:38.389 +of the contents of the source block below. + +00:32:38.390 --> 00:32:40.800 +You can see where I referenced the result + +00:32:40.800 --> 00:32:44.960 +using the `sr` for string raw macro in the prose below, + +00:32:44.960 --> 00:32:50.509 +and how it gets rendered in the exported PDF document. + +00:32:50.510 --> 00:32:52.880 +All the source blocks in the exported sections + +00:32:52.880 --> 00:32:56.559 +of the document include cached results like this. + +00:32:56.560 --> 00:33:01.389 +If I export the document now, it won't take that long to do + +00:33:01.390 --> 00:33:03.800 +because while there are a ton of code blocks + +00:33:03.800 --> 00:33:09.069 +in the exported sections, they're all cached. + +00:33:09.070 --> 00:33:11.560 +Now let's get back to the section of the README + +00:33:11.560 --> 00:33:14.909 +that explains how to execute the code in the document. + +00:33:14.910 --> 00:33:17.640 +Here I explain that if you want to build Emacs + +00:33:17.640 --> 00:33:20.189 +on your computer using this document, + +00:33:20.190 --> 00:33:22.019 +you've got a couple of options. + +00:33:22.020 --> 00:33:25.649 +The first option is to manually invalidate the caches + +00:33:25.650 --> 00:33:28.960 +and take C-c C-c on every code block + +00:33:28.960 --> 00:33:30.959 +in the main document. + +00:33:30.960 --> 00:33:33.160 +This lets you supervise the entire process, + +00:33:33.160 --> 00:33:36.939 +and it also creates new cached result blocks, + +00:33:36.940 --> 00:33:39.239 +but it's time consuming. + +00:33:39.240 --> 00:33:43.440 +There is also an internal link to the main document here, + +00:33:43.440 --> 00:33:47.379 +and you can jump to it with C-c C-o. + +00:33:47.380 --> 00:33:50.040 +This is one of those intra-document links + +00:33:50.040 --> 00:33:52.999 +that is really tricky to get right with LaTeX, + +00:33:53.000 --> 00:33:56.989 +and is why we opted to use the latexmk Perl script + +00:33:56.990 --> 00:34:00.049 +to build the PDF version of the document. + +00:34:00.050 --> 00:34:01.920 +I'm mentioning it specifically here + +00:34:01.920 --> 00:34:05.629 +because it took me forever to figure this out. + +00:34:05.630 --> 00:34:07.269 +The second option you've got + +00:34:07.270 --> 00:34:09.280 +is to change the default header arg + +00:34:09.280 --> 00:34:13.739 +from `:cache yes` to `:cache no` at the top of the document. + +00:34:13.740 --> 00:34:16.269 +If we cruise up to the top of the document, + +00:34:16.270 --> 00:34:19.129 +you can see that this header argument property + +00:34:19.130 --> 00:34:22.440 +basically says that unless a code block + +00:34:22.440 --> 00:34:24.160 +explicitly says otherwise, + +00:34:24.160 --> 00:34:27.118 +it's by default supposed to be cached. + +00:34:27.119 --> 00:34:29.440 +That's how we were able to export the document + +00:34:29.440 --> 00:34:31.558 +before so quickly. + +00:34:31.559 --> 00:34:34.819 +The code block named `no_cache_no_confirm` + +00:34:34.820 --> 00:34:38.618 +uses the `save-excursion` and regex replace trick + +00:34:38.619 --> 00:34:40.348 +that I demonstrated earlier + +00:34:40.349 --> 00:34:42.819 +to munch the default cache header arg + +00:34:42.820 --> 00:34:45.409 +from "cache yes" to "cache no". + +00:34:45.410 --> 00:34:49.299 +And it also turns off confirmations on bash code blocks. + +00:34:49.300 --> 00:34:51.939 +Let's do that now. + +00:34:51.940 --> 00:34:54.559 +Now we'll export the document to PDF, + +00:34:54.560 --> 00:34:57.439 +which will ignore the cache result blocks + +00:34:57.440 --> 00:35:00.319 +and clone the Git repository on Savannah, + +00:35:00.320 --> 00:35:01.760 +create a branch that points + +00:35:01.760 --> 00:35:05.459 +to the most recently tagged version of Emacs 29, + +00:35:05.460 --> 00:35:07.759 +run configure a handful of times, + +00:35:07.760 --> 00:35:10.720 +installing packages to fix missing dependencies + +00:35:10.720 --> 00:35:12.399 +along the way, + +00:35:12.400 --> 00:35:16.099 +build Emacs, install Emacs in our home directory, + +00:35:16.100 --> 00:35:19.339 +verify that it has successfully built a binary, + +00:35:19.340 --> 00:35:22.549 +run it in batch mode with some sample Elisp + +00:35:22.550 --> 00:35:26.869 +and show the file sizes and dates of the generated files. + +00:35:26.870 --> 00:35:28.339 +This is gonna take a while. + +00:35:28.340 --> 00:35:32.829 +And while it's running, we'll pop over to our Fedora box. + +00:35:32.830 --> 00:35:34.680 +All right, now we'll fire up Emacs, + +00:35:34.680 --> 00:35:39.280 +hit `C-c C-c` on the `configure_document` code block + +00:35:39.280 --> 00:35:41.849 +to configure the document for RedHat + +00:35:41.850 --> 00:35:45.709 +since Fedora here is a RedHat based distro. + +00:35:45.710 --> 00:35:47.040 +Then what we'll do is we'll pop down + +00:35:47.040 --> 00:35:49.589 +and hit `C-c C-c` + +00:35:49.590 --> 00:35:53.699 +on the `rh_install_latex` code block + +00:35:53.700 --> 00:35:56.229 +to install the LaTeX prerequisites + +00:35:56.230 --> 00:35:58.459 +for this Fedora virtual machine. + +00:35:58.460 --> 00:36:02.589 +Finally, we'll execute the `no_cache_no_confirm` block + +00:36:02.590 --> 00:36:05.049 +and then kick off the export. + +00:36:05.050 --> 00:36:07.280 +Then we'll go and check back on what's happening + +00:36:07.280 --> 00:36:09.529 +on the Ubuntu box. + +00:36:09.530 --> 00:36:11.240 +Ooh, top looks pretty quiet. + +00:36:11.240 --> 00:36:14.039 +I think the export is complete. + +00:36:14.040 --> 00:36:17.559 +Ooh, those are the words I love to see in the status area, + +00:36:17.560 --> 00:36:20.609 +PDF file produced! + +NOTE Looking at the PDF + +00:36:20.610 --> 00:36:22.600 +Now I can't use my web browser + +00:36:22.600 --> 00:36:24.959 +to take a look at this PDF file + +00:36:24.960 --> 00:36:27.080 +because I haven't set up a web server + +00:36:27.080 --> 00:36:30.759 +or anything like that on the Ubuntu virtual machine. + +00:36:30.760 --> 00:36:34.439 +I can, however, use TRAMP with the ssh method + +00:36:34.440 --> 00:36:36.560 +to poke around on the ubuntu host + +00:36:36.560 --> 00:36:39.120 +on my personal version of Emacs. + +00:36:39.120 --> 00:36:40.939 +So let's do that. + +00:36:40.940 --> 00:36:44.809 +Okay, so now if we go into the source directory + +00:36:44.810 --> 00:36:48.039 +and then we hop into the orgdemo2 directory + +00:36:48.040 --> 00:36:51.619 +and then we look at the deb version of the PDF, + +00:36:51.620 --> 00:36:54.149 +there she blows. + +00:36:54.150 --> 00:36:58.160 +Now, if we go down to the Building Emacs section, + +00:36:58.160 --> 00:37:00.129 +we can see that it built. + +00:37:00.130 --> 00:37:03.839 +And if we look in the bin directory, + +00:37:03.840 --> 00:37:06.779 +we can see that at 17:01, + +00:37:06.780 --> 00:37:11.379 +that's when all of those files got created. + +00:37:11.380 --> 00:37:15.589 +Also the file creation date on the PDF is 17:01. + +00:37:15.590 --> 00:37:18.720 +So all of this code executed roughly the same time + +00:37:18.720 --> 00:37:21.159 +the PDF was created. + +00:37:21.160 --> 00:37:25.339 +All right, so now let's head back over to the Fedora box + +00:37:25.340 --> 00:37:27.920 +and then we'll navigate to the source directory, + +00:37:27.920 --> 00:37:30.119 +the orgdemo2 directory, + +00:37:30.120 --> 00:37:35.719 +and there is our RedHat version of the built Emacs PDF. + +00:37:35.720 --> 00:37:38.219 +And Bob's your uncle. + +00:37:38.220 --> 00:37:42.549 +And you can see it is the RedHat version of the document + +00:37:42.550 --> 00:37:44.939 +because this is a RedHat box. + +00:37:44.940 --> 00:37:51.639 +And if we go over to the What did we install? section, + +00:37:51.640 --> 00:37:56.049 +you can see that these binaries were built at 17:35. + +00:37:56.050 --> 00:37:58.699 +And now if we pop open dired + +00:37:58.700 --> 00:38:00.739 +and we take a look at the PDF, + +00:38:00.740 --> 00:38:07.329 +we can see it also was created at 17:35. + +00:38:07.330 --> 00:38:10.039 +All right, in the couple minutes remaining, + +00:38:10.040 --> 00:38:11.640 +I thought it would be a good idea + +00:38:11.640 --> 00:38:15.739 +just to take a look at the document + +00:38:15.740 --> 00:38:19.000 +and maybe just go through some of what it actually does + +00:38:19.000 --> 00:38:22.579 +in explaining how to build Emacs from source. + +00:38:22.580 --> 00:38:27.139 +We'll look at the RedHat version since we're here. + +00:38:27.140 --> 00:38:28.160 +And the first thing you do is + +00:38:28.160 --> 00:38:31.539 +you have to get access to the source code. + +00:38:31.540 --> 00:38:32.840 +And before you can do anything, + +00:38:32.840 --> 00:38:35.419 +this is a RedHat-specific section + +00:38:35.420 --> 00:38:38.299 +where you need to install some development tools. + +00:38:38.300 --> 00:38:41.539 +And this development tools group actually has Git. + +00:38:41.540 --> 00:38:44.640 +Now I installed Git earlier, but if you didn't do that, + +00:38:44.640 --> 00:38:46.939 +that would be the first thing that you need to do. + +00:38:46.940 --> 00:38:50.039 +We create a source directory, we cd into it, + +00:38:50.040 --> 00:38:53.059 +we clone the repo from Savannah. + +00:38:53.060 --> 00:38:56.059 +And then we start to take a look at some of the Git tags. + +00:38:56.060 --> 00:38:58.560 +And we showed this before where we check out + +00:38:58.560 --> 00:39:00.369 +how many different tags there are. + +00:39:00.370 --> 00:39:02.400 +And then we run this kind of funky Git command + +00:39:02.400 --> 00:39:06.040 +to sort of list all the tags that begin with 'emacs-29', + +00:39:06.040 --> 00:39:08.759 +and we sort them by when they were tagged. + +00:39:08.760 --> 00:39:12.400 +So we can see that Emacs 29.1.pretest + +00:39:12.400 --> 00:39:14.439 +is the most recent version. + +00:39:14.440 --> 00:39:15.880 +So that's the one we grab + +00:39:15.880 --> 00:39:18.659 +and that's the one we decide to build. + +00:39:18.660 --> 00:39:22.779 +And then we create a branch that is based on this tag. + +00:39:22.780 --> 00:39:27.479 +And this is dynamically generated based on what we saw here. + +00:39:27.480 --> 00:39:29.439 +So that's what we use here. + +NOTE Errors + +00:39:29.440 --> 00:39:32.920 +In this case, we're piping standard error + +00:39:32.920 --> 00:39:35.099 +to where standard out goes. + +00:39:35.100 --> 00:39:36.069 +That's another trick. + +00:39:36.070 --> 00:39:39.559 +If you want to actually see an error get created, + +00:39:39.560 --> 00:39:44.119 +org-mode will capture any errors that code blocks produce, + +00:39:44.120 --> 00:39:46.819 +and it will show you the error message in a buffer. + +00:39:46.820 --> 00:39:49.240 +So if you actually wanna show what it looks like + +00:39:49.240 --> 00:39:53.059 +when something errors out, this is the trick you have to use. + +00:39:53.060 --> 00:39:56.200 +And then what we do is we look for a configure script + +00:39:56.200 --> 00:39:57.419 +and there isn't one. + +00:39:57.420 --> 00:39:58.599 +And then we realize, + +00:39:58.600 --> 00:40:00.909 +uh-oh, we're gonna have to deal with autotools. + +00:40:00.910 --> 00:40:05.560 +So, you know, we run the autogen script and it complains + +00:40:05.560 --> 00:40:08.679 +because we're missing some prerequisites. + +00:40:08.680 --> 00:40:11.349 +So we have to install autoconf, + +00:40:11.350 --> 00:40:13.019 +and then we run it again, + +00:40:13.020 --> 00:40:15.959 +and finally it generates a configure script. + +00:40:15.960 --> 00:40:19.019 +And this is another case where I pull this number + +00:40:19.020 --> 00:40:21.979 +right here into the actual prose. + +00:40:21.980 --> 00:40:24.840 +And I can see it's, oh, it's, you know, this how many bytes. + +00:40:24.840 --> 00:40:26.800 +When was the last time you wrote a shell script + +00:40:26.800 --> 00:40:29.579 +that was this many bytes long? + +00:40:29.580 --> 00:40:31.320 +And then we configure the build process. + +00:40:31.320 --> 00:40:33.760 +And, you know, it's not gonna work right away + +00:40:33.760 --> 00:40:36.699 +because we don't have GNU Texinfo installed. + +00:40:36.700 --> 00:40:41.439 +So we gotta do that, which we do with `dnf install` here. + +00:40:41.440 --> 00:40:44.320 +And then there's this section that is either RedHat- + +00:40:44.320 --> 00:40:48.919 +or Debian-specific that talks about, like, + +00:40:48.920 --> 00:40:51.240 +if you don't know the name of a package + +00:40:51.240 --> 00:40:55.160 +that contains a given file name, how do you query it? + +00:40:55.160 --> 00:40:59.519 +And in the RedHat world, you use `dnf provides makeinfo`. + +00:40:59.520 --> 00:41:02.289 +In the Debian world, you do something entirely different. + +00:41:02.290 --> 00:41:06.639 +And then we have to install the `ncurses` binary. + +00:41:06.640 --> 00:41:10.299 +And finally we get like a minimal configuration + +00:41:10.300 --> 00:41:13.699 +and you can see that there's a whole bunch of nos here. + +00:41:13.700 --> 00:41:15.200 +So, you know, we don't have cairo, + +00:41:15.200 --> 00:41:18.799 +we don't have imagemagick, we don't have dbus, + +00:41:18.800 --> 00:41:20.600 +you know, there's a whole bunch of stuff we don't have. + +00:41:20.600 --> 00:41:23.880 +We don't have X, we don't have libjansson, no tree-sitter. + +00:41:23.880 --> 00:41:25.960 +This is really a bare-bones Emacs + +00:41:25.960 --> 00:41:28.639 +that is strictly terminal mode. + +00:41:28.640 --> 00:41:30.800 +Then we actually build Emacs, which is, you know, + +00:41:30.800 --> 00:41:33.259 +kind of boring, we're just gonna type make + +00:41:33.260 --> 00:41:35.259 +and then make is gonna run successfully. + +00:41:35.260 --> 00:41:37.880 +And make is gonna spew a ton of output, right? + +00:41:37.880 --> 00:41:41.099 +So here's where I do that /dev/null trick, + +00:41:41.100 --> 00:41:42.600 +where I pipe everything to /dev/null + +00:41:42.600 --> 00:41:45.819 +and then I, or I pipe standard output to /dev/null + +00:41:45.820 --> 00:41:47.520 +and then I pipe standard error + +00:41:47.520 --> 00:41:50.239 +to wherever standard output's going. + +00:41:50.240 --> 00:41:52.799 +And then at the end to say that it ran successfully, + +00:41:52.800 --> 00:41:55.379 +I say "Make ran successfully!" + +00:41:55.380 --> 00:41:57.799 +Then we take a look at the Emacs binary + +00:41:57.800 --> 00:41:59.879 +and you know, it's an elf binary. + +00:41:59.880 --> 00:42:01.720 +And, you know, because this is running on my Mac, + +00:42:01.720 --> 00:42:06.619 +this is an ARM-based machine, this virtual machine is. + +00:42:06.620 --> 00:42:10.519 +Oops, and this is a bug. + +00:42:10.520 --> 00:42:12.200 +This really should be a macro call, + +00:42:12.200 --> 00:42:14.800 +but I think I have the wrong number of curly braces + +00:42:14.800 --> 00:42:16.159 +or something in there. + +00:42:16.160 --> 00:42:19.129 +I need to figure out why that's not right. + +00:42:19.130 --> 00:42:21.109 +I'll look into that later. + +00:42:21.110 --> 00:42:23.979 +And then we install Emacs and then we kind of show + +00:42:23.980 --> 00:42:27.719 +like the file sizes of everything in the home directory. + +00:42:27.720 --> 00:42:31.989 +And then we, you know, show the binaries that got installed. + +NOTE Final thoughts + +00:42:31.990 --> 00:42:35.599 +Anyway, so this is the final thoughts section. + +00:42:35.600 --> 00:42:39.219 +And my final thoughts are, is I hope you enjoyed this talk + +00:42:39.220 --> 00:42:42.379 +and I hope you actually learned a thing or two. + +00:42:42.380 --> 00:42:43.360 +All right, thanks everybody. + +00:42:43.360 --> 00:42:45.200 +And I'll see you all next time. diff --git a/2023/captions/emacsconf-2023-ref--orgmode-workflow-informal-reference-tracking--christopher-howard--main--chapters.vtt b/2023/captions/emacsconf-2023-ref--orgmode-workflow-informal-reference-tracking--christopher-howard--main--chapters.vtt new file mode 100644 index 00000000..a61c9cd3 --- /dev/null +++ b/2023/captions/emacsconf-2023-ref--orgmode-workflow-informal-reference-tracking--christopher-howard--main--chapters.vtt @@ -0,0 +1,20 @@ +WEBVTT + + +00:00:00.000 --> 00:02:06.040 +Introduction + +00:02:06.040 --> 00:03:14.919 +Tip about completion frameworks + +00:03:14.920 --> 00:05:39.320 +References file overview + +00:05:39.320 --> 00:08:02.719 +The Emacs Lisp code + +00:08:02.720 --> 00:11:41.539 +Example reference to Elfeed article + +00:11:41.540 --> 00:15:04.320 +Searching the references diff --git a/2023/captions/emacsconf-2023-ref--orgmode-workflow-informal-reference-tracking--christopher-howard--main.vtt b/2023/captions/emacsconf-2023-ref--orgmode-workflow-informal-reference-tracking--christopher-howard--main.vtt new file mode 100644 index 00000000..f678c7ed --- /dev/null +++ b/2023/captions/emacsconf-2023-ref--orgmode-workflow-informal-reference-tracking--christopher-howard--main.vtt @@ -0,0 +1,808 @@ +WEBVTT captioned by bhavin192, checked by sachac + +NOTE Introduction + +00:00:00.000 --> 00:00:04.940 +Hello, this is Christopher Howard, + +00:00:04.940 --> 00:00:06.520 +and welcome to my talk, + +00:00:06.520 --> 00:00:08.800 +"Informal Reference Tracking." + +00:00:08.800 --> 00:00:10.574 +This is a workflow talk, + +00:00:10.574 --> 00:00:12.240 +so I need to explain a little bit about + +00:00:12.240 --> 00:00:14.840 +what my needs were. + +00:00:14.840 --> 00:00:18.760 +I am not a professional scholar or academic, + +00:00:18.760 --> 00:00:20.200 +but there are a number of subjects + +00:00:20.200 --> 00:00:21.607 +that I'm interested in, + +00:00:21.607 --> 00:00:23.240 +and I occasionally like to write + +00:00:23.240 --> 00:00:25.600 +gemlog posts about them. + +00:00:25.600 --> 00:00:28.680 +So I needed some way to keep track of references. + +00:00:28.680 --> 00:00:32.960 +References to webpage articles, references to books, + +00:00:32.960 --> 00:00:37.280 +pages in books, and notes about them. + +00:00:37.280 --> 00:00:39.480 +Something that was searchable, + +00:00:39.480 --> 00:00:42.440 +but also something that was quick and easy to use, + +00:00:42.440 --> 00:00:45.200 +and something that I could set up quickly. + +00:00:45.200 --> 00:00:47.360 +And the approach I took, it only took me + +00:00:47.360 --> 00:00:49.520 +about an hour or two to figure out + +00:00:49.520 --> 00:00:52.160 +how to put it together. + +00:00:52.160 --> 00:00:53.840 +I do want to emphasize + +00:00:53.840 --> 00:00:56.520 +that there are better ways to do this. + +00:00:56.520 --> 00:00:58.960 +I'm not recommending you use my code + +00:00:58.960 --> 00:01:02.120 +or follow my exact approach. + +00:01:02.120 --> 00:01:05.940 +In particular, what I'm doing was meant to be done + +00:01:05.940 --> 00:01:09.240 +with Org's built-in capture + +00:01:09.240 --> 00:01:11.800 +and templates functionality, + +00:01:11.800 --> 00:01:14.907 +so that's something that's more flexible, + +00:01:14.907 --> 00:01:21.440 +programmable, and there's also a lot of add-ins + +00:01:21.440 --> 00:01:23.960 +that can be tied into that. + +00:01:23.960 --> 00:01:31.320 +For example, tools that allow you to search for, + +00:01:31.320 --> 00:01:34.480 +you know, feed in a URL, and it automatically + +00:01:34.480 --> 00:01:38.240 +pulls all the reference data for you. + +00:01:38.240 --> 00:01:39.760 +And there's tools out there + +00:01:39.760 --> 00:01:43.120 +that are really meant for scientific writing, + +00:01:43.120 --> 00:01:46.760 +so if you do this professionally, + +00:01:46.760 --> 00:01:49.960 +you may need to keep track of dozens of details + +00:01:49.960 --> 00:01:51.080 +for each reference + +00:01:51.080 --> 00:01:55.320 +and then have some fancy system to generate that + +00:01:55.320 --> 00:02:00.800 +into your, or output that into your paper. + +00:02:00.800 --> 00:02:02.440 +So there are better systems, + +00:02:02.440 --> 00:02:06.040 +but this is what worked for me and what was easy. + +NOTE Tip about completion frameworks + +00:02:06.040 --> 00:02:11.320 +I do want to emphasize that if you haven't, + +00:02:11.320 --> 00:02:14.640 +you really want to learn how to use helm-mode + +00:02:14.640 --> 00:02:20.440 +H-E-L-M, or one of the similar systems in Emacs + +00:02:20.440 --> 00:02:26.440 +that does fuzzy search on Emacs commands. + +00:02:26.440 --> 00:02:29.340 +For example, in Helm here, + +00:02:29.340 --> 00:02:39.007 +I input one keychord, and then I just have to remember + +00:02:39.007 --> 00:02:40.720 +a few characters of some command, + +00:02:40.720 --> 00:02:43.479 +and they don't even have to be right next to each other, + +00:02:43.480 --> 00:02:47.640 +like H-O-C will bring up `helm-occur`. + +00:02:47.640 --> 00:02:51.360 +That's based on its algorithms + +00:02:51.360 --> 00:02:53.000 +of what I most likely meant + +00:02:53.000 --> 00:02:55.160 +and the ones that I've used in the past. + +00:02:55.160 --> 00:02:57.920 +So it usually brings up the command that I want, + +00:02:57.920 --> 00:02:59.579 +or the one that I want + +00:02:59.580 --> 00:03:03.080 +is one or two spots away in the entry. + +00:03:03.080 --> 00:03:05.074 +That just saves me a lot of time + +00:03:05.074 --> 00:03:06.960 +[and] a lot of memorization. + +00:03:06.960 --> 00:03:09.120 +So if you haven't learned Helm + +00:03:09.120 --> 00:03:14.919 +or a similar system for Emacs, you really want to. + +NOTE References file overview + +00:03:14.920 --> 00:03:18.240 +So what is my approach? + +00:03:18.240 --> 00:03:24.880 +Well, basically, what it comes down to is really + +00:03:24.880 --> 00:03:27.307 +fundamentally nothing more than just a list + +00:03:27.307 --> 00:03:30.640 +of Org entries in a file. + +00:03:30.640 --> 00:03:35.579 +And there's one entry per reference. + +00:03:35.580 --> 00:03:37.207 +Fundamentally, that's all it is. + +00:03:37.207 --> 00:03:39.207 +But I'll go over the parts. + +00:03:39.207 --> 00:03:43.080 +You can see there's the title for the entry, + +00:03:43.080 --> 00:03:44.800 +and that's not necessarily + +00:03:44.800 --> 00:03:47.400 +the title of the book or the article, + +00:03:47.400 --> 00:03:50.840 +but that's my perspective on it, + +00:03:50.840 --> 00:03:52.720 +that's what I want to remember about it, + +00:03:52.720 --> 00:03:54.560 +and what I'll be looking for later + +00:03:54.560 --> 00:03:56.560 +when I do a search on my references. + +00:03:56.560 --> 00:04:06.659 +There's also in here the use of Org's tags + +00:04:06.660 --> 00:04:08.274 +here to the right of the title, + +00:04:08.274 --> 00:04:12.040 +very handy for searching for entries later. + +00:04:12.040 --> 00:04:18.160 +I use some Org properties attached to each entry. + +00:04:18.160 --> 00:04:21.740 +I automatically add in here an ID + +00:04:21.740 --> 00:04:24.074 +that can be useful if you want to + +00:04:24.074 --> 00:04:27.800 +link entries together later. + +00:04:27.800 --> 00:04:30.400 +I automatically add in here the date + +00:04:30.400 --> 00:04:31.840 +that the entry was created, + +00:04:31.840 --> 00:04:35.699 +which can be useful to me if things + +00:04:35.700 --> 00:04:38.360 +got sorted in a different order at some point, + +00:04:38.360 --> 00:04:39.940 +I could still look through + +00:04:39.940 --> 00:04:42.507 +the most recent entries that I had made + +00:04:42.507 --> 00:04:45.040 +if I wanted to do that for some reason. + +00:04:45.040 --> 00:04:48.640 +And sometimes I add in this publication year field + +00:04:48.640 --> 00:04:52.720 +with the idea that one day I might want to do + +00:04:52.720 --> 00:04:55.840 +a search for entries based on the publication year + +00:04:55.840 --> 00:04:57.360 +of the book or the article, + +00:04:57.360 --> 00:05:00.774 +say, only to use recent references + +00:05:00.774 --> 00:05:03.080 +or something like that. + +00:05:03.080 --> 00:05:05.360 +And then down here below the properties + +00:05:05.360 --> 00:05:10.080 +is where I paste in the URL to the webpage, or + +00:05:10.080 --> 00:05:13.007 +type in the title and author of the book + +00:05:13.007 --> 00:05:16.959 +on the pages, maybe the pages that were relevant, + +00:05:16.960 --> 00:05:21.640 +the pages of the periodical, or something like that. + +00:05:21.640 --> 00:05:23.920 +And I could put anything that I want down here, + +00:05:23.920 --> 00:05:25.840 +some other notes about what's important + +00:05:25.840 --> 00:05:29.939 +about this article to me. + +00:05:29.940 --> 00:05:32.200 +So fundamentally, that's all it is. + +00:05:32.200 --> 00:05:35.240 +Of course, I've added in a bit of convenience code + +00:05:35.240 --> 00:05:37.080 +to make this go a lot faster + +00:05:37.080 --> 00:05:39.320 +rather than typing all this out. + +NOTE The Emacs Lisp code + +00:05:39.320 --> 00:05:45.879 +For that, I'll switch back to my init.el file. + +00:05:45.880 --> 00:05:49.480 +There's really just five functions. + +00:05:49.480 --> 00:05:52.840 +The first two here are ones + +00:05:52.840 --> 00:05:54.560 +that I've adapted off the Internet. + +00:05:54.560 --> 00:05:56.160 +Honestly, I can't remember + +00:05:56.160 --> 00:05:58.239 +exactly where that I got them from, + +00:05:58.240 --> 00:06:00.240 +but basically, they're just some functions + +00:06:00.240 --> 00:06:04.240 +for making a block of text writable or readable. + +00:06:04.240 --> 00:06:09.299 +Writable or not writable, I should say. + +00:06:09.300 --> 00:06:12.200 +The idea there is that + +00:06:12.200 --> 00:06:13.480 +when I'm creating a new entry, + +00:06:13.480 --> 00:06:16.307 +I don't want to accidentally delete + +00:06:16.307 --> 00:06:18.960 +or write over some earlier entries that I've made. + +00:06:18.960 --> 00:06:24.880 +So I use a little bit of Emacs functionality for that. + +00:06:24.880 --> 00:06:29.440 +And then here are the three reference functions + +00:06:29.440 --> 00:06:32.440 +that I've actually written. + +00:06:32.440 --> 00:06:35.040 +Really trivial, basic stuff here. + +00:06:35.040 --> 00:06:41.800 +The core of it is the `new-reference` function. + +00:06:41.800 --> 00:06:44.840 +Basically, what that does is + +00:06:44.840 --> 00:06:47.560 +it opens up the references file, + +00:06:47.560 --> 00:06:52.040 +jumps to the end of the reference file, + +00:06:52.040 --> 00:06:57.440 +starts a new entry, inserts the asterisk. + +00:06:57.440 --> 00:07:01.520 +It jumps back to the previous text, + +00:07:01.520 --> 00:07:03.474 +and whatever previous text there is, + +00:07:03.474 --> 00:07:04.880 +it makes that read-only. + +00:07:04.880 --> 00:07:08.120 +Again, so that I don't accidentally delete that, + +00:07:08.120 --> 00:07:10.800 +or cut, or type over it, or something + +00:07:10.800 --> 00:07:14.579 +when I'm making a new reference. + +00:07:14.580 --> 00:07:17.680 +Then it goes back to the new reference, + +00:07:17.680 --> 00:07:21.339 +automatically adds in a unique ID for that, + +00:07:21.340 --> 00:07:25.360 +and then automatically stamps it with + +00:07:25.360 --> 00:07:28.999 +the date the entry was created — today's date. + +00:07:29.000 --> 00:07:32.760 +Now, I've got two other functions here. + +00:07:32.760 --> 00:07:34.540 +One is `view-references`, + +00:07:34.540 --> 00:07:37.807 +which does nothing but open up the reference file + +00:07:37.807 --> 00:07:39.400 +and switch to that buffer + +00:07:39.400 --> 00:07:42.539 +if you're not already on it. + +00:07:42.540 --> 00:07:45.880 +And then there's one other here, `edit-references`, + +00:07:45.880 --> 00:07:50.159 +which does the exact same thing except for + +00:07:50.160 --> 00:07:53.560 +it also goes over all the text in the buffer + +00:07:53.560 --> 00:07:55.040 +and makes it writable. + +00:07:55.040 --> 00:07:58.120 +So if I really do want to edit those other references, + +00:07:58.120 --> 00:08:02.719 +I've got a function to quickly make that possible. + +NOTE Example reference to Elfeed article + +00:08:02.720 --> 00:08:07.499 +Let me give an example of this. + +00:08:07.500 --> 00:08:13.979 +I type in here, new reference. + +00:08:13.980 --> 00:08:16.440 +Now I've jumped to the end of my references file. + +00:08:16.440 --> 00:08:19.080 +See, it's ready to take the title. + +00:08:19.080 --> 00:08:21.720 +Well, I guess I need to have something, + +00:08:21.720 --> 00:08:23.659 +some content, to put in here. + +00:08:23.660 --> 00:08:28.879 +Let's say I was looking through Elfeed, + +00:08:28.880 --> 00:08:31.600 +and let's say I found this interesting article + +00:08:31.600 --> 00:08:38.219 +about Mars earthquakes. + +00:08:38.220 --> 00:08:40.007 +Let's say I open it up [and] + +00:08:40.007 --> 00:08:41.159 +I read through the article. + +00:08:41.160 --> 00:08:43.840 +First, I'd figure out what it is + +00:08:43.840 --> 00:08:47.259 +that I find interesting about this, what it is that + +00:08:47.260 --> 00:08:51.579 +I'm going to want to remember and look up later. + +00:08:51.580 --> 00:08:57.479 +So I come up with a quick title based on that. + +00:08:57.480 --> 00:09:01.899 +Let's go back to the references with `view-reference`. + +00:09:01.900 --> 00:09:05.674 +And, let's just call it + +00:09:05.674 --> 00:09:13.879 +"Study of Mars Earthquake." + +00:09:13.880 --> 00:09:18.199 +Now I'm going to also want to put in some tags. + +00:09:18.200 --> 00:09:21.107 +On my system, that's done with + +00:09:21.107 --> 00:09:23.639 +Control C, Control Q (`C-c C-q`). + +00:09:23.640 --> 00:09:25.520 +And I can put in some tags. + +00:09:25.520 --> 00:09:29.160 +I like to go ahead and insert the colons. + +00:09:29.160 --> 00:09:30.799 +You can leave those out, + +00:09:30.800 --> 00:09:32.560 +but they're going to get added anyway, + +00:09:32.560 --> 00:09:36.779 +so I'm in the habit of using them. + +00:09:36.780 --> 00:09:41.120 +Let's say we'll call this 'Astronomy' as one tag, + +00:09:41.120 --> 00:09:47.059 +and the next tag could be 'Planets'. + +00:09:47.060 --> 00:09:48.400 +If I wanted to use a tag + +00:09:48.400 --> 00:09:50.400 +that was more than one word in the tag, + +00:09:50.400 --> 00:09:53.540 +I'd need to use underscores or something like that. + +00:09:53.540 --> 00:10:00.499 +If I wanted a tag that was 'Mars Earthquakes', + +00:10:00.500 --> 00:10:05.059 +I could do it like that, but that's kind of silly. + +00:10:05.060 --> 00:10:08.659 +Now I try not to be too clever with the tags. + +00:10:08.660 --> 00:10:10.600 +I don't spend a lot of time thinking about them. + +00:10:10.600 --> 00:10:13.107 +I just come up with some general buckets + +00:10:13.107 --> 00:10:15.019 +to throw things in. + +00:10:15.020 --> 00:10:16.880 +You can see the tags were added there, + +00:10:16.880 --> 00:10:19.379 +to the right of the title. + +00:10:19.380 --> 00:10:23.399 +Now you can see down here under PROPERTIES, + +00:10:23.400 --> 00:10:25.320 +the ID has already been added, + +00:10:25.320 --> 00:10:27.040 +the Date_Created has been added. + +00:10:27.040 --> 00:10:30.200 +Sometimes, I'll like to put in the publication year, + +00:10:30.200 --> 00:10:38.139 +and for that, I use the `org-set-property` command. + +00:10:38.140 --> 00:10:43.439 +Publication_Year, this year in this case. + +00:10:43.440 --> 00:10:46.679 +And then I just need to paste in the URL. + +00:10:46.680 --> 00:10:48.080 +I do that manually. + +00:10:48.080 --> 00:10:53.480 +I use Org's bracket format for that. + +00:10:53.480 --> 00:10:57.639 +So I start that, go back to the article, + +00:10:57.640 --> 00:11:02.099 +copy the URL, paste that in. + +00:11:02.100 --> 00:11:04.480 +If I want, I can add it in the title + +00:11:04.480 --> 00:11:07.459 +with the second pair of brackets here. + +00:11:07.460 --> 00:11:14.200 +Don't have to, but often like to. + +00:11:14.200 --> 00:11:18.560 +Close that off, and there it is. + +00:11:18.560 --> 00:11:20.879 +That was really it. + +00:11:20.880 --> 00:11:22.120 +I add a return on the end here, + +00:11:22.120 --> 00:11:26.619 +just so the next entry comes out with the right spacing. + +00:11:26.620 --> 00:11:28.307 +But really, that's it, + +00:11:28.307 --> 00:11:31.000 +and typically, when I'm not explaining it, + +00:11:31.000 --> 00:11:37.499 +that only takes 20 seconds or so, or 30 seconds. + +00:11:37.500 --> 00:11:41.539 +Pretty quick. Pretty easy. + +NOTE Searching the references + +00:11:41.540 --> 00:11:45.539 +What about searching later? + +00:11:45.540 --> 00:11:50.474 +Well, often the easiest thing is just do a simple, + +00:11:50.474 --> 00:11:54.639 +boring incremental search. + +00:11:54.640 --> 00:11:55.880 +I usually know roughly + +00:11:55.880 --> 00:11:58.499 +what it is that I'm looking for already. + +00:11:58.500 --> 00:12:02.379 +If I was looking for that wildflower article, + +00:12:02.380 --> 00:12:06.000 +I could just do an incremental search for wildflowers + +00:12:06.000 --> 00:12:07.920 +and jump through that. It's pretty simple. + +00:12:07.920 --> 00:12:13.200 +Not very impressive, but honestly, most of the time + +00:12:13.200 --> 00:12:16.439 +that gets me there pretty quick. + +00:12:16.440 --> 00:12:20.360 +Sometimes I find it useful to do an Occur search, + +00:12:20.360 --> 00:12:23.240 +more specifically a Helm Occur search. + +00:12:23.240 --> 00:12:31.259 +If I use the `helm-occur` command, + +00:12:31.260 --> 00:12:34.680 +then I like to use this to search by tag. + +00:12:34.680 --> 00:12:36.760 +That's where it really becomes handy. + +00:12:36.760 --> 00:12:39.207 +Let's say I want to narrow it down + +00:12:39.207 --> 00:12:42.640 +to all my astronomy references + +00:12:42.640 --> 00:12:50.039 +and then narrow it down a little bit more to planets. + +00:12:50.040 --> 00:12:54.119 +I can put spaces in between and it still works. + +00:12:54.120 --> 00:12:57.199 +You can see here in one window, + +00:12:57.200 --> 00:13:00.239 +it gives me the bottom window there. + +00:13:00.240 --> 00:13:03.479 +It's giving…, just because of the way + +00:13:03.480 --> 00:13:06.440 +the tags are formatted with the title, it gives me + +00:13:06.440 --> 00:13:09.519 +a list of all the titles that have those tags. + +00:13:09.520 --> 00:13:11.520 +And I usually find what I want pretty quick + +00:13:11.520 --> 00:13:13.400 +by just tapping through here. + +00:13:13.400 --> 00:13:16.499 +Once I find the one that I think I want, + +00:13:16.500 --> 00:13:24.139 +I press enter, and now I'm focused on just that entry. + +00:13:24.140 --> 00:13:26.960 +There is some advanced functionality, I believe, + +00:13:26.960 --> 00:13:29.960 +that I used in the past where you could search + +00:13:29.960 --> 00:13:33.119 +based on the property fields. + +00:13:33.120 --> 00:13:37.880 +So do something like search for publication — + +00:13:37.880 --> 00:13:42.439 +the most recent publications in the last 10 years. + +00:13:42.440 --> 00:13:46.200 +There's some kind of advanced syntax for that, + +00:13:46.200 --> 00:13:48.219 +which I used once or twice. + +00:13:48.220 --> 00:13:51.400 +Honestly, I use that so infrequently + +00:13:51.400 --> 00:13:54.840 +that I have to go back to the Emacs manual + +00:13:54.840 --> 00:13:57.739 +and figure it out each time, and figure out again + +00:13:57.740 --> 00:13:59.880 +how I did that the last time. + +00:13:59.880 --> 00:14:02.000 +But since I do it only once + +00:14:02.000 --> 00:14:06.679 +every three or four months, it's not a problem. + +00:14:06.680 --> 00:14:11.519 +So I'm not going to go over that today. + +00:14:11.520 --> 00:14:16.479 +That's pretty much it in a nutshell. + +00:14:16.480 --> 00:14:19.974 +Again, the code that I wrote, this specific approach + +00:14:19.974 --> 00:14:24.279 +is not really what I'm recommending. + +00:14:24.280 --> 00:14:31.160 +But here it is if you really do want to use it. + +00:14:31.160 --> 00:14:36.239 +Maybe I can make a link to the URL + +00:14:36.240 --> 00:14:40.059 +and share that in the chat room or something. + +00:14:40.060 --> 00:14:46.759 +But I consider this to be trivial code. + +00:14:46.760 --> 00:14:49.799 +So just use that if you want to use it. + +00:14:49.800 --> 00:14:53.440 +I should be signing off here now. + +00:14:53.440 --> 00:14:58.259 +I should be in the chat room, in the IRC chat room, + +00:14:58.260 --> 00:15:01.920 +or you can reach out to me by email if you'd like. + +00:15:01.920 --> 00:15:04.320 +Thank you very much. diff --git a/2023/captions/emacsconf-2023-unentangling--unentangling-projects-and-repos--alexey-bochkarev--main.vtt b/2023/captions/emacsconf-2023-unentangling--unentangling-projects-and-repos--alexey-bochkarev--main.vtt new file mode 100644 index 00000000..61834255 --- /dev/null +++ b/2023/captions/emacsconf-2023-unentangling--unentangling-projects-and-repos--alexey-bochkarev--main.vtt @@ -0,0 +1,572 @@ +WEBVTT + +00:00.000 --> 00:04.000 +Hello, I'm Alexey Bychkadov, and I'm talking about + +00:04.000 --> 00:07.000 +unentangling projects and repositories, + +00:07.000 --> 00:10.000 +or maybe entangling them, depending on how you look at that. + +00:12.000 --> 00:15.000 +So that's going to be a short workflow note. + +00:15.000 --> 00:19.000 +I work as a researcher, + +00:19.000 --> 00:23.000 +so there are three main components to my work, I guess. + +00:23.000 --> 00:27.000 +First, I think, so I try to come up with new ideas, + +00:27.000 --> 00:31.000 +and that usually results in some collection of notes I have. + +00:31.000 --> 00:35.000 +Second, I try things out, so it usually means that I write code. + +00:35.000 --> 00:39.000 +And third, I communicate, so I prepare papers, + +00:39.000 --> 00:43.000 +presentations, memos, and so on and so forth. + +00:43.000 --> 00:47.000 +And so the workflow problem I had is + +00:47.000 --> 00:51.000 +sometimes all this does not really fit + +00:51.000 --> 00:55.000 +into a concept of a single repository per project, + +00:55.000 --> 00:59.000 +so I might want to have, for example, + +00:59.000 --> 01:03.000 +a source code in one repository, and then I would like to have a paper + +01:03.000 --> 01:07.000 +in another one, and then I want to have a collection of notes somewhere + +01:07.000 --> 01:11.000 +unrelated to those two. And yeah, + +01:11.000 --> 01:15.000 +Emacs is pretty good at supporting your workflows, and I figured I should + +01:15.000 --> 01:19.000 +share what I use and what works for me. + +01:19.000 --> 01:23.000 +So, + +01:23.000 --> 01:27.000 +from the technical perspective, things are + +01:27.000 --> 01:31.000 +pretty easy, so I use a collection of pretty standard components + +01:31.000 --> 01:35.000 +of Emacs, so it's a projectile org-mode with its capture templates and other + +01:35.000 --> 01:39.000 +things. Then I sustain a collection of notes in something + +01:39.000 --> 01:43.000 +that is called org-roam, which is, well, essentially, it's a glorified + +01:43.000 --> 01:47.000 +collection of org-mode files. Then I use directory + +01:47.000 --> 01:51.000 +local variables, maybe a ctext to jump through the source code, + +01:51.000 --> 01:55.000 +and very, very little Elisp glue to make this + +01:55.000 --> 01:59.000 +all work, but that's not really rocket science. + +01:59.000 --> 02:03.000 +So that's the workflow I would like to talk about today. + +02:03.000 --> 02:07.000 +So, what I mean by all that, + +02:07.000 --> 02:11.000 +it's pretty straightforward to make + +02:11.000 --> 02:15.000 +it easy to jump around a single repository in Emacs. + +02:15.000 --> 02:19.000 +Now, I have Doom Emacs, but that's not really specific to Doom. + +02:19.000 --> 02:23.000 +That'll work in any Emacs configuration. + +02:23.000 --> 02:27.000 +Well, kbindings might be + +02:27.000 --> 02:31.000 +different, but that's not the point, I guess, for the workflow. So, if I hit space + +02:31.000 --> 02:35.000 +two times, I have all the list of files within my project. + +02:35.000 --> 02:39.000 +So, if I create a couple of custom shortcuts, + +02:39.000 --> 02:43.000 +so if I press a magic button, + +02:43.000 --> 02:47.000 +hyperlp, don't worry about hyperkey, so I want it to have a + +02:47.000 --> 02:51.000 +modifier key all to myself, so that would, no program + +02:51.000 --> 02:55.000 +on my computer would use that except Emacs, and Emacs would + +02:55.000 --> 02:59.000 +use that only when I tell it to, so I have a hyperkey instead of caps lock, that's pretty easy + +02:59.000 --> 03:03.000 +to do in GNU Linux system. So, + +03:03.000 --> 03:07.000 +when I press this magic keys, I have a menu that's a normal + +03:07.000 --> 03:11.000 +kbinding, yeah, essentially in Emacs, and + +03:11.000 --> 03:15.000 +if I hit, for example, R, I end up in a readme file within + +03:15.000 --> 03:19.000 +this specific repository I was sitting in, right, so if I want to document something + +03:19.000 --> 03:23.000 +real quick, I go to the readme file. Then I could have, I could + +03:23.000 --> 03:27.000 +go to a changelog file, right, so I have a list of changes + +03:27.000 --> 03:31.000 +and the way it works, usually, for example, if I'm working on some code, + +03:31.000 --> 03:35.000 +I created a couple of dummy files in there, so + +03:35.000 --> 03:39.000 +I'm working on some code, and then I implemented something, and I can + +03:39.000 --> 03:43.000 +just use the org mode capture + +03:43.000 --> 03:47.000 +mechanisms to keep track of what + +03:47.000 --> 03:51.000 +I want to discuss with colleagues next time, for example, I could just hit + +03:51.000 --> 03:55.000 +capture repo specific changelog entry + +03:55.000 --> 03:59.000 +and I implemented a feature + +03:59.000 --> 04:03.000 +and I can continue working + +04:03.000 --> 04:07.000 +without this context switching, and then if I want to go to the changelog, + +04:07.000 --> 04:11.000 +well, it is there, and next time I talk + +04:11.000 --> 04:15.000 +to the colleagues about the source code, I can open the changelog and go through entries one by one + +04:15.000 --> 04:19.000 +and discuss what I have implemented last time. + +04:19.000 --> 04:23.000 +I could go to project specific + +04:23.000 --> 04:27.000 +to, sorry, to repo specific to-do list, and I have + +04:27.000 --> 04:31.000 +a list of to-dos that would live within a repository, and + +04:31.000 --> 04:35.000 +for example, I could have a high-level structure here, + +04:35.000 --> 04:39.000 +work distribution between team members and other things that sort of face + +04:39.000 --> 04:43.000 +the world, so to speak, and of course, + +04:43.000 --> 04:47.000 +there are very many ways to jump through the source code conveniently, + +04:47.000 --> 04:51.000 +I ended up not using language servers, I used a special program called + +04:51.000 --> 04:55.000 +ctags, and so the way it works is just I call + +04:55.000 --> 04:59.000 +projectile regenerate tags, and it creates the special + +04:59.000 --> 05:03.000 +tags file within the repository, + +05:03.000 --> 05:07.000 +and then I can, again, run + +05:07.000 --> 05:11.000 +I usually just hit a single keystroke, + +05:11.000 --> 05:15.000 +and here is all the symbols that are there in my + +05:15.000 --> 05:19.000 +source code, regardless of the language, right, so I can jump to the main function + +05:19.000 --> 05:23.000 +and that'll be a C++ file, or I could go to the super function, which I + +05:23.000 --> 05:27.000 +had in my Python file, and this comes in pretty convenient if I have + +05:27.000 --> 05:31.000 +a mixture of languages, so sometimes I can have some algorithm-specific code + +05:31.000 --> 05:35.000 +in Julia, and then I can have some Python glue within the same + +05:35.000 --> 05:39.000 +source code repository, and it makes it really convenient to jump + +05:39.000 --> 05:43.000 +between all of those, right, + +05:43.000 --> 05:47.000 +but I have a few problems here, + +05:47.000 --> 05:51.000 +just to give you a little bit of context, for example, here is the + +05:51.000 --> 05:55.000 +a real project that corresponds to a real paper, + +05:55.000 --> 05:59.000 +I have a single note about that project, + +05:59.000 --> 06:03.000 +where I keep all the things related to that project here, but that's a private + +06:03.000 --> 06:07.000 +note, so for example, again, I hit a special key that + +06:07.000 --> 06:11.000 +invokes my org-roam function that gives me a menu of my + +06:11.000 --> 06:15.000 +notes, and so here is the paper, + +06:15.000 --> 06:19.000 +essentially, and I can have a paper timeline, and I can + +06:19.000 --> 06:23.000 +have a list of all the dates, what happened to the paper, with links + +06:23.000 --> 06:27.000 +to my email, right, so for example, if I hit this link, + +06:27.000 --> 06:31.000 +that'll open a specific email, and that doesn't work outside of my + +06:31.000 --> 06:35.000 +computer, it doesn't make any sense to keep it in the outer world-facing + +06:35.000 --> 06:39.000 +repository, for example, so that's something to myself, right, sometimes I want + +06:39.000 --> 06:43.000 +to have, like, this list of + +06:43.000 --> 06:47.000 +working notes, right, that contain, like, for example, + +06:47.000 --> 06:51.000 +I might produce this kind of things for internal discussion, right, + +06:51.000 --> 06:55.000 +it has some marks, it has some margin notes, and things like that, + +06:55.000 --> 06:59.000 +maybe, again, health-based ideas that may or may not end up + +06:59.000 --> 07:03.000 +in a repository, in a final paper, or in a source code, + +07:03.000 --> 07:07.000 +but still I want to have it somewhere, and + +07:07.000 --> 07:11.000 +well, long story short, I need a project folder + +07:11.000 --> 07:15.000 +that would be unrelated to the source code, or + +07:15.000 --> 07:19.000 +to the source code repository, or to the paper itself, + +07:19.000 --> 07:23.000 +or a final report, right, and one way, + +07:23.000 --> 07:27.000 +as usual, there are multiple ways to achieve that, I suppose, and one way to do that + +07:27.000 --> 07:31.000 +is, so, I create + +07:31.000 --> 07:35.000 +a special folder within my org-roam + +07:35.000 --> 07:39.000 +storage, so it's a special folder outside of any + +07:39.000 --> 07:43.000 +repositories that got backed up to my hard drive, with + +07:43.000 --> 07:47.000 +certain redundancy, but I don't really need, like, version control, full-blown + +07:47.000 --> 07:51.000 +version control for that, I'm okay with just having a couple of backups, right, so + +07:51.000 --> 07:55.000 +this is the folder you see here, so pkb stands for personal knowledge + +07:55.000 --> 07:59.000 +base, and I have a folder, project notes in there, right, so + +07:59.000 --> 08:03.000 +and, how does it work, so I have a + +08:03.000 --> 08:07.000 +folder per project in there, essentially, and here I can + +08:07.000 --> 08:11.000 +have all the stuff that is, that kind of belongs to me, and I + +08:11.000 --> 08:15.000 +do not publish it anywhere, and then + +08:15.000 --> 08:19.000 +for example, a source code + +08:19.000 --> 08:23.000 +repository knows about that folder, and a paper repository + +08:23.000 --> 08:27.000 +knows about that folder, and anything else that might live in separate + +08:27.000 --> 08:31.000 +places all over my system can know about that folder, and how do I achieve that, + +08:31.000 --> 08:35.000 +well, essentially, this is one of the use cases for the directory + +08:35.000 --> 08:39.000 +local variables, right, so, for example, + +08:39.000 --> 08:43.000 +how does it work from the user perspective, so if I hit a special + +08:43.000 --> 08:47.000 +key, oh, sorry, if I hit a special key + +08:47.000 --> 08:51.000 +that would be open project + +08:51.000 --> 08:55.000 +and then, for example, + +08:55.000 --> 08:59.000 +org mode file, right, so this is my personal notes about the emacs conf, not + +08:59.000 --> 09:03.000 +specifically about this very talk, but I can have, you know, + +09:03.000 --> 09:07.000 +half-baked ideas here, again, presentation tools, and things like that, + +09:07.000 --> 09:11.000 +and how does that happen if we try to + +09:11.000 --> 09:15.000 +look at the code, the elisp magic here, what + +09:15.000 --> 09:19.000 +is happening is, it's just a couple lines of code, in fact, so + +09:19.000 --> 09:23.000 +let me just press control, help + +09:23.000 --> 09:27.000 +key, and so the key I was + +09:27.000 --> 09:31.000 +pressing is open project org mode file, and so + +09:31.000 --> 09:35.000 +what we see here, there is a single, so it's just a call to a find + +09:35.000 --> 09:39.000 +file function, so I open that file, and there is a special function that + +09:39.000 --> 09:43.000 +figures out what is the, like, umbrella + +09:43.000 --> 09:47.000 +project notes file, and that's, again, that's very easy, so + +09:47.000 --> 09:51.000 +essentially, if a variable describing this + +09:51.000 --> 09:55.000 +the name for that project is defined, then + +09:55.000 --> 09:59.000 +I use that as my project folder name, if not, I take the project name from the + +09:59.000 --> 10:03.000 +project towel, and well, that's pretty much it, + +10:03.000 --> 10:07.000 +and how do I define this + +10:07.000 --> 10:11.000 +variable is, essentially, there is this + +10:11.000 --> 10:15.000 +magical file in a folder called dear locals elisp, + +10:15.000 --> 10:19.000 +and I just put it there, and then, whenever I + +10:19.000 --> 10:23.000 +go into that folder, or any of its children folders, I get this + +10:23.000 --> 10:27.000 +variable defined, and that's pretty much it, that's how + +10:27.000 --> 10:31.000 +it works for me. + +10:31.000 --> 10:35.000 +I guess one thing that I wanted to emphasize + +10:35.000 --> 10:39.000 +specifically about that is, of course, it's + +10:39.000 --> 10:43.000 +time tracking, right, so what I find especially important when I work in + +10:43.000 --> 10:47.000 +something, and I want to clock time, I usually do not want + +10:47.000 --> 10:51.000 +this information to be in a source code repository or in a paper repository + +10:51.000 --> 10:55.000 +because other people I work with will not be particularly happy about that + +10:55.000 --> 10:59.000 +especially if most of them do not use Emacs, and they will see + +10:59.000 --> 11:03.000 +this long list of org clocked data, and that doesn't look + +11:03.000 --> 11:07.000 +nice in a plain text format, so what I usually + +11:07.000 --> 11:11.000 +do if I want to clock in some time, and then later analyze what I've + +11:11.000 --> 11:15.000 +been spending time on, so I go to my org mode file + +11:15.000 --> 11:19.000 +and I go to my current project + +11:19.000 --> 11:23.000 +to-dos, and I clock in there, and that's + +11:23.000 --> 11:27.000 +how it works, so again + +11:27.000 --> 11:31.000 +what comes in handy if I hit ctrl-o, I just go + +11:31.000 --> 11:35.000 +back to the file I jumped from, so that's also + +11:35.000 --> 11:39.000 +pretty handy, so again, no rocket science in there + +11:39.000 --> 11:43.000 +so I create a directory local variable that helps me + +11:43.000 --> 11:47.000 +to figure out what umbrella project does + +11:47.000 --> 11:51.000 +this particular folder belongs to, and this way + +11:51.000 --> 11:55.000 +I make Emacs aware of, for example, facts like so this + +11:55.000 --> 11:59.000 +source code belongs to that project, and this repository with the paper + +11:59.000 --> 12:03.000 +also belongs to that project, and I can have capture templates + +12:03.000 --> 12:07.000 +that would save my notes into my private notes + +12:07.000 --> 12:11.000 +file, and my to-dos go to my private note files + +12:11.000 --> 12:15.000 +and so on and so forth, so I find it pretty simple, but + +12:15.000 --> 12:19.000 +that really helps to reduce this context + +12:19.000 --> 12:23.000 +switching, and I don't believe it allows me to save time + +12:23.000 --> 12:27.000 +but that probably helps me to stay focused, and this + +12:27.000 --> 12:31.000 +is what is really important, I believe, so thank you + +12:31.000 --> 12:35.000 +very much, and if you have any comments or suggestions to that, please do jump + +12:35.000 --> 12:39.000 +into the discussion, yeah, after the talk, thank you. + |