WEBVTT 00:00:04.080 --> 00:00:07.359 All right, then. Well, hello everyone. 00:00:07.359 --> 00:00:11.519 I hope you're all enjoying the EmacsConf. 00:00:11.519 --> 00:00:15.040 My name is Musa Al-hassy, and I hope you're 00:00:15.040 --> 00:00:19.840 excited to learn about powering up special blocks. 00:00:19.840 --> 00:00:25.574 Let's first off find out what these special blocks are, 00:00:25.574 --> 00:00:27.920 and see what we can go from. 00:00:27.920 --> 00:00:30.240 Yesterday, I saw a lot of cool talks 00:00:30.240 --> 00:00:33.200 and people were chatting about 00:00:33.200 --> 00:00:37.200 how should you present? Should you do it this way or that way? 00:00:37.200 --> 00:00:39.931 I thought maybe I should try a different way. 00:00:39.931 --> 00:00:42.567 But I'm talking about special blocks 00:00:42.567 --> 00:00:45.039 and if I show you an Emacs, then I have to export 00:00:45.039 --> 00:00:47.840 the HTML so you can see what it looks like 00:00:47.840 --> 00:00:51.920 or export to a PDF so you can see what it looks like. 00:00:51.920 --> 00:00:54.239 So I ended up writing in org-reveal, 00:00:54.239 --> 00:00:58.233 and joyously, this just works. 00:00:58.960 --> 00:01:00.879 You can just see things here. 00:01:00.879 --> 00:01:03.452 I was worried that I'd have to take pictures 00:01:03.452 --> 00:01:09.760 and then insert pings, so that was a delight. 00:01:09.760 --> 00:01:15.704 Okay. Special blocks are these things like a center small quote. 00:01:15.704 --> 00:01:17.280 That's what a special block is, 00:01:17.280 --> 00:01:19.733 and with a bit of Lisp, we can make 00:01:19.733 --> 00:01:22.741 special blocks and link types. 00:01:22.741 --> 00:01:24.799 Right. Using a single interface. 00:01:24.799 --> 00:01:27.344 The interface is going to be similar 00:01:27.344 --> 00:01:29.281 to one many people are familiar with. 00:01:29.281 --> 00:01:34.712 In particular, Org Babel's src interface 00:01:34.712 --> 00:01:37.840 as well as using global header arguments for link types. 00:01:37.840 --> 00:01:39.450 The idea is to write it once 00:01:39.450 --> 00:01:41.200 and generate many different kinds. 00:01:41.200 --> 00:01:45.213 You write in Org markup and you can have HTML, 00:01:45.213 --> 00:01:49.767 you can have PDF, and joyously, org-reveal. 00:01:49.767 --> 00:01:53.600 That was an unexpected delight. 00:01:53.600 --> 00:01:57.840 Here are a few that you'll just see 00:01:57.840 --> 00:02:01.759 in this presentation. 00:02:01.759 --> 00:02:05.040 I won't show some of these link-only ones, 00:02:05.040 --> 00:02:06.799 but we'll see a few of these other ones 00:02:06.799 --> 00:02:09.500 just to make the presentation look nice 00:02:09.500 --> 00:02:11.520 So the presentation is really going to 00:02:11.520 --> 00:02:14.000 present these blocks and the mechanism 00:02:14.000 --> 00:02:15.120 at the same time. 00:02:15.120 --> 00:02:18.400 No HTML was written. 00:02:18.400 --> 00:02:21.280 Look, Ma! No HTML, just pure Org Mode, 00:02:21.280 --> 00:02:25.840 and you get all these beautiful boxes and things. 00:02:25.840 --> 00:02:27.680 The motivation for this is... 00:02:29.120 --> 00:02:31.200 you're online, you run into a blog, 00:02:31.200 --> 00:02:32.120 and you see something you like, 00:02:32.120 --> 00:02:33.120 and you're like, man, 00:02:33.120 --> 00:02:36.640 you know, I wish I could produce that. 00:02:36.640 --> 00:02:41.639 But you check, and the author wrote raw HTML. 00:02:41.639 --> 00:02:44.239 You know, #+HTML: everywhere. 00:02:44.239 --> 00:02:49.533 That's going to obscure your real content. 00:02:49.533 --> 00:02:51.200 It's going to be surrounded by all this 00:02:51.200 --> 00:02:54.239 styling information. That's unfortunate. 00:02:54.239 --> 00:02:57.033 The author decides to use an Org macro. 00:02:57.033 --> 00:02:58.959 All right, a bit better, 00:02:58.959 --> 00:03:00.333 but then what if you decide, 00:03:00.333 --> 00:03:04.667 hey I want to make a PDF? Not great. 00:03:04.667 --> 00:03:06.000 And then the worst of all, 00:03:06.000 --> 00:03:07.840 the author doesn't give you the source, 00:03:07.840 --> 00:03:10.159 and then you have to view page source, 00:03:10.159 --> 00:03:13.760 and learn cascading style sheets, 00:03:14.239 --> 00:03:15.767 and sit in a corner and cry, 00:03:15.767 --> 00:03:18.080 and decide to do other things with your life. 00:03:18.080 --> 00:03:22.640 We want to give you Org users numerous styles 00:03:22.640 --> 00:03:27.200 and an extensible mechanism to add more of these 00:03:27.200 --> 00:03:28.799 aesthetically pleasing styles, 00:03:28.799 --> 00:03:31.200 to have really nice things 00:03:31.200 --> 00:03:33.933 look one way in the HTML 00:03:33.933 --> 00:03:36.567 and look almost the same way in the PDF 00:03:36.567 --> 00:03:38.667 and other back ends. 00:03:38.667 --> 00:03:41.680 And if by having these newer ones, 00:03:41.680 --> 00:03:45.519 people might be encouraged to try making new ones, 00:03:45.519 --> 00:03:49.040 especially when the interface is not so difficult, 00:03:49.040 --> 00:03:54.159 that's the aim. 00:03:54.159 --> 00:03:59.120 So let's have a real story to motivate this even more. 00:03:59.120 --> 00:04:03.533 Here's three friends. I hope I don't butcher their names, 00:04:03.533 --> 00:04:04.640 but these friends are called 00:04:04.640 --> 00:04:08.720 Amin, Sacha, and Corwin. They're organizing a conference, 00:04:08.720 --> 00:04:12.080 EmacsConf 2020. 00:04:12.080 --> 00:04:14.239 So Sacha decides to write an Org file 00:04:14.239 --> 00:04:16.479 and she would like some feedback. 00:04:16.479 --> 00:04:19.840 Okay. Just to make it clear, there's no... 00:04:19.840 --> 00:04:22.960 just how easy this looks, 00:04:22.960 --> 00:04:27.280 let's look at the source for this block. 00:04:27.280 --> 00:04:30.720 Notice it's just the word "green," then a colon, 00:04:30.720 --> 00:04:37.333 then Amin. No div style coloring, 00:04:37.333 --> 00:04:38.479 just green:Amin. 00:04:38.479 --> 00:04:41.520 A very pleasant Org markup. 00:04:41.520 --> 00:04:44.960 So that's quite nice. Put some bold around it. 00:04:44.960 --> 00:04:46.433 Not too difficult. 00:04:46.433 --> 00:04:49.900 Hopefully, this will be useful to other people as well. 00:04:49.900 --> 00:04:52.240 So what kind of feedback 00:04:52.240 --> 00:04:55.233 would Sacha expect to get? 00:04:55.233 --> 00:04:59.120 Maybe she would expect top-level remarks 00:04:59.120 --> 00:05:00.833 visible in the export. 00:05:00.833 --> 00:05:04.400 When she makes an HTML, she can see right there a big block. 00:05:04.400 --> 00:05:09.533 Right. Maybe Amin will suggest to Sacha, 00:05:09.533 --> 00:05:11.120 please replace this part 00:05:11.120 --> 00:05:12.267 with this other part 00:05:12.267 --> 00:05:13.333 or replace this word 00:05:13.333 --> 00:05:14.639 with this other word. 00:05:14.639 --> 00:05:16.960 This is not really possible 00:05:16.960 --> 00:05:21.919 with raw HTML or with even LaTeX. 00:05:21.919 --> 00:05:24.000 You'd have to have multiple arguments: 00:05:24.000 --> 00:05:25.360 the first argument, and then 00:05:25.360 --> 00:05:28.800 the replacement argument. It's a bit clunky. 00:05:28.800 --> 00:05:32.080 But with our setup, you just write some text, 00:05:32.080 --> 00:05:34.367 write #+replace_with 00:05:34.367 --> 00:05:36.240 and then write more text, and you're good to go. 00:05:36.240 --> 00:05:39.440 Normal Org markup. 00:05:39.440 --> 00:05:40.720 Everyone speaks different languages. 00:05:40.720 --> 00:05:43.833 Maybe they want to use one word, 00:05:43.833 --> 00:05:45.919 or they're arguing about 00:05:45.919 --> 00:05:48.000 whether we talk about frames or windows, 00:05:48.000 --> 00:05:50.560 so maybe they want to have some translations. 00:05:50.560 --> 00:05:53.433 So there are different kinds of feedback. 00:05:53.433 --> 00:05:55.360 Let's take an example. 00:05:55.360 --> 00:05:59.360 Look at what they are. 00:05:59.360 --> 00:06:02.560 For example, Sacha might write 00:06:02.560 --> 00:06:06.160 this Org Mode right here, 00:06:06.160 --> 00:06:09.759 and then in her HTML exports, you might see this, 00:06:09.759 --> 00:06:12.733 and her feedback might look really nicely 00:06:12.733 --> 00:06:13.840 from anyone who says 00:06:14.560 --> 00:06:17.400 let's do some Lisp instead of mathematics. 00:06:17.400 --> 00:06:18.560 Let's just do some Lisp. 00:06:18.560 --> 00:06:22.479 Corwin says, let's not be so silly. 00:06:22.479 --> 00:06:25.120 Let's just say 9 a.m. and move on. 00:06:28.080 --> 00:06:31.360 Amin likes to export to PDF, 00:06:31.360 --> 00:06:34.333 and so he writes his top-level remarks using LaTeX. 00:06:34.333 --> 00:06:36.900 That's how. To get this square 00:06:36.900 --> 00:06:38.960 Amin: please change whatever, 00:06:38.960 --> 00:06:43.120 he might write like this: #+latex:. 00:06:43.120 --> 00:06:50.880 But then Sacha only exports to HTML, for example, 00:06:50.880 --> 00:06:54.880 so she doesn't look at the PDF, 00:06:54.880 --> 00:06:57.867 and she may not see his top-level feedback 00:06:57.867 --> 00:07:00.667 with those nice brackets and and bold. 00:07:00.667 --> 00:07:03.120 She might think everything's good. 00:07:03.120 --> 00:07:06.160 That can be a bit disastrous. 00:07:06.160 --> 00:07:08.600 So maybe Sacha will then 00:07:08.600 --> 00:07:13.199 make some of her own feedback. 00:07:13.199 --> 00:07:16.160 To produce it, she might write 00:07:16.560 --> 00:07:21.680 HTML commands, #+html: to get that. 00:07:21.680 --> 00:07:24.100 But then Amin will make a PDF, 00:07:24.100 --> 00:07:25.680 and this won't stick out. 00:07:25.680 --> 00:07:28.367 So he might think everything's okay, 00:07:28.367 --> 00:07:30.160 even though it's not. 00:07:30.160 --> 00:07:33.100 Then Corwin actually decides, 00:07:33.100 --> 00:07:35.900 "Hey, let me read the exported result 00:07:35.900 --> 00:07:38.867 and there's all those feedback from two people 00:07:38.867 --> 00:07:42.633 who haven't read anything, because maybe they were in a rush, 00:07:42.633 --> 00:07:45.167 and didn't see the top-level feedback. 00:07:45.167 --> 00:07:50.000 So they agree. "Hey, let's have a uniform Org interface that exports 00:07:50.000 --> 00:07:52.567 to both HTML and PDF. 00:07:52.567 --> 00:07:54.080 Make both of us happy." 00:07:54.080 --> 00:07:58.160 Okay. So they decide to use Org special blocks. 00:07:58.160 --> 00:08:01.300 Right. To set this up, 00:08:01.300 --> 00:08:04.400 they need to read a little bit of Lisp, 00:08:04.400 --> 00:08:08.879 hooks, advice, macros to get all of this set up, 00:08:08.879 --> 00:08:12.319 and then they'll use Org as the main interface. 00:08:12.319 --> 00:08:16.479 It's a lot of work, but it's worth it, right? maybe? 00:08:16.479 --> 00:08:19.360 But then Corwin's a bit terse. 00:08:19.759 --> 00:08:24.333 Corwin maybe doesn't want to write using blocks. 00:08:24.333 --> 00:08:26.080 He thinks they're overkill. 00:08:26.080 --> 00:08:32.560 Sacha wants HTML, and Amin wants PDF, and Corwin wants org-reveal. 00:08:32.560 --> 00:08:35.533 So now they have to reformat all their code. 00:08:35.533 --> 00:08:36.900 And then they need to use org link types 00:08:36.900 --> 00:08:38.867 to reduce the overkill, 00:08:38.867 --> 00:08:41.367 so they can try to avoid duplication 00:08:41.367 --> 00:08:46.800 by factoring things out into self-contained functions. 00:08:46.800 --> 00:08:50.320 But now, to set up our links, 00:08:50.320 --> 00:08:55.467 we'll have to learn a new interface, org setup link. 00:08:55.467 --> 00:09:02.160 Learn a little bit about fonts, follow links, export handlers... 00:09:02.160 --> 00:09:05.040 It's so much. That's so much. But then, 00:09:05.040 --> 00:09:06.800 the friends, they learn a lot. 00:09:06.800 --> 00:09:08.399 They learn about defun. 00:09:08.399 --> 00:09:11.120 So these words are red. 00:09:11.120 --> 00:09:12.185 You get a little explanation. 00:09:12.185 --> 00:09:14.320 I think it's a bit too small for anyone to read. 00:09:14.320 --> 00:09:18.000 This is Lisp documentation for defun. 00:09:18.000 --> 00:09:21.600 advice-add. There's some Lisp documentation. 00:09:21.600 --> 00:09:23.600 They learn about destructuring -let. 00:09:23.600 --> 00:09:25.279 This is from the dash library. 00:09:25.279 --> 00:09:26.959 Here's all that glorious, 00:09:26.959 --> 00:09:28.800 glorious documentation with examples. 00:09:28.800 --> 00:09:30.300 Sorry. I like that. 00:09:30.300 --> 00:09:32.467 They might make an ad-hoc mechanism 00:09:32.467 --> 00:09:35.400 to simulate arguments for special blocks, 00:09:35.400 --> 00:09:38.500 so something maybe called extract-arguments, 00:09:38.500 --> 00:09:41.533 and then, of course, to make new link types, 00:09:41.533 --> 00:09:42.480 they have to learn about 00:09:42.480 --> 00:09:47.400 org-link-set-parameters and its numerous bits and pieces. 00:09:49.920 --> 00:09:53.600 Let's close all these ones down. 00:09:53.600 --> 00:09:55.800 Of course they also need to be comfortable 00:09:55.800 --> 00:09:59.920 with loops and maps and matching and string functions. 00:09:59.920 --> 00:10:02.560 So it's a bit of a pain. 00:10:03.360 --> 00:10:05.839 It's probably not worth it. 00:10:05.839 --> 00:10:07.767 Maybe I'll just rush things quickly, 00:10:07.767 --> 00:10:09.360 or do it ad-hoc... 00:10:10.320 --> 00:10:13.680 We have things to do. 00:10:13.680 --> 00:10:19.367 But maybe the squad wants to have a modular and unified interface 00:10:19.367 --> 00:10:23.700 so everyone's comfortable with defun to define a function 00:10:23.700 --> 00:10:29.440 and they say, "It would be nice if we could just define simultaneously 00:10:29.440 --> 00:10:32.959 both a block and the link type." 00:10:32.959 --> 00:10:36.000 That way, we have a single interface 00:10:36.000 --> 00:10:37.867 Org mode, for these things. 00:10:37.867 --> 00:10:39.767 It would be nice if it was modular. 00:10:39.767 --> 00:10:44.633 If I defined a one kind of block and you defined another, 00:10:44.633 --> 00:10:45.519 we could compose them, 00:10:45.519 --> 00:10:49.360 then get a nice bigger block, like LEGO. 00:10:49.360 --> 00:10:52.320 That would be nice. Building blocks. 00:10:52.320 --> 00:10:56.240 This is what we have come up with, called defblock. 00:10:56.240 --> 00:11:01.760 It also has a long documentation string containing examples and things. 00:11:01.760 --> 00:11:04.800 So that way, it can try to be useful. 00:11:04.800 --> 00:11:10.880 Let's look at a solution to these friends' trilemma. 00:11:10.880 --> 00:11:14.320 So here's a way to define a block. 00:11:14.320 --> 00:11:22.320 It doesn't look that difficult, but this is how they can define a block 00:11:22.320 --> 00:11:25.920 for their top-level feedback. 00:11:25.920 --> 00:11:28.959 Let's look at the three main parts together. 00:11:28.959 --> 00:11:31.233 It's not that difficult, I hope. 00:11:31.233 --> 00:11:35.300 Just six lines, and that's including a documentation string, 00:11:35.300 --> 00:11:37.633 newlines and things. 00:11:37.633 --> 00:11:43.300 So in line 1, we define the block just like you define a function. 00:11:43.300 --> 00:11:44.880 We define a block. 00:11:44.880 --> 00:11:47.433 The block name is going to be called "feedback." 00:11:47.433 --> 00:11:49.680 It has an author, "who." 00:11:49.680 --> 00:11:54.133 The author has no default value. 00:11:54.133 --> 00:11:57.760 It has a color, and the color has a default value of red. 00:11:57.760 --> 00:12:01.680 So just as when you define functions, 00:12:01.680 --> 00:12:06.233 you start by define or defblock, 00:12:06.233 --> 00:12:13.440 then the name, some mandatory argument, and some optional arguments. 00:12:13.440 --> 00:12:18.480 Then the next stage is definition. Documentation. 00:12:18.480 --> 00:12:20.133 The people who use this, 00:12:20.133 --> 00:12:22.880 which are future you or future me, 00:12:22.880 --> 00:12:25.519 might want to know what this is. 00:12:25.519 --> 00:12:27.839 So let's get to document this. 00:12:27.839 --> 00:12:32.079 For Corwin, who might want to use tooltips... 00:12:32.079 --> 00:12:37.120 When Corwin writes feedback in Emacs, they'll see a nice little tooltip, 00:12:37.120 --> 00:12:38.639 and the tooltip will have 00:12:38.639 --> 00:12:41.279 this documentation string. 00:12:41.279 --> 00:12:43.279 That'll be nice. 00:12:43.279 --> 00:12:45.980 And then here's the third part. 00:12:45.980 --> 00:12:48.067 The last three lines are not so difficult. 00:12:48.067 --> 00:12:52.800 If the backend is HTML, 00:12:52.800 --> 00:12:55.360 please use this template string. 00:12:55.360 --> 00:12:57.440 Otherwise, use the other string. 00:12:57.440 --> 00:13:01.279 For each of these string markers, 00:13:01.279 --> 00:13:04.959 please put in the color, who wrote it, and then the contents 00:13:04.959 --> 00:13:07.279 of the special block or the link type. 00:13:08.160 --> 00:13:11.600 So that's pretty neat. Not so difficult. 00:13:11.600 --> 00:13:14.639 I thought that was kind of cool, 00:13:14.639 --> 00:13:16.600 then noticed it's anaphoric. 00:13:16.600 --> 00:13:21.033 This defblock gives you two new names. 00:13:21.033 --> 00:13:23.433 It gives you a name called contents, 00:13:23.433 --> 00:13:26.480 and it gives you a name called backend. 00:13:26.480 --> 00:13:29.733 So even if you're writing a defblock 00:13:29.733 --> 00:13:32.560 and you intend it to be used only for links... 00:13:32.560 --> 00:13:35.440 Like these colors, for example. 00:13:35.440 --> 00:13:38.399 These colors were defined using defblock. 00:13:38.399 --> 00:13:41.279 I used them as links right here. 00:13:41.279 --> 00:13:43.360 You don't need to worry 00:13:43.360 --> 00:13:45.300 where does the text come from in the link. 00:13:45.300 --> 00:13:48.959 If I say "red:Bob," is it Bob? 00:13:48.959 --> 00:13:52.000 Or if I put a description, is it the description? 00:13:52.000 --> 00:13:54.000 So it's whatever is available will 00:13:54.000 --> 00:13:56.720 become the value of contents. 00:13:56.720 --> 00:13:59.199 If you're really interested 00:13:59.199 --> 00:14:02.433 and you want to do some intricate stuff, 00:14:02.433 --> 00:14:06.933 defblock also gives you something called raw-contents, 00:14:06.933 --> 00:14:08.633 if you really want to touch 00:14:08.633 --> 00:14:12.639 the raw contents with all of the Org markups still there. 00:14:12.639 --> 00:14:19.440 Let's see how everyone can communicate amongst themselves 00:14:19.440 --> 00:14:22.480 using this new interface. 00:14:22.480 --> 00:14:26.000 So, Sacha speculates and she... How does 00:14:26.000 --> 00:14:28.399 she speculate for her Org HTML? 00:14:28.399 --> 00:14:33.733 She might just write. Hey look at that, no HTML, nice. 00:14:34.800 --> 00:14:36.833 Amin wants to have some green, 00:14:36.833 --> 00:14:39.600 and so he just says, hey here's some color green. 00:14:39.600 --> 00:14:42.959 There you go. It looks almost the same. 00:14:42.959 --> 00:14:48.267 Notice that the main argument is right here. 00:14:48.267 --> 00:14:49.680 defblock took an author, 00:14:49.680 --> 00:14:51.333 and here's the author again. 00:14:51.333 --> 00:14:53.920 And now the optional argument 00:14:53.920 --> 00:14:57.007 uses the org babel source interface 00:14:57.007 --> 00:15:02.867 You just say :, then a key, and then the argument. Quite nice. 00:15:02.867 --> 00:15:07.920 Corwin doesn't want to use blocks. It's a bit of an overkill. 00:15:07.920 --> 00:15:12.959 He can just write a link. 00:15:12.959 --> 00:15:17.440 So the main argument is now the label of the link, 00:15:17.440 --> 00:15:23.667 and the description of the link is the contents of the feedback. 00:15:23.667 --> 00:15:25.680 So that was quite nice. 00:15:25.680 --> 00:15:29.360 So it looks like everyone uses the same interface on the left 00:15:29.360 --> 00:15:32.800 and can have varying outputs. 00:15:32.800 --> 00:15:34.480 I think it looks quite nice, 00:15:34.480 --> 00:15:36.639 and I hope you do too. 00:15:36.639 --> 00:15:38.800 There's a few more. 00:15:38.800 --> 00:15:41.800 Maybe, as you saw in some previous ones, 00:15:41.800 --> 00:15:43.920 we had text side beside side, 00:15:43.920 --> 00:15:47.440 or we folded some regions away. 00:15:47.440 --> 00:15:50.959 We put some things in pretty boxes. 00:15:50.959 --> 00:15:57.120 We had some spoilers at the very beginning that we hid some text. 00:15:57.120 --> 00:16:01.680 We demoed some texts. Here's some Org and here's what it looks like, 00:16:01.680 --> 00:16:05.199 and most importantly, they compose. 00:16:05.199 --> 00:16:12.639 There's a a macro called thread-block. 00:16:12.639 --> 00:16:17.000 thread-block call, and it lets you thread the contents 00:16:17.000 --> 00:16:18.000 through a number of blocks, 00:16:18.000 --> 00:16:20.639 treating them as if they were functions. 00:16:20.639 --> 00:16:22.480 So, really, you can think of a block 00:16:23.680 --> 00:16:25.567 as a string-valued function. 00:16:25.567 --> 00:16:28.533 That's pretty neat, I think. 00:16:28.533 --> 00:16:30.959 Thank you for listening. 00:16:31.759 --> 00:16:34.320 I hope you've enjoyed this little 00:16:34.880 --> 00:16:38.160 happy fun time with the Emacs and friends. 00:16:38.160 --> 00:16:43.730 I'll happily answer questions right now. 00:16:45.360 --> 00:16:49.467 Someone says: "Why did you put optional arguments 00:16:49.467 --> 00:16:50.480 in a separate list 00:16:50.480 --> 00:16:54.560 rather than using cl-style argument lists?" 00:16:54.560 --> 00:16:58.399 So that's a very good question, 00:16:58.399 --> 00:17:00.000 and I will answer that 00:17:00.000 --> 00:17:05.467 by showing you a more involved definition of feedback. 00:17:05.467 --> 00:17:14.567 Let's look at a more involved one right here. 00:17:14.567 --> 00:17:19.280 So, for example, this one is called rremark. 00:17:19.280 --> 00:17:23.439 Please let me know if my text is not sufficiently big. 00:17:23.439 --> 00:17:28.033 Here is why we have two arguments. 00:17:28.033 --> 00:17:30.720 That takes two arguments instead of one 00:17:30.720 --> 00:17:33.360 for its argument list. 00:17:33.360 --> 00:17:34.799 You have def block, 00:17:34.799 --> 00:17:36.000 then you have the name, 00:17:36.000 --> 00:17:40.467 then you have the first argument list 00:17:40.467 --> 00:17:42.880 and the second argument list. 00:17:42.880 --> 00:17:46.080 The first argument list 00:17:46.080 --> 00:17:49.280 takes the text right after the begin. 00:17:49.280 --> 00:17:53.000 The text right after the begin is the main argument. 00:17:53.000 --> 00:17:59.200 And then the remaining key-value pairs are in the second argument list. 00:18:00.320 --> 00:18:03.280 Now the reason we have two is because 00:18:03.280 --> 00:18:08.880 in order to streamline the interface to account for both special blocks 00:18:08.880 --> 00:18:13.360 and Org link types, what we do is we say, 00:18:13.360 --> 00:18:18.000 in the first argument list, you can give a name to the first argument, 00:18:18.000 --> 00:18:19.633 give it a default value, 00:18:19.633 --> 00:18:28.800 and anything else you provide will become part of the link information. 00:18:28.800 --> 00:18:30.861 For example, this link, 00:18:30.861 --> 00:18:32.833 we decided to make its face angry red. 00:18:32.833 --> 00:18:36.433 You might want to give other features to links. 00:18:36.433 --> 00:18:39.100 So we're trying to streamline the interface 00:18:39.100 --> 00:18:41.733 for both special blocks and Org link types, 00:18:41.733 --> 00:18:46.240 and we thought this way was quite nice. 00:18:46.240 --> 00:18:47.500 That was the main reason. 00:18:47.500 --> 00:18:52.480 Someone asks-- 00:18:52.480 --> 00:18:55.039 if you have follow-ups, please ask-- 00:18:55.039 --> 00:18:57.600 Someone asks, "Do you intend to try to 00:18:57.600 --> 00:19:00.559 upstream this amazing work into Org?" 00:19:00.559 --> 00:19:02.300 Well, I'm glad you like it. 00:19:02.300 --> 00:19:04.559 I don't know how to upstream, 00:19:04.559 --> 00:19:06.400 but I will look into it, 00:19:06.400 --> 00:19:09.833 and any advice or guidance would be much appreciated. 00:19:11.840 --> 00:19:15.267 Lisp is awesome. Just as defun is a macro, 00:19:15.267 --> 00:19:17.120 defblock is a macro, and then 00:19:17.120 --> 00:19:20.240 source blocks are awesome. 00:19:20.240 --> 00:19:22.467 Now maybe we can have arguments in special blocks, 00:19:22.467 --> 00:19:28.799 and motivate and encourage more people to learn Lisp. 00:19:28.799 --> 00:19:32.559 So another person asks, 00:19:32.559 --> 00:19:35.280 "What is used to produce colorful 00:19:35.280 --> 00:19:38.559 boxes around the cursor?" 00:19:38.559 --> 00:19:40.400 I'm not quite sure if you're asking... 00:19:40.400 --> 00:19:42.559 Are you talking about my cursor right here, 00:19:42.559 --> 00:19:48.400 or are you talking about in the slide? 00:19:48.400 --> 00:19:53.767 So this cursor is some application called Streambrush, 00:19:53.767 --> 00:19:55.440 that I had to purchase. 00:19:55.440 --> 00:19:59.039 Unfortunately, I could not find a a suitable free one. 00:19:59.039 --> 00:20:03.067 The blocks... I can demonstrate some Emacs Lisp. 00:20:03.067 --> 00:20:04.467 I can open up my Emacs, if people like, 00:20:04.467 --> 00:20:06.320 and we can try some things out. 00:20:06.320 --> 00:20:09.440 Happy to do that. 00:20:09.440 --> 00:20:10.133 You're welcome. 00:20:10.133 --> 00:20:15.520 Someone asks a side question about org-reveal: "How do you get 00:20:15.520 --> 00:20:17.440 bespoke or multiple-column layouts 00:20:17.440 --> 00:20:19.120 without using HTML?" 00:20:19.120 --> 00:20:22.559 Excellent question. That's what we do. 00:20:22.559 --> 00:20:25.533 That's what this project is about. 00:20:25.533 --> 00:20:27.000 So it's not org-reveal, 00:20:27.000 --> 00:20:30.267 it's our fancy parallel block. 00:20:30.267 --> 00:20:33.440 So we have this thing. You say, #+begin_parallel. 00:20:33.440 --> 00:20:35.679 You say how many columns you would like. 00:20:35.679 --> 00:20:37.967 Do you want a bar or not? 00:20:37.967 --> 00:20:39.679 And then you write some text, 00:20:39.679 --> 00:20:44.400 and then you get some text, and according with the bar or not. 00:20:44.400 --> 00:20:47.520 That's how we achieve that in our slides. 00:20:47.520 --> 00:20:52.880 I'm not quite sure where this was. 00:20:52.880 --> 00:20:59.520 Somewhere here, I think. 00:20:59.520 --> 00:21:06.240 Let me try to find this for you. 00:21:06.240 --> 00:21:10.433 I can't seem to find where the parallel blocks were. Apologies. 00:21:10.433 --> 00:21:15.039 Let's move on to the next question, I suppose. 00:21:15.039 --> 00:21:18.400 I'm pretty sure they're here. Ah, there they are. 00:21:18.400 --> 00:21:22.640 So these were just instances of using 00:21:22.640 --> 00:21:26.480 the parallel block, and it makes things parallel. 00:21:26.480 --> 00:21:27.633 So that's quite nice. 00:21:27.633 --> 00:21:33.360 Another person asks, 00:21:33.360 --> 00:21:37.840 "How does this relate to pandoc, 00:21:37.840 --> 00:21:40.960 which is used for converting between markup formats?" 00:21:40.960 --> 00:21:43.919 So all we're doing is we're saying, 00:21:43.919 --> 00:21:47.679 hey, please write Org because Org is just fantastic, 00:21:47.679 --> 00:21:49.267 and we love it, and it's the dream, 00:21:49.267 --> 00:21:51.760 and if you would like to view things 00:21:51.760 --> 00:21:55.900 in HTML, or in org-reveal, or in PDF, 00:21:55.900 --> 00:21:58.559 that's up to the user. 00:22:02.320 --> 00:22:06.080 Made it too small now. So here is an example. 00:22:06.080 --> 00:22:10.240 Here's how parallel is implemented, 00:22:10.240 --> 00:22:14.320 just as a quick example, not too long. 00:22:14.320 --> 00:22:17.800 About half of the implementation is documentation, 00:22:17.800 --> 00:22:22.720 so, hopefully, that speaks for for how useful this feature is. 00:22:22.720 --> 00:22:25.280 We decide if there's a rule or not. 00:22:25.280 --> 00:22:28.080 We look for the column break. 00:22:28.080 --> 00:22:30.600 Here we're looking at the backend. 00:22:30.600 --> 00:22:31.840 If the backend is LaTeX, 00:22:31.840 --> 00:22:34.133 please use this incantation 00:22:34.133 --> 00:22:37.679 with multicolumns, minipages, what have you. 00:22:37.679 --> 00:22:41.600 If the backend is something else, please do this: 00:22:41.600 --> 00:22:48.080 div, style and other gibberish that we don't really want to look at. 00:22:48.080 --> 00:22:51.760 Pandoc works from Org, 00:22:51.760 --> 00:22:53.633 so it might not work directly, 00:22:53.633 --> 00:22:59.679 since our interface... The way we set it up is: when you try to export, 00:22:59.679 --> 00:23:03.039 we hook in and we do a bunch of pre-processing, 00:23:03.039 --> 00:23:07.440 so this defblock is a string-valued function. 00:23:07.440 --> 00:23:13.919 Whenever we see these #+begin_parallel when you do an export, 00:23:13.919 --> 00:23:17.767 I tell Emacs, hold up, look for those #+begin_parallels, please. 00:23:17.767 --> 00:23:20.320 Oh, you found them? Grab that text. 00:23:20.320 --> 00:23:21.533 You grabbed it. Great. 00:23:21.533 --> 00:23:24.080 Now please apply this person's function 00:23:24.080 --> 00:23:27.120 onto that text, and splice in the result. 00:23:27.120 --> 00:23:30.400 So when you export, we're performing 00:23:30.400 --> 00:23:35.120 arbitrary computations on your text. 00:23:35.120 --> 00:23:39.633 Some people might not find that comforting, 00:23:39.633 --> 00:23:43.039 to have arbitrary computations happening. 00:23:43.039 --> 00:23:45.039 In this article, there's a few where 00:23:45.039 --> 00:23:47.167 we change your text upon export. 00:23:47.167 --> 00:23:51.760 We translate it, we do other things to it. 00:23:51.760 --> 00:23:56.500 So someone says, "If you export to LaTeX, to PDF, 00:23:56.500 --> 00:23:58.640 does that work well with Beamer as well 00:23:58.640 --> 00:24:00.320 to create slides with columns?" 00:24:05.200 --> 00:24:08.000 I made a bunch of these changes 00:24:08.000 --> 00:24:09.200 earlier this morning, 00:24:09.200 --> 00:24:12.320 and it just says LaTeX right here. 00:24:12.320 --> 00:24:14.400 So if you want to go to beamer, 00:24:14.400 --> 00:24:15.360 I think the back end for me, 00:24:15.360 --> 00:24:17.333 beamer is called, well, beamer, 00:24:17.333 --> 00:24:22.000 so instead of a pcase, what we would do is, we would say, 00:24:22.000 --> 00:24:27.167 if it's a 'latex or it's a 'beamer, then use this. 00:24:27.167 --> 00:24:30.267 Otherwise, it's not a LaTeX, 00:24:30.267 --> 00:24:31.867 it will simply default to this one, 00:24:31.867 --> 00:24:34.433 which could be dangerous for your needs. 00:24:34.433 --> 00:24:39.167 I think it's a bad practice to put a underscore, 00:24:39.167 --> 00:24:40.767 but I did it really quickly 00:24:40.767 --> 00:24:44.500 because I just wanted to show you that it works fine in org-reveal 00:24:44.500 --> 00:24:47.440 Contributions are more than welcome. 00:24:47.440 --> 00:24:52.240 I happily would love any assistance. 00:24:52.240 --> 00:24:58.633 We have a Lisp reference cheat sheet here 00:24:58.633 --> 00:25:01.000 to learn a little bit about Lisp, if you're not comfortable, 00:25:01.000 --> 00:25:03.267 or to ask some questions. 00:25:03.267 --> 00:25:06.400 Lots of helpful people. 00:25:06.400 --> 00:25:09.440 So there's another question that says, 00:25:09.440 --> 00:25:13.120 "Does typing in a block mess up with syntax highlighting? 00:25:13.120 --> 00:25:15.679 Usually, you use a single color inside an 00:25:15.679 --> 00:25:17.279 example block, for example. 00:25:17.279 --> 00:25:21.279 Ah, you found my crutch. 00:25:25.279 --> 00:25:27.333 Emacs is all encompassing, 00:25:27.333 --> 00:25:29.760 and I'm not quite sure how fonts work. 00:25:29.760 --> 00:25:32.559 I learned enough to get by. 00:25:37.440 --> 00:25:38.667 Here's how links work. 00:25:38.667 --> 00:25:40.799 They're a bit complicated. 00:25:40.799 --> 00:25:42.567 This is a bit scary. 00:25:42.567 --> 00:25:47.039 I don't recommend anyone read it. 00:25:47.039 --> 00:25:49.840 Actually, let me open up an email 00:25:50.559 --> 00:25:52.100 and you can see what I see. 00:25:52.100 --> 00:25:54.799 So here's an Emacs. 00:25:54.799 --> 00:25:56.799 Let's make that a bit bigger. 00:25:56.799 --> 00:25:59.133 Let's change this slightly. 00:25:59.133 --> 00:26:01.200 Nope, that's worse. There you go. 00:26:01.919 --> 00:26:09.360 Here's some words. Here's red hello. 00:26:09.360 --> 00:26:15.679 But you're worried about preserving fontification. 00:26:15.679 --> 00:26:18.480 Let's make an emacs-lisp block. 00:26:18.880 --> 00:26:22.840 Let's say, (+ 1 2). 00:26:22.840 --> 00:26:31.133 Ah, where's the fun? Hello. Bye. 00:26:31.133 --> 00:26:32.080 Okay. Where's the coloring? 00:26:32.080 --> 00:26:36.000 If we zoom in on this #+begin_src block, 00:26:36.000 --> 00:26:39.200 you can see down here 00:26:39.200 --> 00:26:42.159 we have our our coloring 00:26:42.159 --> 00:26:43.279 when we zoom in. 00:26:43.279 --> 00:26:46.960 If we zoom out, no coloring. 00:26:46.960 --> 00:26:50.880 Zoom in, coloring. Zoom out, aah, no coloring. 00:26:50.880 --> 00:26:55.679 Let's take off these bad boys, and oh, look, my coloring's back. 00:26:55.679 --> 00:27:03.760 In a previous iteration of the system, I was able to maintain coloring. 00:27:03.760 --> 00:27:06.400 In this new iteration, I am not. 00:27:06.400 --> 00:27:07.400 I don't know how to do it. 00:27:07.400 --> 00:27:10.333 I haven't had the time to implement it. 00:27:10.333 --> 00:27:17.279 I spent a lot of time writing this 48-page documentation 00:27:17.279 --> 00:27:21.133 with some fun examples to try to help people learn. 00:27:21.133 --> 00:27:23.200 But I would appreciate any help or guidance 00:27:23.200 --> 00:27:26.240 on how to maintain the fontification. 00:27:26.240 --> 00:27:29.200 I really would like to keep those colors in. 00:27:29.200 --> 00:27:32.640 [Amin]: Musa, we have time for maybe one more question, 00:27:32.640 --> 00:27:34.500 one or two more questions, 00:27:34.500 --> 00:27:37.039 and then we have to move on to the next talk. 00:27:37.039 --> 00:27:39.120 You're more than welcome to 00:27:39.120 --> 00:27:42.559 continue taking the questions via IRC or the pad. 00:27:42.559 --> 00:27:45.760 [Musa]: Okay. Thank you. 00:27:45.760 --> 00:27:48.880 The final question we'll take is, 00:27:48.880 --> 00:27:52.320 "Should packages implement 00:27:52.320 --> 00:27:53.967 interface to one specific format, 00:27:53.967 --> 00:27:55.600 or attempt to be inclusive 00:27:55.600 --> 00:27:57.279 to all the potential output targets?" 00:27:57.279 --> 00:27:59.300 I think you should just make them as you go, 00:27:59.300 --> 00:28:01.500 and add them as you need them. 00:28:01.500 --> 00:28:05.600 We'll make Github requests for things. 00:28:05.600 --> 00:28:08.533 We can share recipes in this document, 00:28:08.533 --> 00:28:12.333 and then try to add other techniques, 00:28:12.333 --> 00:28:19.200 and then we can use these blocks as a common interface 00:28:19.200 --> 00:28:22.240 for exporting to PDF and other things. 00:28:22.240 --> 00:28:26.000 Since someone asked, 00:28:26.000 --> 00:28:28.033 here what a PDF looks like. 00:28:28.033 --> 00:28:31.667 This is the same PDF rendered. 00:28:31.667 --> 00:28:34.960 I made no effort to make it look good, 00:28:34.960 --> 00:28:37.840 but it surprisingly does look good. 00:28:38.559 --> 00:28:40.067 That was nice. 00:28:40.067 --> 00:28:44.320 That was a terrible magenta, but that is life. 00:28:44.320 --> 00:28:47.100 Anyhow, I hope you all enjoyed this talk. 00:28:47.100 --> 00:28:51.033 I hope you will find defblock useful to you. 00:28:51.033 --> 00:28:52.799 It is available on MELPA. 00:28:52.799 --> 00:28:56.367 In a rush to make it available for EmacsConf 2020, 00:28:56.367 --> 00:29:00.159 some MELPA guidelines may not have been adhered to. 00:29:00.159 --> 00:29:01.600 Please do not hit me. 00:29:01.600 --> 00:29:08.559 I hope everyone enjoys the rest of the EmacsConf 2020. Thank you!