|
Some problems of modernizing Emacs (2025)
- 1. Screenshots
- 2. Try it!
- 3. `remove-method'
- 4. Subtitles
The part of the video that corresponds to the slide 6 -
from 12:04 to 20:36 - explains a "try it!" for the ideas
of the video... you just need to run this,
and then type `f8's on the eepitch block. I
made the screenshot below by running the three red star lines in blue
at the window at the left, then splitting and balancing the window at
the right with `C-x 2 C-x 2 C-x +' and making the subwindows at the
right diplay the buffers "*Help*", "*pp*", and "*string*"; that
screenshot corresponds to what I show in the video from 14:13
to 14:57, but with the three outputs being shown at the same
time.
In 2025mar02 I asked this message on help-gnu-emacs - "How do I do a `cl-undefmethod'?" - and Stefan Monnier answered this. My original plan was to show in the video how we can
define structures with cl-defstruct, and then turn on and off
special ways of `cl-print'ing them... the "turning off" part
turned out to be hard in Elisp but easy in Common Lisp, and I decided
that in the video I would just show how do that in Common Lisp - and
readers/viewers who really, really wanted to do that in Elisp could
consider that the translation to Elisp was left as an
exercise.
The code below is here: 2025-remove-method.lisp.
The subtitles in Lua for this video are here.
The rest of this page contains a conversion of the subtitles in Lua
to a slightly more readable format.
0:00
0:01 Hi! My name is Eduardo Ochs. I'm the
0:03 author of an Emacs package called eev and
0:06 the title of this video is
0:09 "Some problems of modernizing Emacs".
1. The main themes of this video
0:11 Here is a summary of the main themes
0:14 of this video. I'm going to talk mainly
0:16 about these four things here. The first
0:18 one is that Emacs has changed a lot in its
0:21 recent versions, and now it has lots of
0:24 types... so if we want to look under the
0:27 hood and to understand what Emacs
0:30 really does we are going to stumble on
0:33 lots of types... and the
0:36 current tree of classes and types
0:40 looks like this... that is,
0:43 is quite big.
0:52 The second theme is that people used
0:55 to say things like "Anyone can learn Lisp
0:59 in one day"... I'm going to explain
1:02 this quote, and I'm also going to show
1:07 that now this is gone... anyway. This is a
1:10 very short summary... details soon.
1:14 I will also show how to display
1:16 better "inner views" of Emacs objects...
1:19 I'm going to Define what is an inner view,
1:22 of course.
1:24 The main trick is that we are going
1:26 to use one of the ways of displaying
1:30 internal objects, that is the `cl-print'
1:35 family of functions, for example,
1:38 `cl-prin1-to-string', and here are some
1:41 examples of the kind of output that we
1:43 are going to see...
1:44 for example, if we run these two lines
1:50 here the first line defines a function `foo'
1:53 and the second line sets `o' to the
1:58 internal view of the definition of `foo'.
2:00 In older Emacses `o' would be just a
2:05 list that looks... that would look very
2:08 similar to this line here... but in newer
2:11 Emacses the result of this - I mean, the
2:15 the contents of `o' is this thing herem
2:18 that looks quite different
2:21 from this definition.
2:24 So, in older Emacses
2:27 the contents of the
2:31 function cell of `o'...
2:34 sorry, of the function cell of `foo',
2:36 would be an "old-style lambda",
2:38 that would be just a list like this...
2:41 and in newer Emacses uh the contents of O would
2:45 be a "vector-like lambda"... look for the
2:48 square brackets here - this is a
2:50 vector, but it is preceded by a hash sign.
2:53 So this is what we call
2:55 a "vector-like lambda",
2:57 and vector-like lambas do not
2:59 have a canonical printed representation -
3:01 they have at least two semicanonical
3:03 printed representations...
3:05 The first semicanonical
3:07 printed representation is this one, that is
3:10 generated by a family of functions with
3:13 names like `prin1'...
3:15 and the second semicanonical printed
3:19 representation is like this -
3:23 it looks like a list...
3:26 it looks somewhat like this definition
3:29 of `foo' here, but it has this
3:33 `:dynbind' symbol here...
3:35 and it turns out that when we use
3:38 the `cl-print' family of functions we can
3:41 reconfigure how things are printed...
3:43 and I'm going to show several interesting
3:46 ways of reconfiguring how lambdas are printed,
3:53 and one of the ways is going to
3:55 be like this.
3:58 We can also use the `cl-print'
4:02 functions with my indentation tricks to
4:05 to display how types, or classes, are
4:10 viewed internally by Emacs, and this is a
4:13 big example...
4:16 This is what Emacs considers as being
4:20 the definition of the type
4:22 `cl-structure-class',
4:24 class and it is this big thing here.
4:27 I edited it very lightly...
4:30 I just uh deleted some line breaks here.
4:36 And another thing that I want to to
4:39 explain is that Emacs
4:41 has some help functions that
4:43 I have never liked...
4:45 for most people they are good enough,
4:47 but for me they aren't... they...
4:50 uh, well - I'm going to say
4:54 more about this later...
4:56 and, for example,
4:58 if we want a description of what is
5:00 this type here, that we just saw in
5:04 its internal view here...
5:06 we can run either `describe-type'
5:08 or my variant of `describe-type',
5:10 and we get a help buffer
5:13 that looks like this, in which
5:16 these blue things that are underlined
5:19 are "buttons", in the classical sense...
5:21 you can click on these buttons, or type
5:23 RET on these buttons, and you will be
5:25 taken to another help page, that is
5:28 generated dynamically...
5:30 and you can navigate back and forth...
5:34 and well, whatever...
5:36 and I'm going to explain my
5:39 problems with these kinds of help buffers
5:41 and what I'm trying to do to
5:43 overcome these problems...
2. Anyone can learn Lisp in one day
5:47 One of my slogans in this video
5:49 is going to be this one:
5:49 "Anyone can learn Lisp in one day".
5:51 this is a part of a bigger quote
5:55 that I took from a keynote presentation
5:57 by Abelson and Sussman, who
6:00 are two dinosaurs of Computer Science...
6:04 Here is the full quote:
6:06 "Anyone can learn Lisp in one day -
6:10 except that if they already know Fortran
6:12 then it would take three days."
6:17 This is a frame of the video...
6:30 By the way I am going to to add
6:34 this... "and if the person is starting
6:38 with Doom Emacs then it would take 5 years."
6:40 why? I'm going to explain why.
6:45 This is how Emacs used to be.
6:49 If we execute these two expressions here
6:52 the first one... sorry, each symbol can
6:57 have two "values",
6:59 one is its "value as a variable"
7:00 and another one is its "value as a function"...
7:04 and if we run this we store 42
7:08 in the "value cell" of the symbol `foo', and
7:13 if we run this defun here it stores a
7:17 certain anonymous function in the
7:20 "function cell" of the symbol `foo'...
7:24 and in Emacs, until some time ago
7:28 if we did that and and if we ran
7:33 this expression here the result
7:36 would be 42,
7:37 because of this line here, and if we
7:41 ran this line here the result would be
7:43 the anonymous function corresponding to
7:46 this defun here...
7:47 but now this has changed...
7:51 the result of this thing here is this
7:54 vector-like lambda here - but that doesn't
7:57 matter much now...
8:00 So, until some time ago
8:02 if we did that and if we ran
8:04 this expression here, (foo foo)...
8:07 Emacs would do this: it would
8:10 replace the first `foo' by this
8:12 anonymous function here, it would replace
8:15 the second `foo' by the value of `foo' as a
8:17 variable, that is 42,
8:19 and it would evaluate this, and the
8:22 result would be 420.
4. Lambdas for beginners broken
8:26 So, again, we used to have this slogan
8:29 here, "anyone can learn Lisp in one day"...
8:32 but now this is gone.
8:34 Let me show... let me talk
8:36 a bit more about why...
8:40 the title of this slide is
8:42 "Lambdas for beginners broken"...
8:44 if we run this, as I've shown
8:47 in the previous slide...
8:49 in the old style, in old Emacses,
8:51 the result of (symbol-function 'foo)
8:53 would be this anonymous function here...
8:55 and now we get this strange thing here.
9:00 So, this is an "old-style lambda",
9:04 this is a "vector-like lambda",
9:08 and until the middle of 2024
9:11 beginners could learn a lot of Lisp
9:14 by thinking only in terms of
9:17 objects like these...
9:19 this is a function and this
9:21 is an anonymous function, and
9:23 they would learn how to draw cons cell
9:26 diagrams like this thing here and this
9:29 thing here...
9:31 they would think on lists as
9:33 being these trees here, and they
9:35 would be able to understand a lot of
9:38 Lisp just by thinking in these terms...
9:41 and then vector-like lambdas started
9:45 to appear in many places... and if we use
9:49 "vector-like lambdas" in a wide sense,
9:52 to mean all the new objects,
9:56 these new objects, that are
10:00 difficult to visualize... they also started
10:02 to appear in many places.
5. Lambdas for beginners broken (2)
10:04 This is a continuation of the
10:07 previous slide - this part here is a copy
10:10 of things that were in the previous slide...
10:12 before 2024 beginners could
10:18 open black boxes like this...
10:23 they could try to see what was in the
10:26 function cell of the symbol `foo'...
10:30 and they would see something elegant and
10:33 mind-blowing... and they would start to love
10:35 Lisp immediately.
10:37 Now what they get - what they see -
10:39 is a tiny part of a very complex structure
10:41 that is very powerful but that is
10:45 very difficult to understand...
10:47 and now our beginners are overwhelmed
10:50 instead of mind-blown.
10:52 Note that I said "black box" here.
10:54 Let me explain the term.
10:58 We can open what's inside of `foo'...
11:03 we can open `foo' to see the contents of
11:05 the symbol `foo', and we can try to see
11:08 what's in the function cell of the
11:12 symbol `foo'...
11:14 so we can open the box, but what we get
11:16 is something very difficult to understand,
11:19 and so I'm going to say that
11:23 when this happens that box is black.
11:27 It is not totally black - we can open open it -
11:29 but we don't understand what is going on there,
11:32 so we declare that that is black.
11:36 And... when these things started to happen
11:39 _I_ was overwhelmed -
11:44 and in this video I'm going to pretend
11:46 that I was not the only person
11:50 that was overwhelmed
11:52 by these new structures
11:56 that are not so elegant
11:58 as the ones that we had before.
12:00 Anyway...
6. For the impatient: try this
12:04 Anyway, before going ahead
12:07 I need to explain how technical
12:09 this video is going to be.
12:10 I hate videos that present things
12:12 that look fantastic
12:15 but that are very hard to install,
12:18 and I've been experimenting
12:22 with things that can be installed -
12:25 usually in /tmp/,
12:27 so in a very temporary place -
12:29 in seconds, so they don't even
12:31 leave garbage in your system...
12:35 So, in the page of this video
12:39 there will be something like this...
12:42 you just need to copy that
12:44 to a temporary buffer and execute that
12:46 with a series of f8s, and then the rest
12:49 will hopefully
12:51 be somewhat obvious...
12:53 this part here will download three files
12:57 into /tmp, and these things these things
13:01 here will show some tests.
13:04 Let me execute these tests
13:07 and explain what they do.
13:09 I will need a smaller font...
13:13 if we run this `code-c-d' we just make
13:18 this prefix here point to /tmp/...
13:20 we are going to put that in the load-path...
13:24 and then we're going to to load
13:29 my new definitions of `cl-print'
13:31 for some default Lisp objects...
13:33 and with these new definitions
13:36 if I run this it shows...
13:39 well, this is my file
13:45 2025modern-prints.el...
13:47 and it has lots of tests,
13:50 and if we execute this test here
13:55 we are going to see that when we run
13:57 this `setq' here
14:01 it shows the result of the...
14:04 the contents of the function cell
14:06 of `adt-2'...
14:09 and the default representation
14:11 is this thing here, that is very ugly...
14:13 but we have other ways of
14:17 inspecting that...
14:21 so the first way is the default way,
14:25 we just ask Emacs to "describe"
14:29 what is the function `adt-2'...
14:31 and it shows that `adt-2' is an
14:35 "interpreted-function" that has two
14:38 "advice"s, whatever that means...
14:41 and if I run this thing here to show
14:45 my redefinition...
14:48 one of the internal representations of `adt-o'...
14:54 result is this, that is quite pretty...
14:57 a nice internal view of an advice object...
15:05 and if we load this file here,
15:09 2025-modern-reset.el, it resets the
15:13 definitions of `cl-print' to the default ones...
15:16 so if we run this and we ask Emacs
15:20 to to print the contents of `adt-o'
15:23 we are going to get this...
15:27 so it's indented in a weird way,
15:30 it's not easy to understand, blah
15:32 blah blah blah...
15:34 but we can load 2025-modern-prints.el
15:38 again to use my new definitions again
15:42 and this thing becomes pretty again...
15:44 and with these new definitions
15:49 we can also print, for example,
15:50 the definition of a class.
15:52 And this is exactly what I've
15:55 shown before, except that
16:00 we need to delete some line braks here
16:03 to make things slightly easier to read...
16:05 but whatever - let's go back.
16:11 And I was also mentioning my problems
16:14 with the Emacs help pages.
16:16 This file here, 2025-modern-button.el,
16:19 loads some functions for exploring these
16:22 help pages and its buttons,
16:25 and we have some examples here...
16:26 oops, sorry...
16:32 here...
16:34 Let me show this example here.
16:38 First I'm going to define a structure
16:41 called `mybutton' - the name is bad, sorry...
16:44 and if we ask Emacs to describe
16:47 this structure in the default way
16:50 it says that mybutton is a type,
16:53 that has these fields here, and whatever...
16:57 and these are the buttons that I don't like...
16:59 and if I execute this thing here -
17:04 that is a "piano roll macro", that I
17:06 explained in a previous video...
17:09 this thing here is going to simulate that
17:11 the user is typing all these keys here...
17:15 please pay attention to what happens here...
17:17 we are going to switch to this window,
17:20 and then we're going to to type a series
17:22 of tabs to navigate between the buttons...
17:25 we're going to stop at this button here,
17:27 we're going to do something,
17:29 and this something will appear here,
17:32 in the minibuffer. So, take a look...
17:38 here... then here.
17:42 and now we defined a variable
17:46 called `ee-button' and it points to this
17:51 position in this buffer...
17:53 and this file here -
17:55 2025-modern-button.el - has several tools
17:57 for exploring these buttons, and the best way
17:59 of exploring these buttons is to use this
18:01 other function here, `find-ebutton-links',
18:04 that also sets this variable, but that shows
18:07 some functions for exploring these buttons.
18:11 Let me show... it will do
18:13 something very similar - it will navigate
18:15 to this button here and then it will
18:18 execute `M-x find-ebutton-links'...
18:22 look...
18:30 it creates this temporary buffer here,
18:33 and these functions that start with
18:35 `find-3a-button'... they divide the window...
18:40 they divide the Emacs frame in three windows...
18:42 they show the "*Help*" buffer here...
18:46 remember that the cursor is here,
18:49 on the button that we are trying
18:52 to understand...
18:55 and they show some other output in the
18:57 third window here.
18:59 This first call here, with (ee-button-helpcall),
19:01 shows what this button "calls"...
19:05 for technical reason the prefix for that
19:08 is "help"...
19:12 the "helpcall" associated to this
19:17 button is this one... if we format it in a
19:20 slightly different way it is this...
19:25 and if we pretty-print the contents of a
19:28 certain big structure and display it
19:31 in this window we see that the text
19:34 properties at this position are all
19:37 these ones here... they are sorted in
19:39 alphabetical order...
19:40 and then... sorry...
19:47 we can delete the ones that are
19:51 not very interesting, and we get this...
19:54 so, this gives us a lot of information about
19:57 this button here, but it deletes some
20:01 things that are not very interesting...
20:03 and here we can see how we can extract the
20:06 "helpcall" from this button here.
20:09 The "helpcall" is this thing here -
20:13 it calls `describe-function' with the
20:15 argument `cl-print-object'...
20:17 and we can see here that the `help-function'
20:21 associated to this button here
20:24 is `describe-function', and the `help-args'
20:26 are this list here: (cl-print-object).
20:30 And other things are not... are very
20:34 hard to explain, so I'm not going to
20:36 explain them now.
|