-hello EmacsConf +Hello, EmacsConf!
-thanks very much first of all to the +00:00:04.160 --> 00:00:05.279 +Thanks very much, first of all,
-organizers of the conference +00:00:05.280 --> 00:00:07.200 +to the organizers of the conference
-and to the audience who I hope is out +00:00:07.200 --> 00:00:08.800 +and to the audience,
-there somewhere +00:00:08.801 --> 00:00:10.480 +who I hope is out there somewhere,
-uh for giving me this chance to talk +00:00:10.480 --> 00:00:11.679 +for giving me this chance
-about Emacs and some of my uh +00:00:11.680 --> 00:00:12.880 +to talk about Emacs
-my poking around with Emacs lisp my name +00:00:12.881 --> 00:00:16.240 +and some of my poking around with Emacs Lisp.
-is eric abrahamson I'm not +00:00:16.241 --> 00:00:17.680 +My name is Eric Abrahamsen.
-a professional programmer but I use +00:00:17.681 --> 00:00:20.480 +I'm not a professional programmer,
-Emacs all day +00:00:20.481 --> 00:00:23.039 +but I use Emacs all day, every day,
-every day for writing for translating +00:00:23.040 --> 00:00:24.800 +for writing, for translating,
-for project management +for project management,
-and most importantly for email which +00:00:26.160 --> 00:00:27.920 +and most importantly, for email,
-will be the +00:00:27.921 --> 00:00:30.640 +which will be the subject of my talk today.
-subject of my talk today so I'm talking +00:00:30.641 --> 00:00:32.880 +So I'm talking about
-about object-oriented code in Emacs +00:00:32.881 --> 00:00:34.160 +object-oriented code
-uh most famous possibly oldest +00:00:34.161 --> 00:00:38.320 +in Emacs' most famous, possibly oldest,
-definitely most notorious news reader +00:00:38.320 --> 00:00:39.520 +definitely most notorious
-slash Emacs client +00:00:39.521 --> 00:00:42.800 +news reader / email client,
-email client so in particular object +00:00:42.801 --> 00:00:44.000 +so, in particular,
-oriented code +00:00:44.001 --> 00:00:46.000 +object-oriented code in Gnus.
-in news why object-oriented code +00:00:46.001 --> 00:00:50.239 +Why object-oriented code?
-the way news works is it started off as +00:00:50.239 --> 00:00:51.199 +The way Gnus works is
-a news reader so for access +00:00:51.200 --> 00:00:52.480 +it started off as a news reader,
-accessing nntp servers and later on grew +00:00:52.481 --> 00:00:55.920 +so for accessing NNTP servers
-a whole bunch of new functionality as a +00:00:55.921 --> 00:00:57.600 +and later on grew a whole bunch
-mail client so it can talk to imap +00:00:57.601 --> 00:00:59.760 +of new functionality as a mail client,
-servers +00:00:59.761 --> 00:01:02.079 +so it can talk to IMAP servers,
-mail dealer directories uh folders on +00:01:02.079 --> 00:01:04.320 +Maildir directories,
-your file system all kinds of stuff +00:01:04.321 --> 00:01:05.360 +folders on your file system,
-but it presents a unified interface to +00:01:05.361 --> 00:01:06.640 +all kinds of stuff,
-all those things so it's basically +00:01:06.640 --> 00:01:08.320 +but it presents a unified interface
-polymorphism +00:01:08.321 --> 00:01:08.960 +to all those things,
-one of the the basic fundamental +00:01:08.961 --> 00:01:11.040 +so it's basically polymorphism,
-principles of object oriented code so +00:01:11.040 --> 00:01:14.560 +one of the the basic fundamental principles
-it's a good fit second reason is it +00:01:14.561 --> 00:01:15.680 +of object oriented code.
-already is +00:01:15.681 --> 00:01:17.600 +So it's a good fit.
-object oriented and I'll get into what +00:01:17.601 --> 00:01:21.439 +Second reason is it already is object-oriented,
-that means +00:01:21.440 --> 00:01:25.280 +and I'll get into what that means in a second.
-in a second so +00:01:25.281 --> 00:01:28.479 +So the background that you should know
-the background that you should know is +00:01:28.480 --> 00:01:30.000 +is that most of this code
-that most of this code was written in -
-the 90s +00:01:30.001 --> 00:01:32.560 +was written in the 90s.
-Emacs lisp has only grown sort of -
-official +Emacs Lisp has only grown sort of
-object orientation support libraries +00:01:34.881 --> 00:01:38.640 +official object orientation support libraries
-over the past 10 years or so -
-from about 2010 to the present so what -
-does -
-news do so the basics of +over the past 10 years or so,
-object orientation in most languages are +00:01:41.200 --> 00:01:42.799 +from about 2010 to the present.
-you you define +00:01:42.800 --> 00:01:45.920 +So what does Gnus do?
-a class of some sort and then you +00:01:45.921 --> 00:01:49.520 +So the basics of object orientation
-instantiate that class and these +00:01:49.521 --> 00:01:50.560 +in most languages are:
-class instances have two things they +00:01:50.560 --> 00:01:53.439 +you define a class of some sort,
-have data attributes or +00:01:53.440 --> 00:01:55.040 +and then you instantiate that class.
-slots or members or whatever you're +00:01:55.041 --> 00:01:57.920 +These class instances have two things:
-going to call them and they have +00:01:57.921 --> 00:02:00.719 +they have data attributes (or slots,
-methods which operate on individual +00:02:00.720 --> 00:02:01.680 +or members, or whatever
-instances +00:02:01.681 --> 00:02:02.640 +you're going to call them),
-so you could say that you create or +00:02:02.641 --> 00:02:05.600 +and they have methods
-instantiate an instance of a class in +00:02:05.601 --> 00:02:08.399 +which operate on individual instances.
-that instance +00:02:08.399 --> 00:02:10.239 +So you could say that
-owns two things that owns its set of +00:02:10.240 --> 00:02:11.840 +you create or instantiate
-attributes +00:02:11.841 --> 00:02:12.800 +an instance of a class,
-and it owns some methods which +00:02:12.801 --> 00:02:14.800 +and that instance owns two things.
-also work on the on the instance +00:02:14.801 --> 00:02:17.120 +That owns its set of attributes,
-so both in nurse's existing code and in +00:02:17.120 --> 00:02:19.520 +and it owns some methods,
-the more standard object oriented Emacs +00:02:19.521 --> 00:02:23.280 +which also work on the instance.
-lisp libraries +00:02:23.280 --> 00:02:25.680 +Both in Gnus' existing code
-this relationship is turned on its head +00:02:25.681 --> 00:02:28.560 +and in the more standard object-oriented
-a little bit +00:02:28.561 --> 00:02:31.680 +Emacs Lisp libraries, this relationship
-in that data slots and +00:02:31.681 --> 00:02:34.080 +is turned on its head a little bit,
-uh and instance methods are defined +00:02:34.080 --> 00:02:39.599 +in that data slots and instance methods
-outside of the +00:02:39.600 --> 00:02:41.760 +are defined outside of the class
-class or the instances themselves so +00:02:41.761 --> 00:02:42.959 +or the instances themselves.
-they are top level definitions +They are top-level definitions.
-so we'll get to what that means in the +We'll get to what that means
-in the newer libraries um +00:02:46.879 --> 00:02:48.720 +in the newer libraries in a bit,
-in a bit but uh first I want to talk +00:02:48.721 --> 00:02:49.920 +but first I want to talk about
-about how news does this and in order to +00:02:49.921 --> 00:02:51.280 +how Gnus does this.
-do that we are going to go deep into +00:02:51.281 --> 00:02:52.160 +In order to do that,
-the darkest corner of the new co source +00:02:52.161 --> 00:02:54.319 +we are going to go deep into
-code tree to a library called +00:02:54.319 --> 00:02:55.760 +the darkest corner
-nno.l very cryptically +00:02:55.761 --> 00:02:58.080 +of the Gnus source code tree
-titled uh library and when we open it up +00:02:58.081 --> 00:03:01.440 +to a library called nnoo.el,
-we find +00:03:01.441 --> 00:03:04.080 +very cryptically-titled library,
-a library with no code comments and +00:03:04.081 --> 00:03:06.800 +and when we open it up, we find
-almost no doc strings +00:03:06.800 --> 00:03:09.280 +a library with no code comments + +00:03:09.281 --> 00:03:11.040 +and almost no doc strings.
-almost as if lars was a little ashamed +Almost as if Lars was a little ashamed--
-not ashamed but knew he was doing +not ashamed, but knew he was doing
something a little bit crazy
-and didn't want anyone to see so +00:03:16.000 --> 00:03:18.080 +and didn't want anyone to see.
-this file contains the the object +00:03:18.081 --> 00:03:20.560 +So this file contains
-oriented mechanism +00:03:20.561 --> 00:03:22.400 +the object-oriented mechanism
-whereby you can define different kinds +00:03:22.400 --> 00:03:23.920 +whereby you can define
-of back ends for news +00:03:23.921 --> 00:03:25.760 +different kinds of backends for Gnus,
-and then those back ends can be +00:03:25.760 --> 00:03:26.799 +and then those backends
-instantiated as individual +00:03:26.800 --> 00:03:30.879 +can be instantiated as individual servers.
-servers and as you define these backends +00:03:30.880 --> 00:03:32.480 +As you define these backends,
-you're supposed to use +00:03:32.480 --> 00:03:34.319 +you're supposed to use two macros,
-two macros which you can see here one is +00:03:34.320 --> 00:03:35.680 +which you can see here.
-called def +00:03:35.681 --> 00:03:37.280 +One is called defvoo,
-vu and one is called defu and if you +00:03:37.281 --> 00:03:39.440 +and one is called deffoo.
-look at the definitions the definitions +00:03:39.441 --> 00:03:40.400 +If you look at the definitions,
-look pretty simple here def vu basically +00:03:40.401 --> 00:03:41.920 +the definitions look pretty simple.
-turns into a def var +00:03:41.921 --> 00:03:45.440 +Here, defvoo basically turns into a defvar
-and foo turns into a defund +and foo turns into a defun.
-and along with those basic definitions +Along with those basic definitions,
-the library also does some registration +the library also does some registration,
-memoization caching of those variables -
-it saves them in the structure -
-for later use so that we know that those -
-are meant to be -
-uh attributes and methods that are used +memoization, caching of those variables.
-with instances +00:03:58.720 --> 00:04:00.879 +It saves them in the structure for later use,
-with server instances but you can see +00:04:00.880 --> 00:04:03.360 +so that we know that those are meant to be
-that there's no server instance +00:04:03.360 --> 00:04:04.799 +attributes and methods
-definition here there's no +00:04:04.800 --> 00:04:06.640 +that are used with instances,
-like no nothing these are top level +00:04:06.640 --> 00:04:07.519 +with server instances.
-these are top level +00:04:07.520 --> 00:04:08.159 +But you can see that
-definitions so really data attributes +00:04:08.160 --> 00:04:10.000 +there's no server instance definition here.
-for +00:04:10.001 --> 00:04:12.159 +There's no, like, no nothing.
-new servers and +00:04:12.160 --> 00:04:14.799 +These are top-level definitions,
-methods or functions that operate on +00:04:14.800 --> 00:04:20.239 +so really, data attributes for new servers
-those instances are completely +00:04:20.240 --> 00:04:23.040 +and methods or functions
-separate mechanisms they don't really +00:04:23.041 --> 00:04:24.639 +that operate on those instances
-have anything to do with each other they +00:04:24.640 --> 00:04:27.840 +are completely separate mechanisms.
-don't belong to the same data structures +00:04:27.841 --> 00:04:29.040 +They don't really have anything to do
-so how do they work follow me +00:04:29.041 --> 00:04:29.520 +with each other.
-aka methods and attributes these are all +00:04:29.521 --> 00:04:31.680 +They don't belong to the same data structures.
-the things I just said +00:04:31.680 --> 00:04:34.080 +So how do they work?
-so when you define a +00:04:34.081 --> 00:04:37.120 +Follow me. deffoo and defvoo,
-a backend type +00:04:37.120 --> 00:04:38.960 +aka methods and attributes,
-in noose what you get is this a +00:04:38.961 --> 00:04:41.360 +these are all the things I just said.
-definition a list +00:04:41.360 --> 00:04:50.240 +So when you define a a backend type in Gnus,
-and it'll say there is such a back end +00:04:50.241 --> 00:04:52.400 +what you get is this: a definition, a list.
-as nnml +00:04:52.400 --> 00:04:55.520 +It'll say, there is such a backend as nnml,
-and these are its uh data attributes +and these are its data attributes
-that any +00:04:58.880 --> 00:05:01.039 +that any given instance can have,
-given instance can have and then these +00:05:01.040 --> 00:05:04.720 +and then these are the functions or methods
-are +00:05:04.721 --> 00:05:06.880 +that are defined to operate on
-the functions or methods that are +00:05:06.880 --> 00:05:08.240 +an instance of this backend,
-defined to operate on +00:05:08.241 --> 00:05:09.600 +so a server that belongs to
-an instance of this backend so a server +00:05:09.601 --> 00:05:12.160 +the nnml backend.
-that belongs to the nnml +00:05:12.161 --> 00:05:13.600 +So at least we have this data here.
-backend so at least we have this data +00:05:13.601 --> 00:05:16.080 +That's handy. We don't really touch that.
-here so that's that's handy we don't you +00:05:16.081 --> 00:05:19.600 +That's, like, very, very, very deep Gnus code
-don't really touch that that's like very +00:05:19.601 --> 00:05:20.560 +that doesn't really come up
-very very deep +00:05:20.560 --> 00:05:25.199 +even as a bug squasher or whatever.
-um use code that doesn't really come up +00:05:25.200 --> 00:05:26.160 +We don't touch that very often,
-even as a +00:05:26.161 --> 00:05:26.800 +but there they are,
-even as a bug squasher or whatever we +00:05:26.801 --> 00:05:29.199 +and that's how they work.
-don't touch that very often but there +00:05:29.200 --> 00:05:31.039 +Now the next thing that obviously
-they are and that's +00:05:31.040 --> 00:05:32.080 +you want to know is, okay,
-that's how they work now the next thing +00:05:32.080 --> 00:05:33.759 +where are... if I've started up Gnus,
-that obviously you want to know is okay +00:05:33.760 --> 00:05:35.039 +where are my servers?
-where are if I've started up news where +00:05:35.039 --> 00:05:36.880 +Where are these server objects,
-are my servers +00:05:36.881 --> 00:05:40.479 +since this is object-oriented programming?
-uh where are these server objects since +00:05:40.480 --> 00:05:41.520 +And the weird thing
-this is object oriented +00:05:41.521 --> 00:05:43.759 +that you will eventually figure out
-programming and the weird thing that you +00:05:43.760 --> 00:05:45.680 +(in some cases, after years of poking around)
-will eventually +00:05:45.681 --> 00:05:46.880 +in the Gnus source code
-figure out in some cases after years of +00:05:46.880 --> 00:05:48.880 +is that servers do not exist
-poking around in the new source code +00:05:48.881 --> 00:05:51.360 +in an ontological, philosophical sense,
-is that servers do not exist in an +00:05:51.361 --> 00:05:55.280 +as objects. The primary data structures of Gnus
-ontological +00:05:55.281 --> 00:05:58.160 +are groups, and in sort of
-philosophical sense as objects the +00:05:58.161 --> 00:06:00.560 +an object-oriented hierarchical mindset,
-primary data structures of noose are +00:06:00.561 --> 00:06:03.039 +you'd think, well, groups belong to servers,
-groups +00:06:03.040 --> 00:06:05.759 +so servers must exist, but they don't.
-and in sort of an object-oriented +00:06:05.759 --> 00:06:07.840 +Each group... And here you can see
-hierarchical you know mindset you'd -
-think well -
-groups belong to servers so servers must -
-exist but they don't -
-each group and here you can see some -
-examples of groups +00:06:07.841 --> 00:06:09.360 +some examples of groups...
-these are basically the data structures +These are basically the data structures
-that represent a group each group also +00:06:11.199 --> 00:06:12.240 +that represent a group.
-has a little entry here that +00:06:12.241 --> 00:06:14.160 +Each group also has a little entry here
-that tells you what server it belongs to +00:06:14.161 --> 00:06:17.039 +that tells you what server it belongs to,
-and each group +00:06:17.039 --> 00:06:20.080 +and each group replicates that data,
-replicates that data uh saying which +00:06:20.081 --> 00:06:21.600 +saying which server it belongs to.
-server it belongs to and so when +00:06:21.601 --> 00:06:24.000 +So when Gnus is going through
-nurse is going through doing its +00:06:24.001 --> 00:06:25.280 +doing its business,
-business uh trying to figure out what's +00:06:25.281 --> 00:06:27.039 +trying to figure out updating mail
-like updating mail from the groups or +00:06:27.040 --> 00:06:28.479 +from the groups or whatever,
-whatever almost every time +00:06:28.480 --> 00:06:30.960 +almost every time, it will cycle through
-it will cycle through all the list of -
-groups it'll +00:06:30.961 --> 00:06:32.960 +all the list of groups.
-it'll look at all the server definitions -
-and it will categorize the groups by +It'll look at all the server definitions,
-server +00:06:34.960 --> 00:06:38.160 +and it will categorize the groups by server,
-which which is just weird because you're +00:06:38.160 --> 00:06:40.000 +which is just weird,
-sort of looking for okay where does the +00:06:40.001 --> 00:06:41.680 +because you're sort of looking for...
-server exist it doesn't exist it's put +00:06:41.681 --> 00:06:42.720 +okay, where does the server exist?
-together +00:06:42.721 --> 00:06:43.440 +It doesn't exist.
-every time uh out of out of code +00:06:43.441 --> 00:06:46.240 +It's put together every time
-elsewhere in the news code base +00:06:46.241 --> 00:06:50.400 +out of code elsewhere in the Gnus code base,
-specifically from these group +00:06:50.400 --> 00:06:53.599 +specifically from these group definitions.
-these group definitions and so this is +00:06:53.600 --> 00:06:54.479 +So this is very odd,
-very odd because +00:06:54.480 --> 00:06:56.319 +because in some sense...
-in in some sense like here this one its +00:06:56.320 --> 00:06:59.360 +Like here, this one, its server is nnml
-server is +00:06:59.361 --> 00:07:01.680 +and an empty string,
-nnml and an empty string so there's a +00:07:01.681 --> 00:07:02.880 +so there's a certain sense here
-certain sense here in which this server +00:07:02.881 --> 00:07:04.720 +in which this server is not really
-is not +00:07:04.721 --> 00:07:06.160 +an object at all. What it is
-really an object at all what it is is a +00:07:06.161 --> 00:07:07.120 +is a set of instructions
-set of instructions for how to find +00:07:07.121 --> 00:07:08.560 +for how to find messages,
-messages +00:07:08.560 --> 00:07:10.319 +and this set of instructions is:
-and this set of instructions is go to +00:07:10.320 --> 00:07:12.000 +go to the default place
-the default place where the user +00:07:12.001 --> 00:07:14.000 +where the user might have their mail
-might have their mail and expect to find +00:07:14.001 --> 00:07:16.319 +and expect to find messages there
-messages +00:07:16.320 --> 00:07:18.479 +in an nnml format, which is basically
-there in an nml format which is +00:07:18.480 --> 00:07:21.759 +just one message per file.
-basically just one message per +00:07:21.760 --> 00:07:22.720 +Any number of groups could have
-um per file and any number of groups +00:07:22.721 --> 00:07:24.400 +those same instructions, but they're not...
-could have those same instructions uh -
-but they're not it's not really a thing +00:07:24.401 --> 00:07:25.440 +It's not really a thing.
-it's really just a +It's really just a...
-it's more of a procedural instruction -
-and on the other end of the spectrum you +It's more of a procedural instruction.
-might have an nni map +00:07:28.639 --> 00:07:30.160 +On the other end of the spectrum,
-server which very much is a thing it has +00:07:30.161 --> 00:07:32.240 +you might have an nnimap server,
-its own it has its own server its own +00:07:32.241 --> 00:07:33.280 +which very much is a thing.
-port its own authentication +00:07:33.281 --> 00:07:36.160 +It has its own server, its own port,
-system so some of the servers are more +00:07:36.161 --> 00:07:38.960 +its own authentication system.
-like things some of the servers are more +00:07:38.961 --> 00:07:40.639 +So some of the servers are more like things,
-like instructions +00:07:40.640 --> 00:07:42.400 +some of the servers are more like instructions.
-as news works right now um these +As Gnus works right now,
most of the servers are treated like
-just instruction sets +just instruction sets,
-and and there's no place where you can +and there's no place where you can
-go and find them there's no one central +00:07:50.880 --> 00:07:51.840 +go and find them.
-uh variable that defines them all so how +00:07:51.841 --> 00:07:53.680 +There's no one central variable
-do the +00:07:53.681 --> 00:07:56.160 +that defines them all. So how do the...
-um so we'll talk about the methods in a +00:07:56.160 --> 00:07:57.759 +We'll talk about the methods in a second.
-second how do the data attributes work +00:07:57.760 --> 00:07:59.520 +How do the data attributes work?
-uh put very crudely um +Put very crudely,
-your servers when they're put together +your servers, when they're put together,
-uh they are okay they are +00:08:04.479 --> 00:08:06.879 +they are kept in a variable,
-kept in a variable and it's called nno +00:08:06.880 --> 00:08:08.080 +and it's called nnoo
nno -- cgit v1.2.3