Quick
index
main
eev
eepitch
maths
angg
blogme
dednat6
littlelangs
PURO
(C2,C3,C4,
 λ,ES,
 GA,MD,
 Caepro,
 textos,
 Chapa 1)

emacs
lua
(la)tex
maxima
git
agda
forth
squeak
icon
tcl
tikz
fvwm
debian
irc
contact

Eev and TikZ, or: how to learn TikZ using a REPL (subtitles)

The main page about this video is here.
Its index is here.
Its subtitles in Lua are here.
The rest of this page contains a conversion of the subtitles in Lua
to a slightly more readable format.


00:01 Hi! My name is Eduardo Ochs, I'm the author
00:04 of an Emacs package called eev, and the name of
00:08 this video is: "Eev and TikZ, or how to
00:11 learn TikZ using a REPL"... and this is a
00:13 picture of me in and a REPL - you can see that
00:16 I'm very happy because I have a REPL
00:18 with me.

00:20 This video complements what is in this
00:23 page here - so I'm going to use lots of
00:26 technical terms that are explained in
00:28 the web page and I'm not going to
00:30 explain them here.
00:36 First of all...
00:39 I tried to learn TikZ the first time
00:42 many years ago, in 2014, and I failed
00:48 miserably, many, many times. I've
00:51 tried it several times, and
00:54 every time I gave up with the
00:57 feeling that my brain was too small for
00:59 learning TikZ.
01:00 And about one month ago I finally found
01:03 a way that worked for me for
01:06 studying TikZ, and it used links to
01:10 the manual - I'm going to show them in
01:13 a minute -

01:15 I mean links to both the PDF of the
01:18 manual and to the source code of the
01:20 manual - a REPL that I can run from Emacs,
01:24 and a way to extract examples from the manual

01:29 Let me show a first example - here.
01:33 This link here -
01:36 I will have to use a smaller font - this
01:39 link here opens my file with notes about
01:42 TikZ. You can see that it's
01:47 very big... it has about 4000 lines at
01:50 this moment, and it's very messy.

01:52 This thing here is an index.
01:56 Some of the sections are good,
01:59 some of the sections are totally crap,
02:01 and whatever ... and this link here goes to
02:04 the section that I want to discuss.

02:09 So, this goes to this section here, about
02:12 horizontal and vertical lines...
02:16 and these first links here point to
02:19 the manual. If I open this one - note that
02:22 it ends with "page" here - it opens the
02:25 page of the manual in the usual sense... in
02:27 the sense that it opens a PDF.
02:29 It opens a PDF of the manual at this
02:32 page, and this is a comment that the
02:36 function
02:38 find-tikzmanpage ignores, so the
02:41 comment is just for humans.

02:44 So, if I execute this...
02:47 it takes a few seconds because the
02:49 the PDF is very big... and it opens the PDF
02:53 on page
02:54 152 and what I'm going to show is
02:58 something related to this example here.

03:02 So the manual explains that
03:05 sometimes we want to connect two points
03:07 via straight lines that are
03:09 only horizontal and vertical and for
03:11 that we can use this notation, -|,
03:13 and this one, |-...
03:16 and it gives this example here. So this
03:18 is the output of the example and this is
03:21 the source code of the example.
03:24 Let me go back/

03:25 If I execute this sexp here...
03:29 it will take several seconds to run
03:32 because it will have to run a
03:34 program called pdftotext to convert
03:38 the PDF to text, and the manual is huge...
03:41 it's about 1300 pages -
03:45 so it takes a while
03:47 and then it is going to go to the page
03:49 152 of the manual
03:52 converted to text - it finds that page by
03:55 counting formfeeds - and then it will
03:58 search for this string here
04:01 in the converted text.
04:11 Here -
04:13 So this is the the name of the command that
04:20 was run to generate the converted
04:23 version,
04:24 and if I do not delete this buffer then
04:27 going back to the manual is very quick. So
04:30 if I execute this again it goes back to
04:32 the manual immediately.

04:35 And note that
04:38 this corresponds to this section of the
04:41 manual here...
04:43 and the first obvious way to extract the
04:47 source code of these example here is to
04:50 simply take this text here,
04:57 copy this to my notes and edit this a
05:00 bit to delete everything from
05:04 this column to the left. And note that
05:07 there's an A and a B here these letters
05:10 are there because here in the manual in
05:13 the example we see an A and a B - here, in
05:16 the image.

05:20 Until a few weeks ago when I was
05:23 extracting examples from the manual I was
05:26 always
05:27 using these conversion to text here, and
05:31 I was editing these things by hand... but
05:35 then I realized that
05:36 maybe I should take a look at the
05:40 source code of the manual, that is a
05:42 huge .tex file,
05:46 and I could try to see how these
05:49 sections and these examples are coded in
05:51 the manual... and it turns out that it's
05:53 very easy to extract the examples from
05:55 the manual.

05:57 If I execute this sexp here - note
06:00 that the suffix is "file" -
06:03 this thing here opens a file with this
06:06 name in a certain directory and searches
06:08 for the first occurrence of this string
06:10 here...
06:12 and what we get
06:14 is this. Here is the one of the files
06:19 of the source code of the manual... here we
06:22 have a listing of everything in this
06:24 directory... so we have lots of files that
06:26 start with pgf-manual-blahblahblah
06:31 and we find a subsubsection with this
06:37 title here...

06:42 and here we have this block,
06:45 that starts with \begin{codeexample} and
06:48 ends with
06:49 \end{codeexample}, and this is exactly the
06:52 the source code that I want, so I realized
06:56 that in many cases it was much easier to
06:59 simply extract
07:00 this code here from the source code of
07:03 the manual and then try to run that code.
07:09 Anyway, let me go back again.

07:12 Remember that I said that I
07:15 found a way of testing the examples in
07:17 the manual using a REPL. This is a demo
07:20 of this this REPL... I'm going to explain
07:22 it in details very soon - now I just want
07:27 to demonstrate how it works.
07:35 if I execute these three lines here
07:38 then eepitch will create a target
07:41 buffer running Lua in the
07:44 right half of this frame it will let's
07:48 do that now. So now we have this...
07:50 And now if I execute this line here
07:54 it will make Lua load a certain file,
08:01 that is the REPL - no, the tricks with the
08:04 REPL that I'm going to explain soon... and
08:08 this thing here defines a drawing in TikZ.
08:13 And when I run this line here - show() - it
08:16 takes a few seconds because it produces
08:19 a .tex file, it saves the .tex file to disk...
08:22 this sexp here visits the .tex file...
08:26 it is just this. So: it has a
08:30 header, a footer, and this thing in the
08:32 middle.

08:36 And it said that, uh...
08:40 The class "Show" compiled the .tex file
08:46 and everything went well - "Success!!!".

08:51 And now I can run this thing here - note
08:53 that this is a red star line, so eepitch
08:59 interprets everything at the right of
09:01 the red star as Lisp, and executes that
09:04 as Lisp... and when I do that
09:07 it will show the PDF: here.
09:11 And the nice thing is that
09:18 I can make changes to this drawing. For
09:21 example, I can change the scale of the
09:24 drawing, and then I can recompile
09:26 everything and show the PDF again...
09:29 and you can see that the PDF is
09:33 always shown here, so it's very easy
09:35 to compare one version with another.
09:39 And by the way I can even
09:43 execute these lines here
09:45 in another order - for example,
09:49 I can execute this one, and then skip the
09:52 second one, and then run the show() and the
09:55 (tikz-show)...
10:01 So... I've just
10:03 changed a parameter in the drawing,
10:08 and I produced a new version and I showed
10:10 the PDF of the new version.
10:12 So this is the way that the REPL works.
10:15 There are several variants of this
10:18 function here that shows the PDF...
10:21 one of the variants is this one -
10:27 I can run (tikz-showtex)
10:33 here... the scale appears here inside of
10:38 the scalebox{...},
10:40 so if I change the scale to 1.5, and I
10:43 save the .tex again, and I run showtex()
10:46 again, this 2 here will change to
10:49 something else - it will change to 1.5.
10:53 Let's see. Pay attention - here -
10:59 ta-da! And now I'm going to show
11:03 how to run... no, how people can test this
11:07 by installing just four files, and
11:11 then I'm going to to show a series of
11:13 exercises that I have prepared for
11:16 people who want to take this more
11:18 seriously and who want to use this tool
11:21 to study TikZ by extracting examples
11:26 from the manual.
11:27 By the way, let me just explain one thing
11:30 that is very interesting and very weird
11:33 that will appear later, that is this line
11:36 here. This function, tiks, is an alias for
11:44 the function... find-tikzsearch-links?
11:48 Oops, I don't remember! Let me try...
11:53 "tiks", with an "s" at the end, is an
11:56 alias for find-tikzsearch-links.
11:59 And when I run this it produces a
12:02 temporary buffer with several sexps
12:04 that I can use for locating an
12:08 example in the manual... I mean, both in
12:11 the PDF of the manual and in the source
12:13 code of the manual...
12:15 and other related things that we are
12:18 going to see soon.
12:21 Let me stop this video... and part 2
12:29 starts in a few seconds.


;; Part 2

12:33 Hi! I'm back. This is the part 2 of the
12:35 video...
12:38 In the page about eev and TikZ
12:41 the section 4 is called "Trying it".
12:45 Let me show it here. Bigger font...
12:52 The instructions are here. We are
12:54 going to copy this thing to a buffer in
12:56 Emacs, but let me just make some comments
13:00 before doing that.
13:03 We are also going to execute a function
13:06 here that will show a certain script,
13:08 that contains tests that we will run...
13:14 The prerequisites are quite minimal - we
13:17 just have to have Emacs, eev, pdf-tools,
13:21 that is a package that is in MELPA,
13:23 Lua, and a TeX distribution with TikZ.
13:30 Let me show how these things work... but
13:33 before showing this let me go back to to
13:37 here and make some comments.
13:40 These red bullets here, they will
13:44 behave as red stars even if they
13:48 do not show in red.
13:50 This is explained here in the main
13:52 tutorial. It says that
13:55 it is possible to make other
13:58 characters play the role of
14:00 the red star, and by default the bullet
14:03 can play the role of the red star...
14:08 And we can run this thing here to make
14:11 the bullets appear in red, but I'm not
14:13 going to do that now. And the second
14:16 comment is that
14:19 lines that start with two red stars are
14:22 treated as comments, and are skipped.
14:26 So, let me copy this thing here to my Emacs -
14:30 sorry to a buffer... I'm running an
14:35 Emacs in a quite minimal setting,
14:39 in a temporary directory... sorry -
14:46 this is the home directory that I'm
14:48 using, so it's a fake home directory with
14:50 just a few things - I have just installed
14:52 PDF tools here...
14:55 and let me copy this script here. I will
14:59 have to use a smaller font...
15:04 note that these bullets do not appear in
15:06 red, but they are going to behave as red
15:09 stars, I promise.
15:11 So, f8 here, three times... creates
15:17 a target buffer running a shell...
15:21 then I'm going to run these things here,
15:23 and here we see four "wget"s...
15:33 and now I'm going to load this file here.
15:36 Note that it corresponds to this file
15:39 here.
15:42 It defines a few functions. One of these
15:44 functions is this one, that just displays
15:48 a temporary buffer.
15:49 Let me run it now.
15:55 It shows this temporary buffer here, with
15:58 the script with tests. We have
16:01 just run some code that corresponds to this
16:04 section here, the section 0 here,
16:07 called "Basic installation"... and now we
16:10 are going to run this thing here.
16:12 These lines start with two red stars,
16:15 so they're going to to be treated as
16:17 comets, and we are going to see here in
16:21 the echo area something that says:
16:22 "Comment: blah blah blah blah".
16:25 So let's do that now.
16:28 And now this line here is going to be
16:32 very important. Note that it
16:34 has a single red star, so it's not a
16:36 comment - it's going to be executed as
16:39 lisp and it sets a
16:45 an environment variable that says where
16:49 Lua should should read its init file
16:52 from.
16:54 If I remember correctly that
16:56 variable is not set now, so if execute
16:59 this thing here
17:01 Lua will complain that this function,
17:04 ee_dofile, is not defined.
17:06 So let me run this block again
17:11 When I run this line Emacs will
17:15 define this environment variable for all
17:18 children processes, and I'm going to
17:21 restart the Lua interpreter...
17:24 Here - and now it's going
17:27 to use this
17:28 environment variable here, so now this
17:31 line will work - it will load this
17:35 Lua file here.
17:37 We can also execute this with M-e to
17:41 take a look at this file.
17:43 By the way, it says
17:46 "find-angg not configured"...
17:49 Let me cheat a bit. Let me run one thing
17:53 here without explaining it.
17:59 I'm going to explain this in one of the
18:01 exercises, I promise!
18:05 If I run this thing now,
18:09 then it accesses that file by using wget -
18:13 I mean it downloads a copy of that file
18:16 without saving it to disk...
18:19 and I do not have lua-mode installed
18:22 in this minimal setting here,
18:28 so the colors are a bit boring...
18:33 but anyway, we can access this Lua file
18:36 here, and now let's run this test. This
18:39 test is a bit simpler than the test that
18:41 I've shown before.
18:44 I'm going to run these four lines here,
18:47 and note that this thing has a "tikz"
18:49 here...
18:51 if I just executed this
18:55 then the value of tikzbody would be
18:58 just this string here, that
19:00 is between these funny delimiters -
19:02 between this "[=["
19:05 and this "]=]"...
19:06 but we had a "tikz" here, and this says
19:11 that we have to run the function "tikz"
19:14 with this argument, and the function
19:16 takes this this argument here and
19:19 treats this thing here as something that
19:22 has to be expanded... so every time that we
19:25 expand this string here, this thing here
19:29 between double angle brackets will
19:31 be replaced by the result of evaluating
19:35 it, and also this thing here,
19:39 and also this thing here...
19:44 In the beginning this variable is nil,
19:47 this variable is also nil,
19:50 and
19:53 the function that that evaluates these
19:56 things between double angle brackets
19:59 treats
20:00 things that evaluate to nil as empty
20:04 strings, so this thing here is going to
20:06 become an empty string,
20:08 also this one here,
20:10 but in this one here something
20:12 different is going to happen -
20:14 the variable gridsize is nil, but we
20:19 have this "or" here, so this thing is nil
20:22 and the result of this bigger expression
20:24 is going to be this string here. So
20:30 the result of
20:33 evaluating this part here is going to be
20:35 this string here.
20:38 I have just
20:41 sent this thing without the
20:44 "tikz" - let me run this thing again with
20:47 the "tikz"...
20:48 and now let me run the show() that will
20:51 save this thing into a .tex file... I mean,
20:53 it will produce a .tex file... it will save
20:55 the .tex file, and it will try to compile
20:58 the .tex file to generate a PDF.
21:03 Ta-daaa: "Success!!!"
21:06 Now I can run this thing here -
21:09 remember that it starts with a red
21:11 star, so Emacs is going to execute to this
21:13 thing...
21:17 ah, one second... let me
21:25 try this again - sorry...
21:30 I forgot that I'm in a very minimal
21:33 environment, so it
21:36 wasn't searching for pdf-tools in the
21:38 right place...
21:39 Anyway. Note that I have executed
21:43 this thing, that is a function... it's a
21:47 relatively low level function - it just
21:49 splits the frame into two windows, and it
21:52 shows a PDF in the window at the right.
21:56 We are going to see something much
21:58 better in in a few minutes.
22:01 Now I'm going to run this lines here
22:04 these two lines are sent to the Lua
22:06 REPL...
22:08 this line also, but this one takes a few
22:11 seconds to run, and it shows all
22:13 these messages here...
22:15 and now I'm going to run this line - the
22:19 (find-pdftoolsr-page ...) -
22:24 and it shows a changed version in which
22:28 gridoptions now...
22:31 I mean, this thing here, now when it
22:36 is expanded it becomes this string here...
22:40 so the grid appears in a lighter color.
22:43 And now I'm going to run this block here
22:47 and this is going to change the value
22:50 of the variable gridsize.
22:53 Remember that gridsize appears here...
22:57 so when I change this this variable,
23:01 gridsize, to this string,
23:05 the result of evaluating this expression
23:07 here is no longer going to be the thing
23:10 at the right of the "or" - I mean this
23:13 string here... it's going to be
23:16 this other string.
23:18 So TikZ is going to use a smaller grid.
23:21 Here we have a grid
23:26 whose width is six units and whose height
23:30 is four units... we are
23:34 going to change that to four units and
23:37 three units. Let's do that now.
23:40 "show()" takes a few seconds to run because
23:42 it produces a PDF... and now let's show the
23:45 result... ta-daaa: smaller grid!
23:49 And here is another part of the demo.
23:54 instead of displaying the PDF I'm going
23:58 to use the function savetex(),
24:00 that just produces .tex, but
24:03 does not generate a PDF from it, and this
24:07 function here, that displays the .tex file
24:10 at the right side.
24:12 Let's see. Note that this first line
24:16 sets gridoptions and gridsize to nil
24:19 and nil again, so we are back in
24:22 the initial situation...
24:24 savetex() just says
24:28 "Saved the .tex file in blah blah blah"...
24:31 and now I'm going to run this thing here,
24:34 that produces a
24:37 a window setting with three windows,
24:41 and it shows the .tex file here at the
24:43 bottom.
24:46 And now I'm going to run this other
24:48 block here...
24:52 note that I'm changing the gridoptions,
24:55 and gridoptions appears here, after the
24:59 first \draw, so pay attention to what
25:02 happens here in the .tex file
25:05 we're going to see that here
25:09 appears a thing between square
25:12 brackets that says
25:18 "[color=gray!20]".
25:20 So pay attention... here...
25:24 savetex(), and now (tikz-showtex).
25:31 And now something similar, but the grid
25:33 is going to change to (4,3).
25:37 Pay attention here...
25:43 So (tikz-showtex) is a low-level
25:46 function that we can use to
25:48 inspect what happens with .tex file...
25:53 And now I'm going to
25:57 show the the function that we're going
25:58 to use most, that is the function that
26:00 instead of showing the .tex file - here -
26:03 its shows the PDF file here.
26:06 So, same thing. Let's reset gridoptions
26:09 and gridsize to the initial state,
26:12 show()
26:13 and (tikz-show). So this is our initial
26:16 drawing -
26:17 the grid appears in black.
26:20 Now let's change the color of
26:23 the grid, and run show() again, and run
26:27 (tikz-show)... and now it's going to to show
26:30 the changed version of the PDF, in which the
26:32 grid appears in light gray.
26:35 And now let's change the size of the
26:38 grid. The grid is currently 6 units by
26:41 4 units, it's going to change to 4
26:45 units by 3 units...
26:50 that's it - you can see that the rectangle
26:52 is smaller.
26:55 So, this is the the basic test that
26:59 you can run with without installing
27:01 anything... I mean, you just need these
27:04 prerequisites here...
27:08 Emacs, eev, pdf-tools, Lua 5.1, and a TeX
27:11 distribution with TikZ...
27:15 and by the way this thing puts four
27:19 files in this directory, that is hard
27:21 coded at the moment... and it creates some
27:24 temporary files in /tmp/.
27:35 So, now suppose that you are interested
27:41 in trying this more. Then my suggestion is:
27:46 copy these things here - these lines here -
27:48 to your init file.
27:52 Some people use init files with other
27:54 names, but I prefer to call them by the
27:57 the old name which is ~/.emacs...
28:03 but this is an abuse of language - I mean,
28:06 for some people theirs init file is going
28:08 to be ~/init.el, or
28:14 ~/.emacs.d/ something, whatever...
28:20 So let's copy these things here to my
28:23 init file...
28:32 and now every time that we start Emacs
28:36 it is going to set
28:40 the init file for Lua to this file here,
28:43 as I've shown before, and it's going to
28:46 to load
28:50 the file that defines this script that
28:53 we're using, and blah blah...
28:57 um sorry sorry
29:02 and if you want to deactivate these
29:05 things you just need to comment out
29:08 to this region either in this way, or in
29:12 this way here...
29:17 oops, sorry,
29:23 let me do this by hand... sorry, one of my
29:26 favorite Keys is not defined.
29:29 so, that's it. This thing was commented
29:32 out.
29:34 But right now I do not want it to
29:36 comment it out - I want to use it.
29:40 Note that
29:44 this thing starts with three comments,
29:47 here... I use this a lot in eev - instead
29:51 of using customize I use
29:57 "setq"s, and "defalias"es, and
30:00 "defuns", and whatever else... and there is
30:03 a section here that has links that
30:05 explain why I prefer to use alternatives
30:08 to customize - low-level alternatives -
30:11 instead of using customize itself.
30:15 And one trick that I always use is
30:18 that every time that I put a block of
30:20 code in ~/.emacs
30:26 I start with the line that says "From:"
30:30 that gives me more information about
30:33 what these lines do, and where you can
30:36 go to understand more about them.
30:39 So, if I execute this...
30:41 it will open this .el file..
30:45 and note that here we have the
30:47 definition of find-tikz1-links...
30:52 and it is basically just a big
30:55 template that displays this thing in a
30:57 temporary buffer.
31:00 And it also has a link that goes to a
31:04 certain anchor in this file...
31:08 that anchor points to the place in which
31:12 I define the function "tik", without a
31:15 "z" at the end...
31:16 and it inserts an eepitch block that "runs
31:21 tikz1.lua". Let me show how to
31:23 use this.
31:27 Let me go back to here - this is just a
31:30 random scratch buffer... if I run
31:34 M-x tik here
31:37 it inserts this block... let me show
31:41 this again...
31:43 it inserts this block, and this is
31:45 something that I can modify. I can put
31:48 this block in any place, and if I run
31:50 this thing here it creates Lua
31:53 buffer...
31:55 I mean, a target buffer for eepitch
31:59 running Lua.
32:00 Now this first line loads
32:04 tikz1.lua, that defines "tikz"
32:07 and "show"...
32:12 and here it has a very short demo of a
32:16 drawing.
32:18 The idea is that this is just a
32:20 placeholder that you can replace by
32:22 something else...
32:23 it's to remind people that you can
32:26 put text code inside this thing here.
32:30 Now let me run the show()
32:34 and the (tikz-show)... and this thing drew
32:38 an orange triangle.
32:41 I can, for example,
32:43 replace this by "red"...
32:47 and run this again,
32:50 and now my triangle is red.
32:56 Let me stop this part of the video here.
33:00 In the other part I'm going to
33:01 explain these things here...
33:14 we have just done the "Not so basic
33:18 installation", that lets people explore
33:21 TikZ with just a few
33:24 settings, and now I'm going to explain
33:27 the exercises that
33:30 people can use to learn how to extract
33:33 examples from the TikZ manual.
33:36 So part 3 starts in a few seconds.

;; Part 3

33:40 Hi! this is the part 3 of
33:43 the video,
33:45 that is only for the people who are
33:47 asking: how can I write things like this,
33:52 like this block that we saw in the first
33:54 part, myself?
33:56 And note that right now, in this minimal
33:59 setting in which I'm running this Emacs
34:04 here, in a fake home directory, I do not
34:07 have a copy of the
34:10 TikZ manual, I do not have a
34:14 copy of the source of the TikZ manual... so
34:17 many of these things are not going to
34:19 work. If I execute this thing here it says
34:22 that this function is not even defined...
34:25 this function is not defined also... this
34:28 function is not defined... so it's not even
34:31 in a state in which it searches for the
34:35 manual and for the source of the menu in
34:37 the right places.
34:44 What we are going to see is what is in
34:46 the
34:48 third section here... the section 3 here,
34:50 because it has a 0th section.
34:55 We just saw the sections 0, 1, and 2,
35:00 and we are going to see this one now.
35:02 Let me just return and execute this.
35:05 Here we are.
35:08 I say that these exercises are
35:11 explained in this section of the page
35:13 about eev and TikZ, but at this moment
35:15 this section does does not exist... but it
35:18 will exist very soon.
35:20 And there is also another similar
35:23 function, similar to find-tikz1-links,
35:26 that has some spoilers... at this
35:28 moment it has very few spoilers but I'm
35:31 going to add more spoilers soon.
35:34 This section has lots of exercises
35:38 and in
35:42 this video I'm going to show very
35:43 quickly how to do these exercises, and my
35:45 recommendation is: watch this
35:48 video with subtitles and with the trick
35:51 that eev uses to point to positions in
35:54 a video,
35:56 to follow the instructions in
36:00 each of the exercises step by step.
36:03 All the exercises are going to be
36:06 of the same type which is just
36:09 reproduce yourself the steps that I'm
36:12 performing in this video... so they do not
36:15 require a lot of creativity, I mean, sorry,
36:18 they do not require any creativity, they
36:21 just require people to familiarize
36:23 themselves with some functions that I
36:26 use in eev.
36:27 And let me make a very important comment
36:30 which is that most of the functions that
36:34 we are going to see now, they look like
36:36 5-minute hacks... my presentation at the
36:40 EmacsConf2020 was exactly about that, about
36:44 some design choices in eev,
36:47 and its title was exactly "On why most of
36:51 the best features in
36:54 eev look like 5-minute hacks".
36:58 But let's go back, and let me show
37:04 how to do the exercises.

;; a) [tik]

37:09 We just saw how to do this exercise here,
37:12 but this exercise (a) here, whose name is
37:16 "[tik]"...
37:17 it asks us to use M-x tik to
37:22 create
37:23 an eepitch block that compiles and
37:26 displays a drawing whose body is this.
37:30 So I'll have to copy this file to my
37:35 notes... let me go to my notes - here -
37:37 remember that when I type
37:42 when I type M-1 M-j this opens
37:46 the file with my notes, that is ~/TODO...
37:49 so I'm going to put all my
37:53 notes about these exercises in this file
37:56 here,
37:58 which is the file that I recommend
38:00 people to use to to put all their messy
38:04 things there.
38:09 Let me yank these lines here,
38:16 let me change the indentation... and if
38:19 I run M-x tik it creates a block like
38:24 this, but the exercise asks us to change
38:27 the body to this other body here.
38:32 Now let's run this thing here... I will use
38:36 a smaller font -
38:44 it created the PDF successfully. Let's
38:48 show the PDF. Ta-da - we have a grid with
38:52 this size four units in the horizontal
38:56 direction, and three units in
38:58 the vertical direction, and
39:02 this second draw here has drawn a red
39:07 triangle here.
39:09 So this was the first exercise.
39:12 Let me just put some notes here.
39:20 Now let me go back to the to the
39:23 exercises.

;; b) [.emacs-1]

39:25 The second exercise is this one.
39:33 Let me copy it to my notes.
39:41 Actually we have already done that...
39:45 it says: copy the lines from the
39:49 section 2 to your init
39:52 file, restart Emacs, and check that this
39:55 thing here works.
39:57 Let me try.
39:59 Hm, these lines are already there...
40:12 I'm not going to restart Emacs because I
40:15 I've started Emacs with some command
40:19 line options to make it use certain
40:21 colors, and it would take me many seconds
40:24 to remember how to do that...
40:27 Anyway, so let me pretend that we did the
40:33 exercise b.

;; c) [.emacs-2]

40:35 Now let's go to the exercise c,
40:40 which is this one...
40:48 I have already fixed that but I did
40:50 not explain how. The thing is that by
40:53 default when we run find-es something
40:57 Emacs says that find-es something is
41:02 not configured.
41:04 In this case... sorry -
41:10 let me see what happens here...
41:23 so this thing is configured. The
41:27 instructions say that we have to
41:30 execute this thing here. Let me just
41:32 explain how this thing works. If I type
41:35 M-x and I run this function here -
41:37 find-angg-es-links -
41:42 it shows a way to configure find-es and
41:46 find-angg... it explains how they
41:49 work on my machine and how people
41:52 can also use it...
41:53 I mean, when I run find-es and find-angg
41:56 in my machine they open local files
42:00 that have my scripts, my
42:03 programs my notes and so on. Other people
42:06 can also access my scripts if they
42:09 redefine these functions in a certain
42:11 way
42:12 to make them use wget, and there's a
42:16 video here that explains how how this
42:18 thing works. So if people
42:20 want to understand
42:23 what this thing does the recommendation
42:25 is: watch these videos here. If I remember
42:28 correctly they just need to
42:32 watch 30 seconds starting from this
42:35 point and another 30 seconds
42:37 starting from this point.
42:39 So let's let me pretend that this
42:42 exercise is done,
42:44 and let me go back to the list of
42:47 exercises.

;; d) [manual-pdf]

42:50 Exercise d.
42:57 Remember that I said that we don't have
42:59 a copy of the of the manual yet...
43:07 to download a copy of that manual
43:12 in PDF we have to run M-x brep.
43:17 If we run this here
43:20 it asks for a URL, and then it opens this
43:25 temporary buffer here with this script.
43:29 If people want to understand what this
43:31 thing does they can go to the source
43:34 code by running this line here,
43:39 and then the comments in the source code
43:43 have pointers to the manual,
43:46 to the place that explains how these
43:49 things work...
43:54 and the manual also has some links to
43:57 videos, if I remember correctly...
44:03 oops, sorry, this this tutorial does not
44:07 have links to videos, but it is quite
44:09 clear.
44:15 Anyway,
44:16 to download the local copy we have to
44:19 run M-x brep here, and it displays this
44:24 temporary buffer and what we have to do
44:26 is that we have to execute these
44:39 commands here, but it says that...
44:42 in my previous test I had already
44:45 downloaded a copy of the manual so it's
44:47 already there. And we can also use these
44:50 lines here to test if the file was
44:54 downloaded. It was -
44:57 and the
45:01 othe part of this exercise says
45:04 that we have to produce a pair made of a
45:07 code-pdf-page and a code-pdf-text that
45:10 makes these links work. This is also
45:12 explained in the tutorial. In the page
45:15 about the eev and TikZ I'm going to give
45:17 links to the sections of the
45:20 tutorial that explain everything... but let
45:22 me show very quickly how we can do that.
45:27 When we ran brep here one of the sexps
45:31 that it produced was this one...
45:38 now I'm in dired mode, and here I
45:43 can type M-h M-e... it creates a
45:47 temporary buffer like this,
45:49 and what exercise asks is... that
45:59 we create links like this that work.
46:02 So the "{c}" that we have to put here
46:06 is "tikzman".
46:11 I have edited this first line here, to
46:16 change the value of
46:20 of "{c}", and if I run this
46:24 line again it will regenerate this
46:27 temporary buffer from a template and all
46:30 these "{c}"s are going to be replaced by
46:32 this new value here - "tikzman".
46:35 And now we have this block of
46:38 links that point to a certain PDF file...
46:43 and what the exercise asks is that we
46:46 produce these code-pdf-page and this
46:49 code-pdf-text if I execute them...
46:53 let me execute them. The first one defines
46:55 this function here, find-tikzmanpage,
46:58 the second one defines this function here...
47:02 remember that if you need more
47:05 information about what they do you can
47:07 just add a "find-" here in the beginning
47:10 and then
47:11 execute this new sexp and then it will
47:15 have some explanations, a link to the
47:17 tutorials, and so on...
47:20 but now they have defined these things
47:23 and this sexps should work. This one
47:27 should open the manual in
47:29 PDF - this is the first page of the manual
47:33 in PDF -
47:34 and this sexp here is going to take
47:37 many seconds because the manual is huge...
47:40 and it's going to open the the manual
47:44 converted to text.
47:46 So a bit of patience please...
47:52 a bit more please...
47:55 oh no, it takes ages!...
47:58 Here we are.
48:02 this thing worked correctly it ran
48:05 pdftotext to convert the manual to text,
48:08 and at some point we're going to use
48:10 this thing to
48:14 point to titles of sections, sometimes
48:17 we're going to use this to copy and
48:19 paste examples, and so on...
48:22 so the answer to this exercise is these
48:28 two "code-pdf-*"s -
48:30 these two "code-*" lines. And these two
48:34 lines here are tests.

;; e) [manual-git]

48:37 Let me go back to the exercises. Now
48:41 I'm going to show how to do the
48:44 exercise e.
48:48 The exercise e says that we have to
48:52 start from this URL here, that points to
48:55 a git repository, and
48:59 we have to use this to download the
49:02 source code of the manual... and we
49:04 have to define these three...
49:08 we have to make these things
49:11 work using `code-c-d's.
49:14 And here people will have to consult the
49:20 spoilers because it's not clear what
49:23 this directory means... I mean, to what
49:27 directory this thing has to
49:29 point, and to what directory this thing has
49:31 to point, whatever...
49:32 Anyway. I can type `M-h g',
49:42 and it runs a function called
49:46 find-git-links...
49:48 and now I can run this script here
49:51 and it clones the git...
49:53 oh no -
50:02 It used the wrong directory.
50:08 Let me fix that. Sorry.
50:13 So now the cd worked...
50:20 it's downloading - I mean, it's cloning the
50:23 git repository...
50:35 and if I want I can inspect the git
50:39 repository using these links here -
50:43 but I do not want to do that now.
50:48 What I want to do is that I want to
50:53 create something like this,
50:56 but with a different name... I want to use
50:58 something different instead of "pgf" here.
51:01 So let me copy these two lines
51:05 to my notes...
51:07 what I'm going to do here is that I'm
51:09 going to replace "pgf" by "tikzgit"...
51:19 TikZ is actually PGF/TikZ, but
51:25 the name PGF is not used so much, so I
51:28 preferred to use the name "TikZ" almost
51:31 everywhere.
51:33 So this thing here defined
51:35 this function - code-tikzfile -
51:37 and several other functions...
51:40 remember that you can inspect
51:42 what this code-c-d does
51:44 running a sexp like this...
51:49 it defines this variable, ee-tikzgitdir,
51:52 and lots of functions with "tikzgit" in
51:55 their names... and if people need more
51:59 information about how this works
52:01 they can use these things here to go
52:05 to the tutorial.
52:11 So if I run this then I define
52:15 find-tikzgitfile, find-tikzgitgrep, and
52:17 other links like this, and this one opens
52:21 the source code of the manual...
52:24 and I also need some variants
52:30 of this... let me open the spoilers.
52:41 Here. What I really want is these three
52:47 `code-c-d's here...
52:51 and this one is obvious - it goes to the
52:58 copy of the git repository... this
53:01 one goes to the
53:05 directory where the source code of git
53:08 itself is - I mean, when you use
53:12 \usepackage{tikz} in your .tex file
53:16 it load files that were
53:18 originally here, but that were then copied
53:21 to the texlive distribution... sorry, to
53:25 tex texlive directories.
53:28 And this one is going to be very useful
53:32 and very used...
53:33 that is the source code of the manual
53:36 of TikZ.
53:42 Here we have
53:45 all the sections, and
53:48 chapters, and subsections, and whatever,
53:50 of the manual
53:51 in .tex files. We're going to use that
53:54 soon.
53:57 So, now...
53:58 well, the exercise e said that we had
54:02 to produce these three `code-c-d's
54:06 that make these sexps work...
54:07 and now they do work. This
54:12 one opens the copy of
54:14 the git repository, this one goes to
54:17 the source code of TikZ itself and
54:20 this one opens the source code of the
54:22 manual.
54:25 So now let me go back to the
54:27 exercises again...
54:31 we have just done this exercise here...

;; f) [.emacs-3]

54:34 Let me copy these two exercises to my
54:41 notes at the same time...
54:47 This exercise here asks people to
54:52 put more things in their init file.
54:57 It asks people to copy these
55:01 things to their init file, and it
55:03 recommends using the spoilers.
55:05 And the idea is that we are going to
55:08 copy this thing here to the init file...
55:11 and remember that if we type M-5 M-5 M-j
55:20 then we open the init file.
55:26 So let me copy this to the init file...
55:30 and note that
55:31 it has a "From:" line here, and the line
55:35 with the "From:" can be used to...
55:40 I mean, I forget things all the time, and
55:43 so I use these things to go back to the
55:46 places where the functions were defined,
55:48 where I found the instructions, and so on.
55:50 If execute this thing I go to the
55:54 temporary buffer with spoilers, and I see
55:59 this block here... that is where
56:02 this thing here came from.

;; g) [page]

56:10 Now the exercise g, called "[page]"...
56:16 it asks us to create links to a certain
56:19 page in the manual.
56:22 If I execute this thing it goes to the
56:25 conversion of the manual to text,
56:30 and the exercise says that we have to
56:34 produce a pair like this,
56:36 that points to that page...
56:39 and what we have to do is that we have
56:41 to go here, then we have to mark this
56:44 string and copy it to the key ring, and
56:47 then we have to type `M-h M-p'...
56:51 and then this is the pair
56:54 that we want.
56:57 This first link here opens the PDF of
57:00 the manual at that page...
57:07 those coordinates appear here, in
57:10 the middle of the
57:12 the instructions for drawing this
57:14 envelope here...
57:17 and now this thing here has a number
57:21 here saying to this function that it has
57:24 to count the form feeds to go to page
57:27 30 in the conversion, and then it has to
57:30 search for this string in the
57:32 manual converted to text. If I execute
57:35 this
57:36 it goes exactly to this page
57:39 but it also has this indication that we
57:42 have we are in page 30.

;; h) [src]

57:49 Next exercise: "h) [src]".
57:58 In this exercise we have to
58:01 to learn how to create a link to the
58:04 source code of the manual...
58:06 and we are also going to have to learn
58:09 how to use this - `tiks'. This is a 5-minute
58:12 hack, in the sense that I've mentioned
58:15 earlier and that is explained... I mean, the
58:19 design decisions behind these
58:22 5-minute hacks were explained
58:26 in my talk at the EmacsConf 2020.
58:30 If we execute this it creates a
58:33 temporary buffer with lots of hyperlinks,
58:37 and the idea is that we have to understand
58:42 what these hyperlinks do...
58:48 and we have to produce a hyperlink like this,
58:53 that points to a certain section of the
58:57 source code of the manual.
59:01 note that we don't have links like that
59:04 here... but we will have to use the grep
59:14 here to grep
59:16 in the directory that has this shorthand...
59:26 it found one occurrence of this
59:29 string, in this file here... so what I have
59:33 to do is that I have to visit this file...
59:35 if I type enter here it will go
59:38 to the line 271...
59:42 then I'll have to copy this thing to the
59:49 kill ring... and now the best way to create
59:52 a link to this string is to use...
59:55 I mean, the traditional way is by typing
59:58 `M-h M-h', here and then editing...
1:00:03 duplicating this line, editing this line
1:00:06 to add this string here, and so on... but
1:00:09 one of the things that I'm going to
1:00:10 present in the EmacsConf
1:00:13 is a very fast way to create
1:00:16 links like this.
1:00:17 So if this thing here is in the region -
1:00:24 in this case the region is not active,
1:00:28 but it is there -
1:00:31 and I type `M-x klfs'
1:00:35 this kills a link to a file and
1:00:41 a string in that file...
1:00:44 so if run this -
1:00:46 Gaaah! God! =(
1:00:53 Oh no, this is not loaded by default...
1:00:58 Let's see if I...
1:01:01 I'll have to to fix this later,
1:01:06 but let me
1:01:08 fix this by hand, sorry...
1:01:20 Let me see if this works now...
1:01:25 Ah, yeah! Sorry!
1:01:31 Let me do some mysterious things right
1:01:34 now...
1:01:41 I have use these aliases here.
1:01:44 Let me put these aliases in my...
1:01:50 Let me copy these aliases to the init file
1:02:04 and execute them...
1:02:07 so now this thing should work...
1:02:11 if I
1:02:13 mark the region here and I type `M-x klfs'
1:02:17 this should put in the kill ring a
1:02:21 link to this file and to this string in
1:02:24 this file.
1:02:25 Oops - let me run this again...
1:02:29 The message in the echo area says that
1:02:32 this has killed this sexp here...
1:02:36 and let me go back to my notes...
1:02:41 this is the link that the
1:02:44 exercise asks for.
1:02:46 If I execute this link I go to this file
1:02:51 and the source of the manual, and it
1:02:53 searches for the first occurrence of
1:02:55 this string there.
1:03:01 Next exercise...

;; i) [tiks]

1:03:10 "i) [tiks]".
1:03:15 Let me go back to my notes...
1:03:19 it says: start from this
1:03:21 hyperlink and make sure you know how to
1:03:24 use all the hyperlinks in the temporary
1:03:26 buffer that this function here, `tiks', has
1:03:29 generated.
1:03:34 This first line here just regenerates
1:03:37 the buffer in the sense that if I make a
1:03:39 big mess here I can just execute this
1:03:42 individual reconstruct the buffer in the
1:03:45 original way. This second line uses
1:03:50 a synonym for `tiks'...
1:03:54 this third line here goes to
1:03:57 the definition of this function -
1:04:03 it is here, and after the definition we
1:04:05 have a defalias,
1:04:08 so the two functions are equivalent.
1:04:16 This thing here is going to use wget to
1:04:19 access one of the files in my home site.
1:04:28 It has some notes about TikZ, and here
1:04:31 is an index that I have prepared
1:04:35 for the chapters of the manual - but this
1:04:38 index supposes that we are using an
1:04:40 older version - long story -
1:04:43 so the pagination is not correct...
1:04:45 for example, probably this thing
1:04:49 here is not going to point...
1:04:52 no, this one works but
1:04:56 let me see what happens here...
1:05:00 this one is four or five pages behind.
1:05:09 The right value here should be
1:05:12 something like this...
1:05:15 Almost!
1:05:21 Anyway, this is an index for
1:05:25 the chapters in the TikZ manual,
1:05:28 that is not going to work for you
1:05:30 because...
1:05:31 well, in the other exercises
1:05:35 I recommended to download the current
1:05:37 version of the manual...
1:05:39 and note that
1:05:42 this thing was downloaded by wget, so
1:05:45 it's in a temporary buffer...
1:05:57 in this case this
1:06:00 link is not going to work very
1:06:02 well because
1:06:04 this thing is not the name of a
1:06:07 chapter, it is the name of a subsection...
1:06:09 but whatever... this link here
1:06:14 is more like a button than like a link -
1:06:16 it puts this string in the kill ring.
1:06:26 We are going to see soon how to use that.
1:06:30 This thing here opens the the manual in PDF
1:06:36 in its page 3, where it has the table
1:06:39 of contents...
1:06:42 this one here opens the page 3 using
1:06:46 the conversion to text and now we can
1:06:49 use this thing here that I
1:06:51 have just pushed into the the top of the
1:06:54 kill ring to search for a certain string
1:06:57 if I go here and I type C-s
1:07:00 I enter the mode that performs
1:07:05 interactive search... if I type M-y here
1:07:09 it puts
1:07:12 the top of the kill ring here and I can
1:07:15 use that to find this section
1:07:18 in the manual.
1:07:19 And now I can search for other
1:07:22 occurrences here... because probably
1:07:24 I do not know a link to this page.
1:07:26 No, sorry, let me change the exercise
1:07:29 a bit. I will use this string here
1:07:38 to create a link to the index...
1:07:48 so this thing here is section
1:07:52 14.2.2 that appears
1:07:56 here, in very small letters...
1:08:06 and after doing that I can also
1:08:11 search for this other string here...
1:08:18 and use M-h M-p again to produce
1:08:22 a pair of links that go to the
1:08:26 real section in the manual.
1:08:29 So this goes to this section - here -
1:08:38 and this goes to this section converted
1:08:41 to text.
1:08:44 Let's go back. I was explaining
1:08:48 the lines in this temporary buffer here...
1:08:50 and this one was a bit mysterious, but
1:08:53 I have just explained how to use it.
1:08:58 These lines here...
1:09:01 in theory they go
1:09:06 to the index of the the manual, at the
1:09:09 very end...
1:09:10 and remember that you can
1:09:12 execute this to go to the source code
1:09:16 of that function,
1:09:19 and we can use that to change that to
1:09:21 the right numbers...
1:09:23 this is a bit advanced, but let me
1:09:26 explain it anyway.
1:09:30 The index is a few pages ahead of that...
1:09:33 that number. Let me see how many...
1:09:37 oh, no! Many pages. So, in this version
1:09:41 of the manual the index
1:09:43 starts at the page 1271
1:09:49 instead of 1235,
1:09:51 and I can go to the source code of
1:09:55 this function, and I can change this to
1:09:58 1271...
1:10:02 and then I can redefine this function,
1:10:08 and then I can use this to regenerate
1:10:10 this buffer, and now it has now it has
1:10:15 the right links to the index.
1:10:21 So this first link here goes to the
1:10:25 beginning of the index, but it
1:10:27 ignores this string...
1:10:30 and this other link here goes to the
1:10:32 beginning of the index and then it
1:10:34 searches for the string. I guess that
1:10:36 that is not going to work -
1:10:38 it says "Search failed", but whatever -
1:10:43 for other strings this would
1:10:46 work very well. For example,
1:10:56 if I wanted this...
1:11:03 then I could just use this thing here to
1:11:05 create
1:11:10 a link to where a certain string appears
1:11:13 in the index.
1:11:18 Well, as I've said in the beginning
1:11:21 this is a 5-minute hack with many
1:11:23 small hacks inside... and I've just
1:11:26 explained how we can fix the index, and
1:11:29 how we can create
1:11:30 links to an entry in the index.
1:11:36 These three lines are easier. We just saw
1:11:39 what they do. This goes to the
1:11:42 to the copy of the git repository,
1:11:46 this one goes to the
1:11:49 to the source of the manual, and this
1:11:52 goes to the source code of TikZ and
1:11:59 PGF themselves.
1:12:02 We can use this
1:12:04 three grep links here to search
1:12:12 the whole copy of the git
1:12:14 repository, or to... sorry, to search just
1:12:19 the source of the manual, or to search just
1:12:21 the source of TikZ and PGF.
1:12:27 And note that
1:12:30 I've used the an uppercase R here to to
1:12:34 specify that this grep has to be
1:12:37 recursive.
1:12:40 This one finds one occurrence,
1:12:47 this one also...
1:12:54 and this does not appears in the
1:12:57 source code of TikZ, I mean...
1:12:59 when people run \usepackage{tikz} then
1:13:05 this loads lots of packages and this
1:13:09 string does not
1:13:11 does not appear among the these packages -
1:13:14 these .tex files and the style files
1:13:17 that are loaded by \usepackage{tikz}.
1:13:23 And we can also use these URLs here
1:13:26 to go to the... oops -
1:13:30 I do not want to do that now, sorry... I'm
1:13:33 in the fake home directory... but we can
1:13:37 use this to to open the git repository
1:13:40 using a browser
1:13:44 So these are the explanations
1:13:47 for all the lines that appear in the
1:13:52 "make sure that you know how to use all
1:13:55 the hyperlinks"... there are many, and
1:13:57 some are quite technical. I have
1:13:59 just explained all of them.
1:14:01 So this was exercise (i).

;; j) [section]

1:14:07 Let's go to exercise (j).
1:14:17 Exercise (j) says
1:14:25 that we should start by this
1:14:27 hyperlink here, and
1:14:30 we have to use this to produce links to
1:14:33 a section of the manual. So this is
1:14:35 similar to what I did here,
1:14:37 but here I produced links to a section
1:14:40 called "Horizontal and Vertical Lines",
1:14:43 that was actually a subsubsection,
1:14:46 or a subsection, whatever...
1:14:50 And let me show how how we can do this.
1:14:57 My favorite way of doing this is by
1:14:59 using this to put the string
1:15:03 in the kill ring, then I go to the
1:15:05 table of contents, then I
1:15:08 search for that string...
1:15:11 it's in this chapter here...
1:15:15 then I go to that chapter with
1:15:17 C-s and M-y
1:15:21 and then - oops, sorry...
1:15:29 and then I will create a link to
1:15:34 to this string here in that page,
1:15:37 with the right number of spaces here...
1:15:40 so let me put that in the kill ring,
1:15:44 and M-h M-p...
1:15:54 and this is a pair of links that point
1:15:57 to this section in the manual.
1:16:01 Here we are...
1:16:07 and this one
1:16:09 opens that section in the manual
1:16:12 converted to text
1:16:16 so this was exercise (j).

;; k) [codeexample-1]

1:16:25 The next exercise -
1:16:28 exercise (k) -
1:16:34 is similar to that one, but it asks us to
1:16:37 create... uh, no, no, sorry -
1:16:40 this one is different!
1:16:44 This one says that we
1:16:47 have to start from this hyperlink and
1:16:50 then we have to find the source code
1:16:53 for a certain example.
1:16:57 We have to use this link here
1:17:01 to find that section in the source
1:17:03 of the manual
1:17:08 let me first create a link
1:17:16 to this string in this file... let me copy
1:17:19 it to my notes...
1:17:28 I have just just created something that
1:17:31 is useful to me, but that is not exactly
1:17:34 what the exercise asks for, that is
1:17:37 a link to a certain section
1:17:40 of the manual in the source code of the
1:17:43 manual. And now that I have this link
1:17:45 I'm going to search for
1:17:48 a certain \codeexample here - it is here -
1:17:56 now I have to run `M-x tik' here...
1:18:08 and then I will
1:18:11 change the body of this example
1:18:17 by the body of this \codeexample in the
1:18:20 manual - this one here.
1:18:23 Now let's test this.
1:18:31 It worked! Ta-da =)
1:18:39 We are almost at the end...
1:18:45 let me see what is the next exercise...
1:18:49 We were at exercise (k).

;; l) [codeexample-2]

1:18:52 Now we have to do exercise (l).
1:19:00 This one is similar to the to the
1:19:09 previous one, but instead of using tikzbody
1:19:12 we have to put this
1:19:14 string in another variable.
1:19:19 This links here searches for this
1:19:24 string in the source code of the manual...
1:19:38 I want this code example here.
1:19:54 and now I create a block like this one,
1:19:57 but this block here is going to to have a
1:20:03 an empty tikzbody,
1:20:07 so it's going to produce an empty figure...
1:20:10 and I'm going to copy this thing here
1:20:15 to the variable "hello".
1:20:19 The name is a bit silly, but the thing is
1:20:22 that in some of my early tests I just
1:20:29 did... one second...
1:20:32 I just did this with an empty tikzbody,
1:20:41 and when I run this block here
1:20:51 it just shows a "HELLO". That is...
1:20:56 I mean, it runs this this code here
1:20:59 outside the tikz block.
1:21:02 But...
1:21:05 the hint says to put this thing here in the
1:21:07 variable "hello".
1:21:12 If we want more information about
1:21:14 what does this does
1:21:17 we can go to the
1:21:20 to the source code in Lua...
1:21:23 sorry for the lack of colors, I forgot to
1:21:26 install lua-mode here...
1:21:28 but... the texbody is here, and before...
1:21:38 this block here defines a
1:21:40 tikzpicture inside the \scalebox,
1:21:44 and just before that I have a hello.
1:21:50 Anyway, the exercise asks for this,
1:21:54 and if you if you run this thing here
1:21:59 it runs these very low-level
1:22:05 commands here...
1:22:07 \pgfkeys is the low level way to
1:22:10 define styles in TikZ,
1:22:12 to make a very long story short.
1:22:19 So: the output of this is the result of
1:22:25 these two things here, as text.
1:22:31 This is super technical I'm not going to
1:22:33 explain that now...
1:22:35 But let me go to the
1:22:37 exercises again. We have just run the
1:22:41 exercise (l)...

;; m) [codeexample-3]

1:22:43 now we have the exercises (m) and (n).
1:22:52 (m) is also quite technical... people are
1:22:55 going to need something like this
1:22:57 if they need to run advanced examples
1:23:00 from the tutorial.
1:23:07 Let's first search for
1:23:10 "magnetic field" in the manual.
1:23:14 If we simply search for this, the
1:23:17 first occurrence of "magnetic field" in
1:23:20 the manual...
1:23:23 hm, it's probably in the page
1:23:29 565 or 566, so let me start by creating
1:23:34 links to this page of the manual.
1:23:38 Here we are. Let me copy them to my notes...
1:23:43 the string "magnetic field" appears here
1:23:47 in this figure...
1:23:53 and if the string appears here it's
1:23:56 because it also appears in the
1:23:58 source code, so let's search for it in
1:24:01 the source code.
1:24:03 Here it is: "magnetic field".
1:24:12 The exercise asks us to use this thing
1:24:16 here to find the first occurrence of
1:24:19 magnetic field in the source code of the
1:24:21 manual,
1:24:23 so we have to use this grep here.
1:24:37 Now let me create...
1:24:43 let me use this link here...
1:24:51 and now the exercise tells us to
1:24:55 create a TikZ block that runs this
1:24:57 example here.
1:25:00 But this example is not just a tikzpicture,
1:25:05 it also has some extra options -
1:25:08 here, just after the \begin{codeexample}.
1:25:13 If we just create a tikz block
1:25:20 that runs this thing here...
1:25:24 let me put that in the
1:25:28 in the tikzbody...
1:25:36 and let me try to execute this
1:25:39 thing here...
1:25:44 the show...
1:25:46 instead of saying "Success!!!" it says
1:25:51 that we had an error, and it does not
1:25:54 know how to explain what is that error.
1:25:57 So now we can run this thing here to
1:26:02 show the log of pdflatex...
1:26:07 sorry, of lualatex...
1:26:09 and the log says this:
1:26:14 is that it doesn't know how to run
1:26:18 "canvas (something)" - here.
1:26:23 it doesn't know how to run this.
1:26:26 And the trick is that we need to set
1:26:30 this "preamble=" somehow,
1:26:33 and the exercise says what we have to do...
1:26:38 it says that we have to load this
1:26:51 library here, and if we run this new
1:26:54 version of the eepitch block
1:27:01 now we have a "Success!!!" here, so
1:27:04 it has created a PDF correctly.
1:27:09 The log says the details,
1:27:12 but it's not very important now.
1:27:15 And ta-da! We were able to extract
1:27:19 that example from the manual and to
1:27:22 create an eepitch block that
1:27:27 runs that example.
1:27:32 so this was exercise (m).

;; n) [getmeaning]

1:27:34 And now we have a VERY technical
1:27:37 exercise. I mean,
1:27:41 most people who use latex are going to
1:27:44 find it completely mysterious, but
1:27:46 let me show it anyway.
1:27:51 The last exercise
1:27:53 says that
1:27:57 we have to execute the test blocks in
1:27:59 these files
1:28:02 this one here goes to the copy
1:28:06 of this file in my site - it uses wget...
1:28:10 and this one goes to the local copy.
1:28:13 Let's use this one.
1:28:21 Let me spend a few seconds more to to
1:28:25 load lua-mode, because this thing is
1:28:28 going to be much more easier to
1:28:30 understand if I...
1:28:37 oh no -
1:28:41 I'll have to cheat a bit. One second.
1:28:47 Hm,
1:28:50 you are not expected to understand this...
1:28:58 let me run this thing again...
1:29:01 Now this is going to load all packages from
1:29:04 MELPA, and it's going to display them...
1:29:09 it takes a long time...
1:29:24 wow, it's taking much longer than I
1:29:26 expected...
1:29:34 whoops...
1:29:46 let me install this thing...
1:29:57 it's installed.
1:30:00 Hm,
1:30:05 I forgot to to copy the last exercise to
1:30:10 to my TODO file - to my notes...
1:30:14 now I've copied it.
1:30:16 Now if I open the local copy of this
1:30:21 Lua file here it's probably going to
1:30:23 be able to fontify everything
1:30:27 correctly...
1:30:28 no, it didn't!
1:30:30 Anyway, sorry...
1:30:32 sorry for not having installed
1:30:36 lua-mode before. anyway now we have the
1:30:38 colors, and we can see clearly
1:30:41 that this thing is a big comment and
1:30:43 this thing is a test block,
1:30:45 and we can run this test block here to
1:30:48 understand how these
1:30:51 functions work... and this is the super
1:30:54 technical thing that I want to explain.
1:30:58 This line here
1:31:01 says that
1:31:04 we will
1:31:06 prepare a .tex file that will not
1:31:09 generate a PDF, because it will stop
1:31:11 before... it will stop in the middle of the
1:31:13 execution when lualatex is trying to
1:31:17 compile it, and it will stop because it
1:31:21 will run a REPL, and not the default
1:31:24 TeX REPL... it will run a
1:31:26 REPL in Lua
1:31:28 that is defined here... here we have
1:31:33 an explanation...
1:31:37 it says that when we run this
1:31:42 then
1:31:43 texbody will include this block of
1:31:46 code here...
1:31:50 and this block of code will
1:31:56 load a certain Lua file into lualatex,
1:32:00 and then it will run this \repl,
1:32:02 that is defined in a very mysterious
1:32:05 way.
1:32:07 Anyway let's run that in practice. If
1:32:11 we execute this,
1:32:14 then...
1:32:15 I have just saved the the .tex file, I
1:32:19 have not asked
1:32:21 my Lua files to to run latex on
1:32:24 it...
1:32:25 and now I'm going to run lualatex
1:32:29 on it inside a shell - here...
1:32:33 inside another REPL that is running a
1:32:35 shell.
1:32:36 if I run this then it
1:32:38 starts the compilation and then it gives
1:32:41 this prompt here, and this prompt here is
1:32:45 a Lua prompt.
1:32:55 And
1:32:57 now I'm going to run these things here...
1:33:02 for example, printmeaning("newpage") will
1:33:05 run a certainly mysterious thing, and it
1:33:08 will say that the definition of
1:33:11 \newpage is this thing here.
1:33:18 So \newpage is a
1:33:20 TeX macro that is defined in this way,
1:33:23 and this printmeaning(...) here will do
1:33:28 something similar, but with it will
1:33:32 use a very low level trick to discover
1:33:35 what is the current meaning of
1:33:38 "rounded corners" for TikZ...
1:33:41 so "rounded corners" has this definition
1:33:43 here... and
1:33:47 this thing is the same thing but in
1:33:49 a shorter version, and this thing is the
1:33:52 thing in an even shorter
1:33:55 version, and this one
1:34:00 shows the definition of "right", that
1:34:03 we use sometimes to specify
1:34:06 how labels have to be placed.
1:34:11 So this is a way to inspect definitions
1:34:14 from inside the Lua REPL. It's something
1:34:16 super tricky and
1:34:20 at the end of this this page here...
1:34:26 I'm not sure if if the links are already
1:34:29 there, but I'm going to explain...
1:34:31 uh, to give some links about how these
1:34:34 things work.
1:34:37 Hm, no I don't have the links right now...
1:34:42 I had to ask some questions at
1:34:46 StackExchange and StackOverflow to
1:34:49 understand how to do these things,
1:34:50 and...
1:34:54 the whole story is that I wanted to
1:34:56 do something much more complex...
1:35:00 I wanted to be able to expand a
1:35:04 \pgfkeys{...} from this REPL, and then I
1:35:07 asked the question, and then people
1:35:08 explained to me why that was impossible...
1:35:13 so what we have
1:35:16 here is something much more humble...
1:35:19 instead of of expanding
1:35:24 definitions using PGF
1:35:27 this thing here simply
1:35:31 shows what is the current definition
1:35:33 without any expansions.
1:35:37 This is a long story, it's super technical,
1:35:39 I'm going to explain more about this in
1:35:42 the page at some point, but it's...
1:35:45 I mean, here -
1:35:47 no, I mean here - but it's not ready yet.
1:35:51 And...
1:35:57 so, that's it - this finishes all
1:36:02 the exercises. Let me
1:36:05 stop the video now,
1:36:07 and then I'm going to put more material
1:36:10 in the page, and I'm going to add
1:36:12 subtitles to this video, so that people
1:36:14 can use the subtitles to
1:36:17 see how to perform the
1:36:21 exercises...
1:36:23 So, that's it. Bye!!! =)