diff options
Diffstat (limited to '')
4 files changed, 1858 insertions, 1 deletions
diff --git a/2023/captions/emacsconf-2023-overlay--improving-compiler-diagnostics-with-overlays--jeff-trull--main--chapters.vtt b/2023/captions/emacsconf-2023-overlay--improving-compiler-diagnostics-with-overlays--jeff-trull--main--chapters.vtt new file mode 100644 index 00000000..fde9af29 --- /dev/null +++ b/2023/captions/emacsconf-2023-overlay--improving-compiler-diagnostics-with-overlays--jeff-trull--main--chapters.vtt @@ -0,0 +1,80 @@ +WEBVTT + + +00:00:00.000 --> 00:00:33.560 +Introduction + +00:00:33.560 --> 00:02:02.500 +Overlays and what they can do + +00:02:02.500 --> 00:02:35.700 +Simple overlay example - creating an overlay + +00:02:35.700 --> 00:03:10.940 +Adding properties + +00:03:10.940 --> 00:03:24.660 +Deleting an overlay + +00:03:24.660 --> 00:03:59.340 +Setting fonts the right way + +00:03:59.540 --> 00:04:12.580 +More properties + +00:04:12.580 --> 00:04:49.780 +Visibility + +00:04:49.780 --> 00:05:27.820 +Adding text + +00:05:27.820 --> 00:05:45.380 +Custom properties + +00:05:45.380 --> 00:06:36.100 +Notes on properties + +00:06:36.100 --> 00:08:17.680 +Improving C++ compiler output + +00:08:17.680 --> 00:08:30.240 +The problem with C++ error messages + +00:08:30.240 --> 00:08:47.520 +Many standard class templates have defalut arguments + +00:08:47.520 --> 00:09:20.960 +Some types are aliases for longer things, too + +00:09:20.960 --> 00:10:18.240 +Reporting type information accurately means long lines + +00:10:18.240 --> 00:11:49.320 +Emacs can help - Treat C++ type names as just another kind of balanced expression + +00:11:49.320 --> 00:12:22.400 +Add overlays to improve readability + +00:12:22.400 --> 00:12:59.500 +Create a minor mode that runs during compilation + +00:12:59.500 --> 00:14:16.100 +Parsing types as balanced expressions + +00:14:16.100 --> 00:14:52.260 +Indent and fill with overlays - Use ancient "pretty printing" algorithms" + +00:14:52.260 --> 00:15:14.520 +Overlays can mimic line breaks and indentation + +00:15:14.520 --> 00:17:12.660 +Hiding details - Marking depths with overlays + +00:17:12.660 --> 00:18:04.900 +Hiding to a target depth + +00:18:04.900 --> 00:20:10.220 +Demo + +00:20:10.220 --> 00:20:51.220 +Conclusion diff --git a/2023/captions/emacsconf-2023-overlay--improving-compiler-diagnostics-with-overlays--jeff-trull--main.vtt b/2023/captions/emacsconf-2023-overlay--improving-compiler-diagnostics-with-overlays--jeff-trull--main.vtt new file mode 100644 index 00000000..9c948e2b --- /dev/null +++ b/2023/captions/emacsconf-2023-overlay--improving-compiler-diagnostics-with-overlays--jeff-trull--main.vtt @@ -0,0 +1,1319 @@ +WEBVTT captioned by sachac, checked by sachac + +NOTE Introduction + +00:00.000 --> 00:00:04.897 +Hi, I'm Jeff Trull, and today I'm going to talk to you + +00:00:04.898 --> 00:00:08.460 +about improving C++ compiler diagnostics + +00:08.460 --> 00:13.600 +using overlays and other features from Emacs. + +00:13.600 --> 00:15.840 +First an overview of my talk. + +00:15.840 --> 00:00:17.656 +I'm going to cover what overlays are + +00:00:17.657 --> 00:00:19.325 +and how you can use them in code, + +00:00:19.326 --> 00:00:21.478 +then I'm going to talk about C++ + +00:00:21.479 --> 00:00:24.480 +and why its compiler errors can be so onerous. + +00:24.480 --> 00:00:26.750 +Finally, we'll take that information + +00:00:26.751 --> 00:00:28.447 +and build a new minor mode + +00:00:28.448 --> 00:00:33.560 +using overlays and other Emacs features. + +NOTE Overlays and what they can do + +00:33.560 --> 00:35.520 +First of all, overlays. + +00:35.520 --> 00:36.680 +What are they? + +00:36.680 --> 00:00:39.124 +They are objects consisting of a buffer range + +00:00:39.125 --> 00:00:40.400 +and a set of properties. + +00:40.400 --> 00:43.120 +That means that they cover a region in a buffer. + +00:43.120 --> 00:00:45.533 +The properties can be a certain set + +00:00:45.534 --> 00:00:47.344 +of special property names, + +00:00:47.345 --> 00:00:50.288 +in which case they can be used to cause + +00:00:50.289 --> 00:00:52.569 +special effects in the buffer, + +00:00:52.570 --> 00:00:55.660 +but they never change the underlying text. + +00:55.660 --> 00:59.900 +You can use them for things like hiding things. + +00:59.900 --> 00:01:02.886 +So, for example, overlays are working right now + +00:01:02.887 --> 00:01:04.660 +in this window. `org-present`, + +00:01:04.661 --> 00:01:07.595 +the technology I'm using for this presentation, + +00:01:07.596 --> 00:01:10.031 +is hiding the asterisk before every headline, + +00:01:10.032 --> 00:01:12.520 +as well as the things called emphasis markers; + +00:01:12.521 --> 00:01:16.269 +that is, those things that make things look + +00:01:16.270 --> 00:01:20.700 +monospaced for verbatim, or italic, or bold. + +01:20.700 --> 00:01:24.421 +The special characters we use to mark off those sections + +00:01:24.422 --> 00:01:28.940 +are also hidden by `org-present` using overlays. + +01:28.940 --> 00:01:30.601 +But those things are still in the buffer + +00:01:30.602 --> 00:01:31.980 +and they're still visible to code. + +01:31.980 --> 00:01:34.921 +So if I run this little snippet of code down here, + +00:01:34.922 --> 00:01:37.403 +it's going to go up to the headline "Overlays + +00:01:37.404 --> 00:01:40.051 +and what they can do," and it's going to tell us + +00:01:40.052 --> 00:01:41.540 +what's there in the buffer. + +01:41.540 --> 01:45.100 +Let's go down and run this. + +01:45.100 --> 00:01:48.957 +So according to this code, the contents of the buffer + +00:01:48.958 --> 00:01:51.990 +to the left of the headline is a star in a space, + +00:01:51.991 --> 00:01:55.204 +which means that even though we can't see that star, + +00:01:55.205 --> 00:01:58.220 +it's still there, because it's hidden by an overlay. + +01:58.220 --> 02:02.500 +And that's kind of the essence of what overlays are. + +NOTE Simple overlay example - creating an overlay + +02:02.500 --> 02:04.780 +Let's do a simple overlay example. + +02:04.780 --> 00:02:06.719 +We have some text on the right here, + +00:02:06.720 --> 00:02:09.340 +which is a famous poem by William Carlos Williams, + +02:09.340 --> 02:12.180 +which has been the subject of many memes. + +02:12.180 --> 02:17.860 +Let's create an overlay that covers it. + +02:17.860 --> 02:20.700 +I'll go down here and use this snippet of code here. + +02:20.700 --> 00:02:25.918 +We'll go up to the top, and we'll mark everything + +00:02:25.919 --> 00:02:29.540 +between `#+BEGIN_VERSE` and `#+END_VERSE`. + +02:29.540 --> 00:02:33.276 +You can see we've created an overlay + +00:02:33.277 --> 00:02:35.700 +from position 74 to 224. + +NOTE Adding properties + +02:35.700 --> 00:02:38.063 +Now we can take that overlay that we already created + +00:02:38.064 --> 00:02:41.211 +and add a property, in this case a `face` property, + +00:02:41.212 --> 00:02:43.540 +to change the appearance of the text. + +02:43.540 --> 00:02:46.279 +This is a poem, and it's currently using + +00:02:46.280 --> 00:02:48.083 +a face that is monospaced, + +00:02:48.084 --> 00:02:50.491 +and so it looks like a computer program, + +00:02:50.492 --> 00:02:51.900 +even though it's a poem. + +02:51.900 --> 00:02:54.585 +I think it would be nicer to use something + +00:02:54.586 --> 00:02:57.980 +with variable-width font, maybe with some serifs. + +02:57.980 --> 03:01.140 +So let's give that a try. + +03:01.140 --> 03:03.700 +Now you can see that the poem looks quite a bit different. + +03:03.700 --> 03:10.940 +It looks more like what we'd see in a book. + +NOTE Deleting an overlay + +03:10.940 --> 03:13.100 +We can also delete overlays. + +03:13.100 --> 03:15.140 +So I've named this one. + +03:15.140 --> 00:03:17.765 +So we can just go down and run `delete-overlay` + +00:03:17.766 --> 00:03:20.048 +and get rid of it, and it'll go back to + +00:03:20.049 --> 00:03:22.660 +the appearance it had before. + +03:22.660 --> 03:23.660 +And there it is. + +03:23.660 --> 03:24.660 +It's back to normal. + +NOTE Setting fonts the right way + +03:24.660 --> 00:03:28.473 +Now, if you're interested in changing all of the verses + +00:03:28.474 --> 00:03:31.108 +inside an Org Mode file to a different face + +00:03:31.109 --> 00:03:32.785 +or a different font family, + +00:03:32.786 --> 00:03:35.060 +this isn't the way you'd really do it. + +03:35.060 --> 03:37.520 +I'll just show you that real quick. + +03:37.520 --> 00:03:43.471 +The right way is probably to change the `org-verse` face, + +00:03:43.472 --> 00:03:48.868 +which is the face used for all of the verse blocks + +00:03:48.869 --> 00:03:51.620 +inside your Org Mode file. + +03:51.620 --> 03:55.100 +And so this is how you do it here: + +03:55.100 --> 03:56.100 +`face-remap-add-relative`. + +03:56.100 --> 03:58.340 +Let's give it a try. + +03:58.340 --> 03:59.340 +It worked! + +NOTE More properties + +03:59.540 --> 00:04:01.805 +There are more advanced things that you can do + +00:04:01.806 --> 00:04:03.300 +other than just changing fonts. + +04:03.300 --> 00:04:05.543 +There's a whole long list of them in the manual, + +00:04:05.544 --> 00:04:12.580 +but let's talk about the ones we're going to use today. + +NOTE Visibility + +04:12.580 --> 04:17.380 +You can make text invisible, just like `org-present` did. + +04:17.380 --> 04:21.820 +The simplest way is to set the `invisible` property to true, + +04:21.820 --> 04:24.500 +so here's a code snippet that will do that. + +04:24.500 --> 00:04:26.159 +What we're going to do is + +00:04:26.160 --> 00:04:28.966 +go and find the word "plums" inside the poem, + +00:04:28.967 --> 00:04:31.284 +and then we're going to make it invisible + +00:04:31.285 --> 00:04:33.436 +by creating an overlay that covers it, + +00:04:33.437 --> 00:04:36.820 +and then setting the invisible property to true. + +04:36.820 --> 04:37.940 +Boom! + +04:37.940 --> 04:38.940 +It's gone. + +04:38.940 --> 04:39.940 +We've eaten the plums. + +04:39.940 --> 04:42.180 +Visibility is a huge topic and very complicated. + +04:42.180 --> 04:44.220 +There are powerful mechanisms for using it. + +04:44.220 --> 00:04:46.626 +I suggest reading the manual + +00:04:46.627 --> 00:04:49.780 +if you'd like to know more about that. + +NOTE Adding text + +04:49.780 --> 00:04:52.117 +Another thing we can do with properties + +00:04:52.118 --> 00:04:54.980 +is to add text either before or after an overlay. + +04:54.980 --> 00:04:57.347 +Since we've made the word "plums" invisible, + +00:04:57.348 --> 00:05:00.574 +or anything that you make invisible in the buffer, + +00:05:00.575 --> 00:05:02.662 +if you add text then afterwards, + +00:05:02.663 --> 00:05:05.700 +it looks like you've replaced the original words + +05:05.700 --> 05:08.220 +with new words. + +05:08.220 --> 00:05:12.046 +So let's add a property, a `before-string` property, + +00:05:12.047 --> 00:05:14.193 +to the overlay that we used before + +00:05:14.194 --> 00:05:17.137 +to make it seem as though we're eating cherries + +00:05:17.138 --> 00:05:18.180 +instead of plums. + +05:18.180 --> 05:19.180 +Boom! + +05:19.580 --> 05:22.020 +There it is. + +05:22.020 --> 05:27.820 +So that's how you can replace words using overlays. + +NOTE Custom properties + +05:27.820 --> 00:05:29.760 +You can also have custom properties + +00:05:29.761 --> 00:05:31.700 +that you name and then use yourself. + +05:31.700 --> 05:35.320 +For example, you can use it to mark regions in the buffer. + +05:35.320 --> 00:05:38.008 +You can also use it to add information + +00:05:38.009 --> 00:05:41.180 +to regions in the buffer for your own tracking + +05:41.180 --> 05:45.380 +in a minor mode or something like that, which we will use. + +NOTE Notes on properties + +05:45.380 --> 05:49.620 +Finally, two notes on properties. + +05:49.620 --> 00:05:51.950 +We've been talking about overlay properties, + +00:05:51.951 --> 00:05:54.540 +but there's also something called text properties. + +05:54.540 --> 05:57.460 +Text properties are attached to text in a buffer. + +05:57.460 --> 06:00.900 +When you copy that text, the properties come along with it. + +06:00.900 --> 00:06:03.056 +If you modify the properties, + +00:06:03.057 --> 00:06:05.500 +the buffer is considered modified. + +06:05.500 --> 06:08.460 +Org Mode makes heavy use of text properties, + +06:08.460 --> 00:06:11.677 +as we can see by running this little code snippet here, + +00:06:11.678 --> 00:06:14.060 +which is going to tell us the properties + +06:14.060 --> 00:06:16.565 +and the string attached + +00:06:16.566 --> 00:06:20.740 +to the "Some poetry" headline on the right. + +06:20.740 --> 06:23.660 +There's also some controversy regarding performance. + +06:23.660 --> 00:06:25.520 +It may be that text properties + +00:06:25.521 --> 00:06:27.860 +perform better than overlay properties, + +06:27.860 --> 00:06:28.892 +so do some research + +00:06:28.893 --> 00:06:31.060 +if you're going to make heavy use of them. + +06:31.060 --> 06:36.100 +I prefer overlays because they're just easier to use. + +NOTE Improving C++ compiler output + +06:36.100 --> 06:37.540 +C++ compiler output. + +06:37.540 --> 00:06:41.170 +So my day job is C++ programmer, + +00:06:41.171 --> 00:06:46.560 +and although I've been an Emacser for many years, + +00:06:46.561 --> 00:06:52.860 +it can be a little bit of a chore dealing with errors. + +06:52.860 --> 00:06:55.680 +The error messages that come out of the compiler + +00:06:55.681 --> 00:06:57.580 +can be pretty hard to understand. + +06:57.580 --> 00:07:00.537 +This has often been a barrier, + +00:07:00.538 --> 00:07:04.640 +particularly for people who are new to C++. + +07:04.640 --> 07:09.040 +So let's see what that's like. + +07:09.040 --> 00:07:10.559 +I have an example + +00:07:10.560 --> 00:07:14.780 +which is generously supplied by Ben Deane of Intel. + +07:14.780 --> 00:07:17.082 +So let's see what it looks like + +00:07:17.083 --> 00:07:19.313 +when you compile a C++ program + +00:07:19.314 --> 00:07:24.400 +that has a difficult error in it. + +07:24.400 --> 07:27.400 +Okay. + +07:28.400 --> 07:31.400 +Okay. + +07:31.400 --> 07:35.680 +So you see we have a lot of fairly verbose messages. + +07:35.680 --> 07:39.400 +The most verbose one I think is probably here. + +07:39.400 --> 07:41.000 +This one here. + +07:41.000 --> 07:42.000 +These are pretty bad. + +07:42.000 --> 07:43.000 +I think there might be bigger ones. + +07:43.000 --> 00:07:43.720 +Oh, yeah. Here we go. + +00:07:43.721 --> 00:07:44.960 +Here's my favorite one. + +00:07:44.961 --> 00:07:51.063 +You can see... Let's look for specialization... Basically, + +00:07:51.064 --> 00:07:55.178 +this whole section of the buffer here, + +00:07:55.179 --> 00:07:58.228 +that is specifying the specific types + +00:07:58.229 --> 00:08:02.000 +that a function template was instantiated with. + +08:02.000 --> 08:04.000 +And it's a lot there. + +08:04.000 --> 00:08:05.473 +So if you're trying to figure out + +00:08:05.474 --> 00:08:06.817 +what's wrong with your program + +00:08:06.818 --> 00:08:08.884 +and you're looking at something like this, + +00:08:08.885 --> 00:08:11.000 +it can be really, really hard to understand. + +08:11.000 --> 08:12.000 +Okay. + +08:12.000 --> 08:17.680 +Back to our presentation. + +NOTE The problem with C++ error messages + +08:17.680 --> 00:08:20.063 +So it's often this way in C++ + +00:08:20.064 --> 00:08:23.400 +because we compose types from other types. + +08:23.400 --> 00:08:26.216 +They can be long to begin with, + +00:08:26.217 --> 00:08:30.240 +but then a couple of other factors come into play. + +NOTE Many standard class templates have defalut arguments + +08:30.240 --> 08:33.280 +First of all, we can have default template arguments. + +08:33.280 --> 00:08:35.363 +These are arguments you didn't write, + +00:08:35.364 --> 00:08:37.008 +but that are implicitly there + +00:08:37.009 --> 00:08:38.325 +and can sometimes refer + +00:08:38.326 --> 00:08:40.300 +to the arguments that you did write, + +00:08:40.301 --> 00:08:42.440 +which causes them to get a bit bigger, + +00:08:42.441 --> 00:08:47.520 +such as these allocator arguments here and here. + +NOTE Some types are aliases for longer things, too + +08:47.520 --> 08:49.360 +Then there are type aliases. + +08:49.360 --> 00:08:54.014 +For example, `std::string` here expands to + +00:08:54.015 --> 00:08:58.320 +a type with three template arguments. + +08:58.320 --> 00:09:01.940 +So you can imagine, when we combine + +00:09:01.941 --> 00:09:04.733 +those two things together, + +00:09:04.734 --> 00:09:09.763 +our simple vector of maps from strings to ints + +00:09:09.764 --> 00:09:14.257 +becomes this humongous thing here, which... + +00:09:14.258 --> 00:09:17.360 +Let's run the comparison. + +09:18.360 --> 09:20.960 +Yeah. + +NOTE Reporting type information accurately means long lines + +09:20.960 --> 00:09:24.924 +So in summary, to properly understand an error + +00:09:24.925 --> 00:09:27.370 +when you're a C++ programmer + +00:09:27.371 --> 00:09:29.718 +requires knowing the exact types + +00:09:29.719 --> 00:09:32.280 +that were supplied to your function. + +09:32.280 --> 00:09:34.430 +And types are built recursively, + +00:09:34.431 --> 00:09:36.646 +and therefore the types can-- + +00:09:36.647 --> 00:09:40.513 +the correct exact name for the type + +00:09:40.514 --> 00:09:42.776 +can just be really huge + +00:09:42.777 --> 00:09:46.360 +and have many levels and layers to it. + +09:46.360 --> 00:09:48.113 +So when I was trying to understand + +00:09:48.114 --> 00:09:49.466 +the things I'd done wrong, + +00:09:49.467 --> 00:09:52.401 +especially when I was a newer C++ programmer, + +00:09:52.402 --> 00:09:54.570 +but honestly still even recently, + +00:09:54.571 --> 00:09:57.440 +if I was having a really intractable problem, + +09:57.440 --> 00:10:00.123 +I would just copy the entire error message out, + +00:10:00.124 --> 00:10:01.735 +stick it in the scratch buffer, + +00:10:01.736 --> 00:10:03.649 +and then manually reformat it + +00:10:03.650 --> 00:10:05.563 +so I could see what it was telling me + +00:10:05.564 --> 00:10:07.261 +I'd actually called the function + +00:10:07.262 --> 00:10:09.320 +or whatever it was with, the exact type. + +10:09.320 --> 00:10:11.311 +I had to sit there + +00:10:11.312 --> 00:10:13.240 +and go through the whole thing. + +10:13.240 --> 10:15.240 +But there's a better way. + +10:15.240 --> 10:18.240 +Now, anyway. + +NOTE Emacs can help - Treat C++ type names as just another kind of balanced expression + +10:18.240 --> 10:23.960 +So what can Emacs do to help us with this problem? + +10:23.960 --> 00:10:28.870 +First of all, if you think about a type name, + +00:10:28.871 --> 00:10:33.080 +it's a lot like what we call S-expressions + +10:33.080 --> 10:35.480 +or balanced expressions. + +10:35.480 --> 10:38.400 +Lisp code itself is an S-expression. + +10:38.400 --> 00:10:41.464 +It's basically things with parentheses + +00:10:41.465 --> 00:10:44.214 +and little atoms or symbols in it, + +00:10:44.215 --> 00:10:46.520 +or strings or numbers. + +10:46.520 --> 00:10:50.231 +But parenthesized balanced expressions + +00:10:50.232 --> 00:10:55.800 +are things that Emacs was actually built to deal with. + +10:55.800 --> 00:10:58.944 +They were... I found an old manual from 1981, + +00:10:58.945 --> 00:11:02.160 +and the two major modes that they recommended + +11:02.160 --> 00:11:05.765 +or that they actually documented in the manual were + +00:11:05.766 --> 00:11:08.400 +one, assembly language, and two, Lisp. + +11:08.400 --> 00:11:10.652 +They mentioned that there were other modes, + +00:11:10.653 --> 00:11:12.700 +but they didn't say anything about them. + +11:12.700 --> 00:11:14.625 +So Lisp is something + +00:11:14.626 --> 00:11:17.440 +with a really long history with Emacs. + +11:17.440 --> 00:11:19.976 +Balanced expressions and manipulating them + +00:11:19.977 --> 00:11:21.434 +and doing them efficiently + +00:11:21.435 --> 00:11:24.155 +is just a thing that Emacs knows how to do, + +00:11:24.156 --> 00:11:25.640 +and Emacs is good at it. + +11:25.640 --> 00:11:27.705 +There's just a legacy + +00:11:27.706 --> 00:11:31.320 +of algorithms and functions for doing it. + +11:31.320 --> 00:11:33.182 +So we take types, + +00:11:33.183 --> 00:11:37.839 +and we take the angle brackets in the types, + +00:11:37.840 --> 00:11:40.840 +and we get the symbols right. + +11:40.840 --> 00:11:41.814 +Then we can treat them + +00:11:41.815 --> 00:11:44.312 +as though they were balanced expressions or S-expressions, + +00:11:44.313 --> 00:11:49.320 +the same kind that Emacs is really good at handling. + +NOTE Add overlays to improve readability + +11:49.320 --> 00:11:51.979 +Secondly, we can use overlays + +00:11:51.980 --> 00:11:55.260 +to improve the readability of errors. + +11:55.260 --> 00:11:58.012 +We can take long lines and break and indent them + +00:11:58.013 --> 00:12:00.160 +using `before-string`s, so the same thing + +12:00.200 --> 12:03.440 +I used to add "cherries" into the poem. + +12:03.440 --> 00:12:06.611 +We can use that to insert new lines + +00:12:06.612 --> 00:12:08.725 +followed by indentation + +00:12:08.726 --> 00:12:15.160 +and produce a much nicer-looking listing of a type. + +12:15.160 --> 00:12:19.641 +We can also use the `invisible` property + +00:12:19.642 --> 00:12:22.400 +to hide unwanted detail. + +NOTE Create a minor mode that runs during compilation + +12:22.400 --> 12:24.960 +Last of all, we can create a minor mode. + +12:24.960 --> 00:12:27.854 +When we're compiling things in Emacs, + +00:12:27.855 --> 00:12:30.140 +we often use `compilation-mode`. + +12:30.140 --> 00:12:32.097 +`compilation-mode` allows you to install + +00:12:32.098 --> 00:12:33.553 +compilation filters that run + +00:12:33.554 --> 00:12:36.434 +when the compiler is producing output, + +00:12:36.435 --> 00:12:39.980 +and at that time, then, we can add our overlays. + +12:39.980 --> 00:12:42.868 +We can also add in minor-mode commands + +00:12:42.869 --> 00:12:45.757 +that do whatever we want to the keymap. + +00:12:45.758 --> 00:12:48.321 +In this case, we're going to show and hide + +00:12:48.322 --> 00:12:50.176 +lower-level details interactively + +00:12:50.177 --> 00:12:53.906 +so that we can see a simplified version + +00:12:53.907 --> 00:12:59.500 +or a more detailed version of a type, depending on our needs. + +NOTE Parsing types as balanced expressions + +12:59.500 --> 13:03.980 +First of all, parsing types as balanced expressions. + +13:03.980 --> 00:13:05.686 +We need to be able to quickly locate + +00:13:05.687 --> 00:13:07.162 +the boundaries and the contents + +00:13:07.163 --> 00:13:08.500 +of parenthesized expressions, + +13:08.500 --> 13:12.100 +or in this case, expressions in angle brackets. + +13:12.100 --> 00:13:14.995 +We use a syntax table inside Emacs + +00:13:14.996 --> 00:13:18.800 +to allow movement functions like `forward-list` + +00:13:18.801 --> 00:13:21.100 +to jump between matching angle brackets. + +13:21.100 --> 13:23.460 +By default, they're just parentheses. + +13:23.460 --> 13:25.900 +First of all, let's look at our syntax table. + +13:25.900 --> 00:13:29.189 +We're going to add here syntax entries + +00:13:29.190 --> 00:13:33.900 +to handle angle brackets as though they were parentheses. + +13:33.900 --> 00:13:37.247 +Then we have a lot of types + +00:13:37.248 --> 00:13:42.980 +that have colons in them, and those are namespaces in C++. + +13:42.980 --> 00:13:45.766 +By default, Emacs does not recognize them + +00:13:45.767 --> 00:13:49.134 +as parts of symbols, so we're going to tell Emacs + +00:13:49.135 --> 00:13:52.839 +that a colon is something called a symbol constituent, + +00:13:52.840 --> 00:13:54.860 +that it can be part of a name. + +13:54.860 --> 00:13:57.613 +Once we do that, then we can use our functions + +00:13:57.614 --> 00:13:59.442 +like `forward-list`, `backward-word`, + +00:13:59.443 --> 00:14:03.288 +all of the navigation and movement functions that we have + +00:14:03.289 --> 00:14:06.623 +that do things, that do more complicated things + +00:14:06.624 --> 00:14:08.707 +like S-expressions and so on, + +00:14:08.708 --> 00:14:11.485 +can be used now with our angle brackets + +00:14:11.486 --> 00:14:16.100 +and inside of our types. + +NOTE Indent and fill with overlays - Use ancient "pretty printing" algorithms" + +14:16.100 --> 00:14:18.462 +The next thing we can do is + +00:14:18.463 --> 00:14:21.540 +perform indent and fill with overlays. + +14:21.540 --> 00:14:23.735 +We're going to use `before-string` properties + +00:14:23.736 --> 00:14:25.630 +to break lines and create indentation + +00:14:25.631 --> 00:14:28.900 +to make the output look a little better. + +14:28.900 --> 14:35.320 +Today, we fill mostly text and we indent mostly code. + +14:35.320 --> 00:14:37.307 +We fill text in order to prevent it + +00:14:37.308 --> 00:14:39.902 +from running off the side of the right margin, + +00:14:39.903 --> 00:14:43.940 +and we indent code to line up syntactic elements. + +14:43.940 --> 14:47.080 +Back in the day, they had algorithms that could do both. + +14:47.080 --> 14:52.260 +Those are what we're going to leverage. + +NOTE Overlays can mimic line breaks and indentation + +14:52.260 --> 00:14:54.582 +We can use the `before-string` property + +00:14:54.583 --> 00:14:57.760 +to insert a new line in the correct number of spaces + +14:57.760 --> 15:00.240 +to emulate indentation. + +15:00.240 --> 00:15:03.525 +As a simplified example, here's some code + +00:15:03.526 --> 00:15:07.280 +that will indent 4 upon each open angle bracket. + +15:07.280 --> 15:14.520 +Let's give it a try. + +NOTE Hiding details - Marking depths with overlays + +15:14.520 --> 15:18.280 +The next thing we're going to need to do is hide details. + +15:18.280 --> 00:15:22.688 +So we have nested types, and the user is going to want to + +00:15:22.689 --> 00:15:27.371 +be able to reveal lower-level or hide lower-level parts + +00:15:27.372 --> 00:15:30.131 +of the nested type interactively + +00:15:30.132 --> 00:15:35.480 +once we've already reformatted the error messages. + +15:35.480 --> 15:40.440 +Let's see how we can do that using invisible properties. + +15:40.440 --> 00:15:43.992 +The first thing we're going to do is + +00:15:43.993 --> 00:15:46.680 +mark depths within the type. + +15:46.680 --> 00:15:49.328 +When we're originally analyzing and formatting + +00:15:49.329 --> 00:15:51.920 +and doing the indentation and the line breaks, + +15:51.920 --> 00:15:55.071 +at the same time, we're going to go through + +00:15:55.072 --> 00:15:58.817 +and mark the nested levels inside the type names, + +00:15:58.818 --> 00:16:00.840 +just as this diagram shows. + +16:00.840 --> 00:16:03.573 +So depth 1, for example, will be everything + +00:16:03.574 --> 00:16:06.120 +inside the first level of angle brackets. + +16:06.120 --> 00:16:09.038 +Depth 2 will be everything inside the second level, + +00:16:09.039 --> 00:16:09.600 +and so on. + +16:09.760 --> 00:16:12.070 +And then later on, when the users request it, + +00:16:12.071 --> 00:16:16.303 +we can go and look at the depth that they've selected + +00:16:16.304 --> 00:16:19.360 +and then mark those sections invisible. + +16:19.360 --> 16:20.520 +Let's see how that might work. + +16:20.520 --> 00:16:24.022 +First of all, let's delete the overlays + +00:16:24.023 --> 00:16:28.400 +that we already have that created the indentation. + +16:28.400 --> 00:16:32.419 +Now we're going to go and do that marking + +00:16:32.420 --> 00:16:35.740 +with the custom depth properties here. + +16:35.740 --> 00:16:38.760 +To prove that I didn't pull a fast one, + +00:16:38.761 --> 00:16:42.082 +let's go and see what `describe-char` tells us + +00:16:42.083 --> 00:16:44.660 +about the depths inside here. + +16:44.660 --> 16:46.460 +Let's start here. + +16:46.460 --> 16:52.820 +Okay, so inside this part here, `std::string`, + +16:52.820 --> 16:54.980 +There are two overlays. + +16:54.980 --> 00:16:57.780 +One of them is of depth 1, and the other is of depth 2, + +00:16:57.781 --> 00:17:00.601 +which makes sense, because depth 1 is going to be + +00:17:00.602 --> 00:17:02.011 +from about here to here, + +00:17:02.012 --> 00:17:07.660 +and depth 2 is going to be from about here to this area. + +17:07.660 --> 00:17:10.829 +So it's reasonable that there should be two, + +00:17:10.830 --> 00:17:12.660 +and that's what we expect. + +NOTE Hiding to a target depth + +17:12.660 --> 00:17:17.353 +Now that we've marked the nested types with their depths, + +00:17:17.354 --> 00:17:21.380 +let's experiment with hiding details. + +17:21.380 --> 00:17:26.773 +This fragment of code takes a user-supplied depth, + +00:17:26.774 --> 00:17:29.085 +in this case 2, and will hide, + +00:17:29.086 --> 00:17:30.875 +based on those markings + +00:17:30.876 --> 00:17:33.932 +that we've already made on the overlays, + +00:17:33.933 --> 00:17:36.020 +the custom depth properties. + +17:36.020 --> 17:40.020 +We'll take those and apply your requested level of detail. + +17:40.020 --> 17:42.020 +So let's try it out. + +17:42.020 --> 17:43.020 +Depth 2. + +17:43.020 --> 00:17:46.005 +All right, that hid everything under the `std::map`, + +00:17:46.006 --> 00:17:47.260 +so the deepest level. + +17:47.260 --> 17:52.140 +If we make it 1, we should get a level higher than that. + +17:52.140 --> 17:54.540 +So now level 1 and below are hidden. + +17:54.540 --> 17:59.660 +Now if we put it back to 3, it should reveal everything. + +17:59.660 --> 18:04.900 +So that's what we're going to use in our minor mode. + +NOTE Demo + +18:04.900 --> 18:05.900 +Let's have a demo. + +18:05.900 --> 00:18:08.538 +We're going to revisit the initial example + +00:18:08.539 --> 00:18:10.380 +with the minor mode installed. + +18:10.380 --> 00:18:12.101 +Now we're going to have a compilation filter + +00:18:12.102 --> 00:18:13.593 +that will run on every chunk of output + +00:18:13.594 --> 00:18:15.780 +produced by the compiler. + +18:15.780 --> 00:18:17.849 +It's going to add those overlays + +00:18:17.850 --> 00:18:20.420 +with the line breaks and the indentation. + +18:20.420 --> 00:18:22.206 +It's also going to add overlays + +00:18:22.207 --> 00:18:23.880 +that mark up the nested types + +00:18:23.881 --> 00:18:26.220 +with the depths for each region. + +18:26.220 --> 18:31.580 +Let's add the hook for `tspew-mode`. + +18:31.580 --> 18:37.220 +And now we can compile again. + +18:38.220 --> 00:18:41.503 +All right, we can already see + +00:18:41.504 --> 00:18:47.195 +that these things are formatted a little bit better + +00:18:47.196 --> 00:18:49.180 +than they were before. + +18:49.180 --> 18:50.180 +They're not all on one line. + +18:50.180 --> 18:53.580 +Things are getting kind of lined up here. + +18:53.580 --> 19:05.620 +Here's a good example. + +19:05.620 --> 00:19:08.637 +And here's our big ugly one from before + +00:19:08.638 --> 00:19:10.900 +with all the characters in it. + +19:10.900 --> 19:14.500 +Let's try hiding some of this information. + +19:14.500 --> 00:19:17.431 +We'll just slowly decrease the level of detail + +00:19:17.432 --> 00:19:19.740 +and you can see how it works. + +19:19.740 --> 00:19:22.333 +Over here, where there's these ellipses + +00:19:22.334 --> 00:19:25.460 +next to string constant, the "..." there, + +19:25.460 --> 00:19:30.386 +that's where we are starting to hide information + +00:19:30.387 --> 00:19:32.900 +and go to the next level. + +19:32.900 --> 19:36.460 +Hiding more, hiding more, hiding more. + +19:36.460 --> 19:38.220 +Now we can go back and start adding it back. + +19:38.220 --> 00:19:42.736 +You can see here now we just have about four layers, + +00:19:42.737 --> 00:19:45.540 +which is a lot easier to understand. + +19:45.540 --> 00:19:47.733 +And if we start understanding what it is + +00:19:47.734 --> 00:19:52.180 +and we need more detail, we can just increase detail again. + +19:52.180 --> 00:19:55.402 +And every time we increase or decrease detail, + +00:19:55.403 --> 00:19:58.900 +it reformats so it still stays kind of consolidated + +19:58.900 --> 19:59.900 +and nice looking. + +19:59.900 --> 20:01.980 +Let's increase it a little bit more. + +20:02.060 --> 20:04.540 +Okay, so you can see how that worked. + +20:04.540 --> 20:08.340 +Let's go back to our presentation. + +20:08.340 --> 20:10.220 +All right. + +NOTE Conclusion + +20:10.220 --> 00:20:12.996 +In conclusion, we saw how we could solve + +00:20:12.997 --> 00:20:15.367 +a real problem for C++ programmers + +00:20:15.368 --> 00:20:18.534 +by combining several Emacs features: overlays, + +00:20:18.535 --> 00:20:20.489 +compilation mode extensions, + +00:20:20.490 --> 00:20:25.700 +and balanced expression navigation using syntax tables. + +20:25.700 --> 00:20:27.978 +Emacs is often compared unfavorably + +00:20:27.979 --> 00:20:31.460 +to newer IDEs and editors with slicker user interfaces. + +20:32.220 --> 00:20:36.386 +What Emacs has that they don't is powerful abstractions, + +00:20:36.387 --> 00:20:38.862 +tons of libraries, and decades of work + +00:20:38.863 --> 00:20:42.100 +by some of the luminaries in the field of software. + +20:42.100 --> 00:20:45.343 +I think that this project would have been much harder to do + +00:20:45.344 --> 00:20:48.020 +in a prettier but less powerful environment. + +20:48.020 --> 20:50.860 +In short, there's plenty of hope for Emacs. + +20:50.860 --> 20:51.220 +Thank you. diff --git a/2023/info/overlay-after.md b/2023/info/overlay-after.md index 73285e87..6bb8bb97 100644 --- a/2023/info/overlay-after.md +++ b/2023/info/overlay-after.md @@ -1,6 +1,436 @@ <!-- Automatically generated by emacsconf-publish-after-page --> +<a name="overlay-mainVideo-transcript"></a> +# Transcript + +[[!template new="1" text="""Hi, I'm Jeff Trull, and today I'm going to talk to you""" start="00:00:00.000" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""about improving C++ compiler diagnostics""" start="00:00:04.898" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""using overlays and other features from Emacs.""" start="00:00:08.460" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""First an overview of my talk.""" start="00:00:13.600" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""I'm going to cover what overlays are""" start="00:00:15.840" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""and how you can use them in code,""" start="00:00:17.657" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""then I'm going to talk about C++""" start="00:00:19.326" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""and why its compiler errors can be so onerous.""" start="00:00:21.479" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Finally, we'll take that information""" start="00:00:24.480" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""and build a new minor mode""" start="00:00:26.751" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""using overlays and other Emacs features.""" start="00:00:28.448" video="mainVideo-overlay" id="subtitle"]] +[[!template new="1" text="""First of all, overlays.""" start="00:00:33.560" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""What are they?""" start="00:00:35.520" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""They are objects consisting of a buffer range""" start="00:00:36.680" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""and a set of properties.""" start="00:00:39.125" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""That means that they cover a region in a buffer.""" start="00:00:40.400" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""The properties can be a certain set""" start="00:00:43.120" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""of special property names,""" start="00:00:45.534" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""in which case they can be used to cause""" start="00:00:47.345" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""special effects in the buffer,""" start="00:00:50.289" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""but they never change the underlying text.""" start="00:00:52.570" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""You can use them for things like hiding things.""" start="00:00:55.660" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""So, for example, overlays are working right now""" start="00:00:59.900" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""in this window. `org-present`,""" start="00:01:02.887" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""the technology I'm using for this presentation,""" start="00:01:04.661" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""is hiding the asterisk before every headline,""" start="00:01:07.596" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""as well as the things called emphasis markers;""" start="00:01:10.032" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""that is, those things that make things look""" start="00:01:12.521" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""monospaced for verbatim, or italic, or bold.""" start="00:01:16.270" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""The special characters we use to mark off those sections""" start="00:01:20.700" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""are also hidden by `org-present` using overlays.""" start="00:01:24.422" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""But those things are still in the buffer""" start="00:01:28.940" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""and they're still visible to code.""" start="00:01:30.602" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""So if I run this little snippet of code down here,""" start="00:01:31.980" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""it's going to go up to the headline "Overlays""" start="00:01:34.922" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""and what they can do," and it's going to tell us""" start="00:01:37.404" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""what's there in the buffer.""" start="00:01:40.052" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Let's go down and run this.""" start="00:01:41.540" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""So according to this code, the contents of the buffer""" start="00:01:45.100" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""to the left of the headline is a star in a space,""" start="00:01:48.958" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""which means that even though we can't see that star,""" start="00:01:51.991" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""it's still there, because it's hidden by an overlay.""" start="00:01:55.205" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""And that's kind of the essence of what overlays are.""" start="00:01:58.220" video="mainVideo-overlay" id="subtitle"]] +[[!template new="1" text="""Let's do a simple overlay example.""" start="00:02:02.500" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""We have some text on the right here,""" start="00:02:04.780" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""which is a famous poem by William Carlos Williams,""" start="00:02:06.720" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""which has been the subject of many memes.""" start="00:02:09.340" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Let's create an overlay that covers it.""" start="00:02:12.180" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""I'll go down here and use this snippet of code here.""" start="00:02:17.860" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""We'll go up to the top, and we'll mark everything""" start="00:02:20.700" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""between `#+BEGIN_VERSE` and `#+END_VERSE`.""" start="00:02:25.919" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""You can see we've created an overlay""" start="00:02:29.540" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""from position 74 to 224.""" start="00:02:33.277" video="mainVideo-overlay" id="subtitle"]] +[[!template new="1" text="""Now we can take that overlay that we already created""" start="00:02:35.700" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""and add a property, in this case a `face` property,""" start="00:02:38.064" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""to change the appearance of the text.""" start="00:02:41.212" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""This is a poem, and it's currently using""" start="00:02:43.540" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""a face that is monospaced,""" start="00:02:46.280" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""and so it looks like a computer program,""" start="00:02:48.084" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""even though it's a poem.""" start="00:02:50.492" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""I think it would be nicer to use something""" start="00:02:51.900" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""with variable-width font, maybe with some serifs.""" start="00:02:54.586" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""So let's give that a try.""" start="00:02:57.980" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Now you can see that the poem looks quite a bit different.""" start="00:03:01.140" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""It looks more like what we'd see in a book.""" start="00:03:03.700" video="mainVideo-overlay" id="subtitle"]] +[[!template new="1" text="""We can also delete overlays.""" start="00:03:10.940" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""So I've named this one.""" start="00:03:13.100" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""So we can just go down and run `delete-overlay`""" start="00:03:15.140" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""and get rid of it, and it'll go back to""" start="00:03:17.766" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""the appearance it had before.""" start="00:03:20.049" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""And there it is.""" start="00:03:22.660" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""It's back to normal.""" start="00:03:23.660" video="mainVideo-overlay" id="subtitle"]] +[[!template new="1" text="""Now, if you're interested in changing all of the verses""" start="00:03:24.660" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""inside an Org Mode file to a different face""" start="00:03:28.474" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""or a different font family,""" start="00:03:31.109" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""this isn't the way you'd really do it.""" start="00:03:32.786" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""I'll just show you that real quick.""" start="00:03:35.060" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""The right way is probably to change the `org-verse` face,""" start="00:03:37.520" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""which is the face used for all of the verse blocks""" start="00:03:43.472" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""inside your Org Mode file.""" start="00:03:48.869" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""And so this is how you do it here:""" start="00:03:51.620" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""`face-remap-add-relative`.""" start="00:03:55.100" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Let's give it a try.""" start="00:03:56.100" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""It worked!""" start="00:03:58.340" video="mainVideo-overlay" id="subtitle"]] +[[!template new="1" text="""There are more advanced things that you can do""" start="00:03:59.540" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""other than just changing fonts.""" start="00:04:01.806" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""There's a whole long list of them in the manual,""" start="00:04:03.300" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""but let's talk about the ones we're going to use today.""" start="00:04:05.544" video="mainVideo-overlay" id="subtitle"]] +[[!template new="1" text="""You can make text invisible, just like `org-present` did.""" start="00:04:12.580" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""The simplest way is to set the `invisible` property to true,""" start="00:04:17.380" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""so here's a code snippet that will do that.""" start="00:04:21.820" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""What we're going to do is""" start="00:04:24.500" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""go and find the word "plums" inside the poem,""" start="00:04:26.160" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""and then we're going to make it invisible""" start="00:04:28.967" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""by creating an overlay that covers it,""" start="00:04:31.285" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""and then setting the invisible property to true.""" start="00:04:33.437" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Boom!""" start="00:04:36.820" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""It's gone.""" start="00:04:37.940" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""We've eaten the plums.""" start="00:04:38.940" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Visibility is a huge topic and very complicated.""" start="00:04:39.940" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""There are powerful mechanisms for using it.""" start="00:04:42.180" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""I suggest reading the manual""" start="00:04:44.220" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""if you'd like to know more about that.""" start="00:04:46.627" video="mainVideo-overlay" id="subtitle"]] +[[!template new="1" text="""Another thing we can do with properties""" start="00:04:49.780" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""is to add text either before or after an overlay.""" start="00:04:52.118" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Since we've made the word "plums" invisible,""" start="00:04:54.980" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""or anything that you make invisible in the buffer,""" start="00:04:57.348" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""if you add text then afterwards,""" start="00:05:00.575" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""it looks like you've replaced the original words""" start="00:05:02.663" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""with new words.""" start="00:05:05.700" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""So let's add a property, a `before-string` property,""" start="00:05:08.220" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""to the overlay that we used before""" start="00:05:12.047" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""to make it seem as though we're eating cherries""" start="00:05:14.194" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""instead of plums.""" start="00:05:17.138" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Boom!""" start="00:05:18.180" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""There it is.""" start="00:05:19.580" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""So that's how you can replace words using overlays.""" start="00:05:22.020" video="mainVideo-overlay" id="subtitle"]] +[[!template new="1" text="""You can also have custom properties""" start="00:05:27.820" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""that you name and then use yourself.""" start="00:05:29.761" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""For example, you can use it to mark regions in the buffer.""" start="00:05:31.700" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""You can also use it to add information""" start="00:05:35.320" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""to regions in the buffer for your own tracking""" start="00:05:38.009" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""in a minor mode or something like that, which we will use.""" start="00:05:41.180" video="mainVideo-overlay" id="subtitle"]] +[[!template new="1" text="""Finally, two notes on properties.""" start="00:05:45.380" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""We've been talking about overlay properties,""" start="00:05:49.620" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""but there's also something called text properties.""" start="00:05:51.951" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Text properties are attached to text in a buffer.""" start="00:05:54.540" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""When you copy that text, the properties come along with it.""" start="00:05:57.460" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""If you modify the properties,""" start="00:06:00.900" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""the buffer is considered modified.""" start="00:06:03.057" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Org Mode makes heavy use of text properties,""" start="00:06:05.500" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""as we can see by running this little code snippet here,""" start="00:06:08.460" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""which is going to tell us the properties""" start="00:06:11.678" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""and the string attached""" start="00:06:14.060" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""to the "Some poetry" headline on the right.""" start="00:06:16.566" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""There's also some controversy regarding performance.""" start="00:06:20.740" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""It may be that text properties""" start="00:06:23.660" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""perform better than overlay properties,""" start="00:06:25.521" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""so do some research""" start="00:06:27.860" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""if you're going to make heavy use of them.""" start="00:06:28.893" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""I prefer overlays because they're just easier to use.""" start="00:06:31.060" video="mainVideo-overlay" id="subtitle"]] +[[!template new="1" text="""C++ compiler output.""" start="00:06:36.100" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""So my day job is C++ programmer,""" start="00:06:37.540" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""and although I've been an Emacser for many years,""" start="00:06:41.171" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""it can be a little bit of a chore dealing with errors.""" start="00:06:46.561" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""The error messages that come out of the compiler""" start="00:06:52.860" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""can be pretty hard to understand.""" start="00:06:55.681" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""This has often been a barrier,""" start="00:06:57.580" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""particularly for people who are new to C++.""" start="00:07:00.538" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""So let's see what that's like.""" start="00:07:04.640" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""I have an example""" start="00:07:09.040" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""which is generously supplied by Ben Deane of Intel.""" start="00:07:10.560" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""So let's see what it looks like""" start="00:07:14.780" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""when you compile a C++ program""" start="00:07:17.083" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""that has a difficult error in it.""" start="00:07:19.314" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Okay.""" start="00:07:24.400" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Okay.""" start="00:07:28.400" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""So you see we have a lot of fairly verbose messages.""" start="00:07:31.400" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""The most verbose one I think is probably here.""" start="00:07:35.680" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""This one here.""" start="00:07:39.400" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""These are pretty bad.""" start="00:07:41.000" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""I think there might be bigger ones.""" start="00:07:42.000" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Oh, yeah. Here we go.""" start="00:07:43.000" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Here's my favorite one.""" start="00:07:43.721" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""You can see... Let's look for specialization... Basically,""" start="00:07:44.961" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""this whole section of the buffer here,""" start="00:07:51.064" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""that is specifying the specific types""" start="00:07:55.179" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""that a function template was instantiated with.""" start="00:07:58.229" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""And it's a lot there.""" start="00:08:02.000" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""So if you're trying to figure out""" start="00:08:04.000" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""what's wrong with your program""" start="00:08:05.474" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""and you're looking at something like this,""" start="00:08:06.818" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""it can be really, really hard to understand.""" start="00:08:08.885" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Okay.""" start="00:08:11.000" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Back to our presentation.""" start="00:08:12.000" video="mainVideo-overlay" id="subtitle"]] +[[!template new="1" text="""So it's often this way in C++""" start="00:08:17.680" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""because we compose types from other types.""" start="00:08:20.064" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""They can be long to begin with,""" start="00:08:23.400" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""but then a couple of other factors come into play.""" start="00:08:26.217" video="mainVideo-overlay" id="subtitle"]] +[[!template new="1" text="""First of all, we can have default template arguments.""" start="00:08:30.240" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""These are arguments you didn't write,""" start="00:08:33.280" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""but that are implicitly there""" start="00:08:35.364" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""and can sometimes refer""" start="00:08:37.009" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""to the arguments that you did write,""" start="00:08:38.326" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""which causes them to get a bit bigger,""" start="00:08:40.301" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""such as these allocator arguments here and here.""" start="00:08:42.441" video="mainVideo-overlay" id="subtitle"]] +[[!template new="1" text="""Then there are type aliases.""" start="00:08:47.520" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""For example, `std::string` here expands to""" start="00:08:49.360" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""a type with three template arguments.""" start="00:08:54.015" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""So you can imagine, when we combine""" start="00:08:58.320" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""those two things together,""" start="00:09:01.941" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""our simple vector of maps from strings to ints""" start="00:09:04.734" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""becomes this humongous thing here, which...""" start="00:09:09.764" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Let's run the comparison.""" start="00:09:14.258" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Yeah.""" start="00:09:18.360" video="mainVideo-overlay" id="subtitle"]] +[[!template new="1" text="""So in summary, to properly understand an error""" start="00:09:20.960" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""when you're a C++ programmer""" start="00:09:24.925" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""requires knowing the exact types""" start="00:09:27.371" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""that were supplied to your function.""" start="00:09:29.719" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""And types are built recursively,""" start="00:09:32.280" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""and therefore the types can--""" start="00:09:34.431" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""the correct exact name for the type""" start="00:09:36.647" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""can just be really huge""" start="00:09:40.514" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""and have many levels and layers to it.""" start="00:09:42.777" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""So when I was trying to understand""" start="00:09:46.360" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""the things I'd done wrong,""" start="00:09:48.114" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""especially when I was a newer C++ programmer,""" start="00:09:49.467" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""but honestly still even recently,""" start="00:09:52.402" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""if I was having a really intractable problem,""" start="00:09:54.571" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""I would just copy the entire error message out,""" start="00:09:57.440" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""stick it in the scratch buffer,""" start="00:10:00.124" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""and then manually reformat it""" start="00:10:01.736" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""so I could see what it was telling me""" start="00:10:03.650" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""I'd actually called the function""" start="00:10:05.564" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""or whatever it was with, the exact type.""" start="00:10:07.262" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""I had to sit there""" start="00:10:09.320" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""and go through the whole thing.""" start="00:10:11.312" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""But there's a better way.""" start="00:10:13.240" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Now, anyway.""" start="00:10:15.240" video="mainVideo-overlay" id="subtitle"]] +[[!template new="1" text="""So what can Emacs do to help us with this problem?""" start="00:10:18.240" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""First of all, if you think about a type name,""" start="00:10:23.960" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""it's a lot like what we call S-expressions""" start="00:10:28.871" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""or balanced expressions.""" start="00:10:33.080" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Lisp code itself is an S-expression.""" start="00:10:35.480" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""It's basically things with parentheses""" start="00:10:38.400" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""and little atoms or symbols in it,""" start="00:10:41.465" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""or strings or numbers.""" start="00:10:44.215" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""But parenthesized balanced expressions""" start="00:10:46.520" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""are things that Emacs was actually built to deal with.""" start="00:10:50.232" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""They were... I found an old manual from 1981,""" start="00:10:55.800" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""and the two major modes that they recommended""" start="00:10:58.945" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""or that they actually documented in the manual were""" start="00:11:02.160" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""one, assembly language, and two, Lisp.""" start="00:11:05.766" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""They mentioned that there were other modes,""" start="00:11:08.400" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""but they didn't say anything about them.""" start="00:11:10.653" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""So Lisp is something""" start="00:11:12.700" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""with a really long history with Emacs.""" start="00:11:14.626" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Balanced expressions and manipulating them""" start="00:11:17.440" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""and doing them efficiently""" start="00:11:19.977" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""is just a thing that Emacs knows how to do,""" start="00:11:21.435" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""and Emacs is good at it.""" start="00:11:24.156" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""There's just a legacy""" start="00:11:25.640" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""of algorithms and functions for doing it.""" start="00:11:27.706" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""So we take types,""" start="00:11:31.320" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""and we take the angle brackets in the types,""" start="00:11:33.183" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""and we get the symbols right.""" start="00:11:37.840" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Then we can treat them""" start="00:11:40.840" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""as though they were balanced expressions or S-expressions,""" start="00:11:41.815" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""the same kind that Emacs is really good at handling.""" start="00:11:44.313" video="mainVideo-overlay" id="subtitle"]] +[[!template new="1" text="""Secondly, we can use overlays""" start="00:11:49.320" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""to improve the readability of errors.""" start="00:11:51.980" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""We can take long lines and break and indent them""" start="00:11:55.260" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""using `before-string`s, so the same thing""" start="00:11:58.013" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""I used to add "cherries" into the poem.""" start="00:12:00.200" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""We can use that to insert new lines""" start="00:12:03.440" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""followed by indentation""" start="00:12:06.612" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""and produce a much nicer-looking listing of a type.""" start="00:12:08.726" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""We can also use the `invisible` property""" start="00:12:15.160" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""to hide unwanted detail.""" start="00:12:19.642" video="mainVideo-overlay" id="subtitle"]] +[[!template new="1" text="""Last of all, we can create a minor mode.""" start="00:12:22.400" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""When we're compiling things in Emacs,""" start="00:12:24.960" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""we often use `compilation-mode`.""" start="00:12:27.855" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""`compilation-mode` allows you to install""" start="00:12:30.140" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""compilation filters that run""" start="00:12:32.098" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""when the compiler is producing output,""" start="00:12:33.554" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""and at that time, then, we can add our overlays.""" start="00:12:36.435" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""We can also add in minor-mode commands""" start="00:12:39.980" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""that do whatever we want to the keymap.""" start="00:12:42.869" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""In this case, we're going to show and hide""" start="00:12:45.758" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""lower-level details interactively""" start="00:12:48.322" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""so that we can see a simplified version""" start="00:12:50.177" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""or a more detailed version of a type, depending on our needs.""" start="00:12:53.907" video="mainVideo-overlay" id="subtitle"]] +[[!template new="1" text="""First of all, parsing types as balanced expressions.""" start="00:12:59.500" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""We need to be able to quickly locate""" start="00:13:03.980" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""the boundaries and the contents""" start="00:13:05.687" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""of parenthesized expressions,""" start="00:13:07.163" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""or in this case, expressions in angle brackets.""" start="00:13:08.500" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""We use a syntax table inside Emacs""" start="00:13:12.100" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""to allow movement functions like `forward-list`""" start="00:13:14.996" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""to jump between matching angle brackets.""" start="00:13:18.801" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""By default, they're just parentheses.""" start="00:13:21.100" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""First of all, let's look at our syntax table.""" start="00:13:23.460" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""We're going to add here syntax entries""" start="00:13:25.900" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""to handle angle brackets as though they were parentheses.""" start="00:13:29.190" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Then we have a lot of types""" start="00:13:33.900" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""that have colons in them, and those are namespaces in C++.""" start="00:13:37.248" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""By default, Emacs does not recognize them""" start="00:13:42.980" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""as parts of symbols, so we're going to tell Emacs""" start="00:13:45.767" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""that a colon is something called a symbol constituent,""" start="00:13:49.135" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""that it can be part of a name.""" start="00:13:52.840" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Once we do that, then we can use our functions""" start="00:13:54.860" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""like `forward-list`, `backward-word`,""" start="00:13:57.614" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""all of the navigation and movement functions that we have""" start="00:13:59.443" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""that do things, that do more complicated things""" start="00:14:03.289" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""like S-expressions and so on,""" start="00:14:06.624" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""can be used now with our angle brackets""" start="00:14:08.708" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""and inside of our types.""" start="00:14:11.486" video="mainVideo-overlay" id="subtitle"]] +[[!template new="1" text="""The next thing we can do is""" start="00:14:16.100" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""perform indent and fill with overlays.""" start="00:14:18.463" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""We're going to use `before-string` properties""" start="00:14:21.540" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""to break lines and create indentation""" start="00:14:23.736" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""to make the output look a little better.""" start="00:14:25.631" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Today, we fill mostly text and we indent mostly code.""" start="00:14:28.900" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""We fill text in order to prevent it""" start="00:14:35.320" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""from running off the side of the right margin,""" start="00:14:37.308" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""and we indent code to line up syntactic elements.""" start="00:14:39.903" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Back in the day, they had algorithms that could do both.""" start="00:14:43.940" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Those are what we're going to leverage.""" start="00:14:47.080" video="mainVideo-overlay" id="subtitle"]] +[[!template new="1" text="""We can use the `before-string` property""" start="00:14:52.260" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""to insert a new line in the correct number of spaces""" start="00:14:54.583" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""to emulate indentation.""" start="00:14:57.760" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""As a simplified example, here's some code""" start="00:15:00.240" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""that will indent 4 upon each open angle bracket.""" start="00:15:03.526" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Let's give it a try.""" start="00:15:07.280" video="mainVideo-overlay" id="subtitle"]] +[[!template new="1" text="""The next thing we're going to need to do is hide details.""" start="00:15:14.520" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""So we have nested types, and the user is going to want to""" start="00:15:18.280" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""be able to reveal lower-level or hide lower-level parts""" start="00:15:22.689" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""of the nested type interactively""" start="00:15:27.372" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""once we've already reformatted the error messages.""" start="00:15:30.132" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Let's see how we can do that using invisible properties.""" start="00:15:35.480" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""The first thing we're going to do is""" start="00:15:40.440" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""mark depths within the type.""" start="00:15:43.993" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""When we're originally analyzing and formatting""" start="00:15:46.680" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""and doing the indentation and the line breaks,""" start="00:15:49.329" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""at the same time, we're going to go through""" start="00:15:51.920" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""and mark the nested levels inside the type names,""" start="00:15:55.072" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""just as this diagram shows.""" start="00:15:58.818" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""So depth 1, for example, will be everything""" start="00:16:00.840" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""inside the first level of angle brackets.""" start="00:16:03.574" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Depth 2 will be everything inside the second level,""" start="00:16:06.120" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""and so on.""" start="00:16:09.039" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""And then later on, when the users request it,""" start="00:16:09.760" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""we can go and look at the depth that they've selected""" start="00:16:12.071" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""and then mark those sections invisible.""" start="00:16:16.304" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Let's see how that might work.""" start="00:16:19.360" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""First of all, let's delete the overlays""" start="00:16:20.520" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""that we already have that created the indentation.""" start="00:16:24.023" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Now we're going to go and do that marking""" start="00:16:28.400" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""with the custom depth properties here.""" start="00:16:32.420" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""To prove that I didn't pull a fast one,""" start="00:16:35.740" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""let's go and see what `describe-char` tells us""" start="00:16:38.761" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""about the depths inside here.""" start="00:16:42.083" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Let's start here.""" start="00:16:44.660" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Okay, so inside this part here, `std::string`,""" start="00:16:46.460" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""There are two overlays.""" start="00:16:52.820" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""One of them is of depth 1, and the other is of depth 2,""" start="00:16:54.980" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""which makes sense, because depth 1 is going to be""" start="00:16:57.781" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""from about here to here,""" start="00:17:00.602" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""and depth 2 is going to be from about here to this area.""" start="00:17:02.012" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""So it's reasonable that there should be two,""" start="00:17:07.660" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""and that's what we expect.""" start="00:17:10.830" video="mainVideo-overlay" id="subtitle"]] +[[!template new="1" text="""Now that we've marked the nested types with their depths,""" start="00:17:12.660" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""let's experiment with hiding details.""" start="00:17:17.354" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""This fragment of code takes a user-supplied depth,""" start="00:17:21.380" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""in this case 2, and will hide,""" start="00:17:26.774" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""based on those markings""" start="00:17:29.086" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""that we've already made on the overlays,""" start="00:17:30.876" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""the custom depth properties.""" start="00:17:33.933" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""We'll take those and apply your requested level of detail.""" start="00:17:36.020" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""So let's try it out.""" start="00:17:40.020" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Depth 2.""" start="00:17:42.020" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""All right, that hid everything under the `std::map`,""" start="00:17:43.020" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""so the deepest level.""" start="00:17:46.006" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""If we make it 1, we should get a level higher than that.""" start="00:17:47.260" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""So now level 1 and below are hidden.""" start="00:17:52.140" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Now if we put it back to 3, it should reveal everything.""" start="00:17:54.540" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""So that's what we're going to use in our minor mode.""" start="00:17:59.660" video="mainVideo-overlay" id="subtitle"]] +[[!template new="1" text="""Let's have a demo.""" start="00:18:04.900" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""We're going to revisit the initial example""" start="00:18:05.900" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""with the minor mode installed.""" start="00:18:08.539" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Now we're going to have a compilation filter""" start="00:18:10.380" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""that will run on every chunk of output""" start="00:18:12.102" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""produced by the compiler.""" start="00:18:13.594" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""It's going to add those overlays""" start="00:18:15.780" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""with the line breaks and the indentation.""" start="00:18:17.850" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""It's also going to add overlays""" start="00:18:20.420" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""that mark up the nested types""" start="00:18:22.207" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""with the depths for each region.""" start="00:18:23.881" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Let's add the hook for `tspew-mode`.""" start="00:18:26.220" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""And now we can compile again.""" start="00:18:31.580" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""All right, we can already see""" start="00:18:38.220" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""that these things are formatted a little bit better""" start="00:18:41.504" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""than they were before.""" start="00:18:47.196" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""They're not all on one line.""" start="00:18:49.180" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Things are getting kind of lined up here.""" start="00:18:50.180" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Here's a good example.""" start="00:18:53.580" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""And here's our big ugly one from before""" start="00:19:05.620" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""with all the characters in it.""" start="00:19:08.638" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Let's try hiding some of this information.""" start="00:19:10.900" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""We'll just slowly decrease the level of detail""" start="00:19:14.500" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""and you can see how it works.""" start="00:19:17.432" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Over here, where there's these ellipses""" start="00:19:19.740" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""next to string constant, the "..." there,""" start="00:19:22.334" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""that's where we are starting to hide information""" start="00:19:25.460" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""and go to the next level.""" start="00:19:30.387" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Hiding more, hiding more, hiding more.""" start="00:19:32.900" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Now we can go back and start adding it back.""" start="00:19:36.460" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""You can see here now we just have about four layers,""" start="00:19:38.220" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""which is a lot easier to understand.""" start="00:19:42.737" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""And if we start understanding what it is""" start="00:19:45.540" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""and we need more detail, we can just increase detail again.""" start="00:19:47.734" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""And every time we increase or decrease detail,""" start="00:19:52.180" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""it reformats so it still stays kind of consolidated""" start="00:19:55.403" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""and nice looking.""" start="00:19:58.900" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Let's increase it a little bit more.""" start="00:19:59.900" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Okay, so you can see how that worked.""" start="00:20:02.060" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Let's go back to our presentation.""" start="00:20:04.540" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""All right.""" start="00:20:08.340" video="mainVideo-overlay" id="subtitle"]] +[[!template new="1" text="""In conclusion, we saw how we could solve""" start="00:20:10.220" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""a real problem for C++ programmers""" start="00:20:12.997" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""by combining several Emacs features: overlays,""" start="00:20:15.368" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""compilation mode extensions,""" start="00:20:18.535" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""and balanced expression navigation using syntax tables.""" start="00:20:20.490" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Emacs is often compared unfavorably""" start="00:20:25.700" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""to newer IDEs and editors with slicker user interfaces.""" start="00:20:27.979" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""What Emacs has that they don't is powerful abstractions,""" start="00:20:32.220" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""tons of libraries, and decades of work""" start="00:20:36.387" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""by some of the luminaries in the field of software.""" start="00:20:38.863" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""I think that this project would have been much harder to do""" start="00:20:42.100" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""in a prettier but less powerful environment.""" start="00:20:45.344" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""In short, there's plenty of hope for Emacs.""" start="00:20:48.020" video="mainVideo-overlay" id="subtitle"]] +[[!template text="""Thank you.""" start="00:20:50.860" video="mainVideo-overlay" id="subtitle"]] + + + +Captioner: sachac + Questions or comments? Please e-mail [emacsconf-org-private@gnu.org](mailto:emacsconf-org-private@gnu.org?subject=Comment%20for%20EmacsConf%202022%20overlay%3A%20Improving%20compiler%20diagnostics%20with%20overlays) diff --git a/2023/info/overlay-before.md b/2023/info/overlay-before.md index 9b672414..06376cf1 100644 --- a/2023/info/overlay-before.md +++ b/2023/info/overlay-before.md @@ -8,12 +8,40 @@ The following image shows where the talk is in the schedule for Sat 2023-12-02. Format: 21-min talk; Q&A: BigBlueButton conference room <https://media.emacsconf.org/2023/current/bbb-overlay.html> Etherpad: <https://pad.emacsconf.org/2023-overlay> Discuss on IRC: [#emacsconf-dev](https://chat.emacsconf.org/?join=emacsconf,emacsconf-dev) -Status: Ready to stream +Status: Now playing on the conference livestream <div>Times in different timezones:</div><div class="times" start="2023-12-02T18:00:00Z" end="2023-12-02T18:20:00Z"><div class="conf-time">Saturday, Dec 2 2023, ~1:00 PM - 1:20 PM EST (US/Eastern)</div><div class="others"><div>which is the same as:</div>Saturday, Dec 2 2023, ~12:00 PM - 12:20 PM CST (US/Central)<br />Saturday, Dec 2 2023, ~11:00 AM - 11:20 AM MST (US/Mountain)<br />Saturday, Dec 2 2023, ~10:00 AM - 10:20 AM PST (US/Pacific)<br />Saturday, Dec 2 2023, ~6:00 PM - 6:20 PM UTC <br />Saturday, Dec 2 2023, ~7:00 PM - 7:20 PM CET (Europe/Paris)<br />Saturday, Dec 2 2023, ~8:00 PM - 8:20 PM EET (Europe/Athens)<br />Saturday, Dec 2 2023, ~11:30 PM - 11:50 PM IST (Asia/Kolkata)<br />Sunday, Dec 3 2023, ~2:00 AM - 2:20 AM +08 (Asia/Singapore)<br />Sunday, Dec 3 2023, ~3:00 AM - 3:20 AM JST (Asia/Tokyo)</div></div><div><a href="/2023/watch/dev/">Find out how to watch and participate</a></div> +<div class="vid"><video controls preload="none" id="overlay-mainVideo"><source src="https://media.emacsconf.org/2023/emacsconf-2023-overlay--improving-compiler-diagnostics-with-overlays--jeff-trull--main.webm" />captions="""<track label="English" kind="captions" srclang="en" src="/2023/captions/emacsconf-2023-overlay--improving-compiler-diagnostics-with-overlays--jeff-trull--main.vtt" default />"""<track kind="chapters" label="Chapters" src="/2023/captions/emacsconf-2023-overlay--improving-compiler-diagnostics-with-overlays--jeff-trull--main--chapters.vtt" /><p><em>Your browser does not support the video tag. Please download the video instead.</em></p></video>[[!template id="chapters" vidid="overlay-mainVideo" data=""" +00:00.000 Introduction +00:33.560 Overlays and what they can do +02:02.500 Simple overlay example - creating an overlay +02:35.700 Adding properties +03:10.940 Deleting an overlay +03:24.660 Setting fonts the right way +03:59.540 More properties +04:12.580 Visibility +04:49.780 Adding text +05:27.820 Custom properties +05:45.380 Notes on properties +06:36.100 Improving C++ compiler output +08:17.680 The problem with C++ error messages +08:30.240 Many standard class templates have defalut arguments +08:47.520 Some types are aliases for longer things, too +09:20.960 Reporting type information accurately means long lines +10:18.240 Emacs can help - Treat C++ type names as just another kind of balanced expression +11:49.320 Add overlays to improve readability +12:22.400 Create a minor mode that runs during compilation +12:59.500 Parsing types as balanced expressions +14:16.100 Indent and fill with overlays - Use ancient "pretty printing" algorithms" +14:52.260 Overlays can mimic line breaks and indentation +15:14.520 Hiding details - Marking depths with overlays +17:12.660 Hiding to a target depth +18:04.900 Demo +20:10.220 Conclusion +"""]]<div></div>Duration: 20:57 minutes<div class="files resources"><ul><li><a href="https://pad.emacsconf.org/2023-overlay">Open Etherpad</a></li><li><a href="https://media.emacsconf.org/2023/current/bbb-overlay.html">Open public Q&A</a></li><li><a href="https://media.emacsconf.org/2023/emacsconf-2023-overlay--improving-compiler-diagnostics-with-overlays--jeff-trull--expr_depth.svg">Download --expr_depth.svg</a></li><li><a href="https://media.emacsconf.org/2023/emacsconf-2023-overlay--improving-compiler-diagnostics-with-overlays--jeff-trull--final.webm">Download --final.webm (63MB)</a></li><li><a href="https://media.emacsconf.org/2023/emacsconf-2023-overlay--improving-compiler-diagnostics-with-overlays--jeff-trull--intro.vtt">Download --intro.vtt</a></li><li><a href="https://media.emacsconf.org/2023/emacsconf-2023-overlay--improving-compiler-diagnostics-with-overlays--jeff-trull--intro.webm">Download --intro.webm</a></li><li><a href="https://media.emacsconf.org/2023/emacsconf-2023-overlay--improving-compiler-diagnostics-with-overlays--jeff-trull--main--chapters.vtt">Download --main--chapters.vtt</a></li><li><a href="https://media.emacsconf.org/2023/emacsconf-2023-overlay--improving-compiler-diagnostics-with-overlays--jeff-trull--main.opus">Download --main.opus (15MB)</a></li><li><a href="https://media.emacsconf.org/2023/emacsconf-2023-overlay--improving-compiler-diagnostics-with-overlays--jeff-trull--main.vtt">Download --main.vtt</a></li><li><a href="https://media.emacsconf.org/2023/emacsconf-2023-overlay--improving-compiler-diagnostics-with-overlays--jeff-trull--main.webm">Download --main.webm (63MB)</a></li><li><a href="https://media.emacsconf.org/2023/emacsconf-2023-overlay--improving-compiler-diagnostics-with-overlays--jeff-trull--normalized.opus">Download --normalized.opus (18MB)</a></li><li><a href="https://media.emacsconf.org/2023/emacsconf-2023-overlay--improving-compiler-diagnostics-with-overlays--jeff-trull--original.mp4">Download --original.mp4 (349MB)</a></li><li><a href="https://media.emacsconf.org/2023/emacsconf-2023-overlay--improving-compiler-diagnostics-with-overlays--jeff-trull--reencoded.webm">Download --reencoded.webm (60MB)</a></li><li><a href="https://media.emacsconf.org/2023/emacsconf-2023-overlay--improving-compiler-diagnostics-with-overlays--jeff-trull--testdata.org">Download --testdata.org</a></li><li><a href="https://media.emacsconf.org/2023/emacsconf-2023-overlay--improving-compiler-diagnostics-with-overlays--jeff-trull.org">Download .org</a></li><li><a href="https://toobnix.org/w/bDou9TDETryMt18KcdB56A">View on Toobnix</a></li></ul></div></div> # Description <!-- End of emacsconf-publish-before-page -->
\ No newline at end of file |