summaryrefslogblamecommitdiffstats
path: root/2022/captions/emacsconf-2022-orgvm--orgvm-a-simple-http-server-for-org--corwin-brust--main.vtt
blob: 7ee7fca6a56e2efc58964c3f884324d7b152c42f (plain) (tree)
1
2
3
4
5
6
7
8
9
                          
 
                 

                             
                                
 

                                     
 

                                          
 

                                                    

                             
                         
 

                                             
 

                                          
 

                                     
 

                                                 

                             
                      

                             
                                   

                             
                               

                             
                                 
 

                                         
 

                             
 

                               
 

                                        
 
                   
 

                                                
 

                             
 

                                                  
 

                               
 

                                          

                             
                           

                             
                                         

                             
                                             

                             
                                   

                             


                                       

                             
                                      

                             
                                   

                             
                                                           

                             
                

                             
                                                

                             
                                                       

                             
                     

                             
                       

                             
                                                

                             
                                                       

                             
                   

                             
                                 

                             
                                    

                             
                                      

                             
                                       
 

                                
 

                             

                             


                                       
 

                              
 

                                 

                             
                                                

                             
                           
 

                                          
 

                                      

                             
                                            

                             
                     

                             
                                                  

                             
                          

                             
                                                  

                             
                                                     

                             



                                          
 

                                   
 
         

                             
                               

                             
                                    

                             
                        

                             
                                                

                             
                       

                             
                                    

                             
                             

                             
                                          

                             
                               

                             
                                                       

                             
                                                            
 

                                             
 

                                                      

                             
                                                 

                             
                        

                             
                                   

                             
                         

                             
                                  
 

                             
 

                                    

                             
            
 

                                                    
 

                                

                             


                                               

                             
                                                

                             
                                    

                             
                                                     

                             
                                                           

                             
                                            

                             
                                               

                             
                                   

                             
                               

                             
                                           

                             
                                
 

                                         
 

                                    

                             
                              

                             
                                            

                             



                                            
 

                                                        
 
                   

                             
                                                           

                             
                                                  

                             
                                                  

                             
                                                  

                             
                                   

                             
                                         

                             
                                         

                             
                       

                             
                                            
 

                                        
 

                             

                             
                              

                             
                                                

                             
                                     

                             
                                

                             
                                                      

                             
                                           

                             
                                                   

                             
                                                      
 

                                                  

                             
                               

                             
                               

                             
                                

                             
                                         

                             
                                       

                             
                                 

                             


                                          

                             
                                                      

                             
                                                        

                             
                                  

                             
                                                 

                             
                                 

                             
                                      

                             
                         

                             
                                     

                             
                        

                             
                                                          

                             
                    

                             
                                

                             
                                        

                             
                            

                             
                                                      

                             
                  

                             
                                                     

                             


                                                         

                             
                                               
 

                                                 
 

                             

                             
                                        

                             
                                  

                             
                                       

                             
                                         

                             
                             

                             
                                                   

                             
                                                 

                             
                              

                             
                              

                             
                                  

                             
                                 
 

                                                  
 

                                

                             
                                  

                             
                                

                             
                                                            

                             
                                      

                             
                                          

                             
                                               

                             
                                        
 

                                           
 

                             
 
            

                             
                                   

                             
                                       
 

                                    
 

                             
 




                                        

                             
                                             

                             
                                          

                             
                                             

                             
                                                  
 

                                      
 

                             
 

                                                  
 
                                    

                             
                                                     

                             
                                            
 

                              
 

                                

                             
                        

                             
                                                        

                             
                                                

                             
                                                

                             
                

                             
                                  
 

                                              
 

                                    

                             
                                      

                             
                                             

                             
                               

                             
                            

                             
                                          

                             
                                            

                             
                                             

                             
                                       

                             
                                               

                             
                                       

                             
                                                         

                             
                                            

                             
                                                 

                             
                                                    

                             
                                

                             
                            

                             
           

                             


                               

                             
                                               

                             
                                 

                             
                                             

                             
                                         

                             
                                  

                             
                                                      

                             
                                             

                             


                         

                             
                                        

                             
                                 

                             
                                         

                             
                                

                             
         

                             
                         

                             
                           

                             
                                                 

                             
                           

                             
                                     

                             
                           

                             
                                                        

                             
                                          

                             
                              

                             
                                

                             
                                                    

                             
                                        

                             
                                             

                             


                                                  

                             
                                                          
 

                                              
 

                                                            

                             
                                              

                             
                                   

                             
                                                            
 

                                          
 

                                           

                             
                                   

                             
                                      

                             
                        

                             
                                             

                             
                                              

                             
                                       

                             
                                                  

                             
                                                   
 

                                                  
 

                                                

                             
                                    

                             
                                

                             
                                                    

                             
                                      

                             
                       

                             
                                 

                             
                                              

                             
                                           

                             
                                

                             
                                                   

                             
                                          

                             
                                        

                             


                                         

                             
                                      

                             
                                  

                             
                                                     

                             
                                                    

                             
                              

                             
                                                 

                             
                                
 

                                           
 

                             

                             
                                                 

                             
                                                 

                             
                              

                             
                             

                             
                                            

                             
                                                

                             
                                       

                             
                            
 

                                  
 

                             

                             
                              
 

                                                  
 

                             
 

                                          

                             
                                                 
 

                             
 

                                  

                             
                                                 

                             
                                      

                             
                         

                             
                   

                             
                              

                             
                       

                             
                                              

                             
                

                             
                         

                             
                                    

                             
                            

                             
        

                             
                               

                             
                                

                             
                            

                             
                                         

                             
                     

                             
                                                    

                             
                   

                             
                                                   
 

                                  
 

                                    

                             



                               
 

                                             
 
                         

                             
                                             

                             
                                             

                             
                                

                             
                                              

                             
                                  

                             
                                            

                             
                       

                             
                                  

                             
                                                

                             
                                      

                             
                                         

                             
                                                   

                             
                                                     
 

                                           
 

                             

                             
                                                

                             
                        

                             
                                  

                             
                                                        

                             
                    

                             
                                                        

                             
                                  

                             
                            

                             
                                    

                             
            

                             
                                               

                             
                       

                             
          

                             
                                         

                             
                           

                             
                                        

                             
                                

                             
                     

                             
            

                             
                                          

                             
                                              

                             
                                                

                             
                                            

                             
                                                         

                             
                                                       

                             
          

                             
                           

                             
                                      

                             
                                             

                             
                                                    

                             
                    

                             
                                             

                             
                                     

                             
                                         

                             
                                                

                             
                       

                             
              

                             
                                               

                             
                               

                             
                                               

                             
                             

                             
                                             

                             


                             

                             
                                      

                             
                                         

                             
                                 

                             
                                   

                             
               

                             
            

                             
                               

                             
                      

                             
                                    
 

                                        
 

                             
 

                                      
 

                             

                             
                                       

                             
                             

                             
                                     

                             
                                                     

                             
                                        

                             
                                 

                             
                                                     

                             
                                              

                             
                        

                             
                                              

                             
                                    

                             
                                           

                             
                                     

                             
                                 

                             
                                       

                             
                                         

                             
                                                       

                             
                                                  

                             
          

                             
                                             

                             
                                      

                             
                                                    

                             
                                   

                             
                                            

                             
                                       

                             
                                  

                             
                                

                             
                                                   

                             
                                  

                             
                                              

                             
                                         

                             
                                                  

                             
                                 

                             
                                                

                             
                                 

                             
                            

                             
                               

                             
                                        

                             
                                             

                             
                                      

                             
                                                 

                             
                          
 

                                                         
 

                                   

                             
                                                          

                             
                                 

                             
          

                             
                                                 

                             
                              

                             


                                               

                             
                                                   

                             
                                                  

                             
                                        

                             
                                               

                             
                                          

                             
                       

                             
                                    

                             
                                            

                             
                                                

                             
                                                        

                             
                                              

                             
                                           

                             
                        

                             
                           

                             
                                                  

                             
                                        

                             
                        

                             
                                   

                             
                                           

                             
                                      

                             
          

                             
                                                    

                             
                                 

                             
                   

                             
                                 
 

                                                        
 

                                      

                             
                                               

                             
                    

                             
                                 

                             
                                                        

                             
                                                            

                             
                                                      

                             
                                   

                             
                                                       
 

                                          
 

                             

                             
                           

                             
                                                       

                             
                                         

                             
                                

                             
                                           

                             
                                                        
 

                             

                             
                       

                             
                         

                             
                

                             
                                     

                             
                 

                             
                 

                             
                            

                             
          

                             
                    

                             
                       
 

                             
 

                             

                             
                                                       

                             
                                 

                             
                                                       

                             
                                            

                             
                

                             
                                                   

                             
                

                             
                                                     

                             
          

                             
                                    

                             
                                                    

                             
                                           

                             
                                            

                             
                         

                             
                                         

                             
                                         

                             
                          

                             
                                               

                             
              

                             
                                                       

                             
     

                             
          

                             
              
 

                                       

                             
                          

                             
                   

                             
                                       

                             
                                                         

                             
            

                             
          

                             
                                              

                             
                                                  

                             
                    

                             
                                                      

                             
                                       

                             
                          

                             
          

                             
                                    

                             


                                           

                             
                                                   

                             
                  

                             
                                              

                             
                                                            
 

                                        
 

                                   

                             
                                           

                             
                                           

                             
                                

                             
                          

                             
                                                       

                             
                                       

                             
                                                          

                             
                       
 

                             
 

                                           

                             
                                             

                             
                      

                             
                                                          

                             
                       
 
                          

                             
                                                           

                             
                                        

                             
                                                            

                             
                               

                             
                                                          

                             
                              

                             
                                   

                             
                                                        

                             
                     

                             
                                             

                             
                                    

                             
                        

                             
                                  

                             
                                       

                             
                               

                             
                                              

                             
                  
 

                              
 

                               

                             
                          

                             
                              

                             
                                           

                             
                                                        

                             
           

                             
                     

                             
                                         

                             
                                                         

                             
                               

                             
                                                            

                             
                   

                             
                  

                             
                    

                             
                                                     

                             
                  

                             
                               

                             
                                                          

                             
                                               

                             
                                                    

                             
                              
 

                             
 

                                     

                             
                                                

                             
                

                             
                                            

                             
                         

                             


                                                  

                             
                                             

                             



                                   
 

                                       
 
                               

                             
                                         

                             
                                                        

                             
                                                

                             
                                         

                             
                                        

                             
                                                           

                             
                                                         

                             
                                                   

                             
                                         
 

                                              
 

                                                  

                             
                                              

                             
                                         

                             
                          

                             


                                                 

                             
                                        

                             
                                                        

                             
                                     
 

                                  
 

                             

                             
                                             

                             
                                       

                             
                                              

                             
                                                 

                             
                        

                             
                                                

                             


                               

                             
                                                          

                             
                                                

                             
                            

                             
                                           

                             
                                          

                             
                                      

                             
                              

                             
                                                    

                             
                          

                             
                                              

                             
                                             

                             
                                                 

                             
                          

                             
                                        

                             
                                              

                             
                            
 

                                      
 

                             
 

                              
 

                                              

                             
                          

                             
                                  

                             
                                

                             
                        

                             
          

                             
                

                             
                                       

                             
                                  
 

                             
 

                                  

                             
                

                             
   

                             
                             

                             
            

                             
                                                     

                             
                 

                             
                                                         

                             
                                                

                             
                          

                             
                                                          

                             
                                                        

                             
                                      

                             
                                                   

                             
                                                       

                             


                                                   

                             
                                           

                             
                                  

                             
                    

                             
                                                     

                             
                                       

                             
                   

                             
         

                             
                                            
 

                                                     
 

                                               
 

                                             

                             
                                                        

                             
                               
 

                                    
 

                                          
 

                                  

                             
                                                    

                             
                                     
 

                                     
 



                                                                 

                             
                                 

                             
                                                    

                             
                                                            

                             
                                                   

                             
                                                    
 

                             
 

                                                 
 

                             

                             
                                            
 

                                
 

                             

                             
                                  
 

                             
 

                                 

                             
                                    

                             
                           

                             
                                                         

                             
                                               

                             
                                              

                             
                                

                             
                                                  
 

                                
 

                                
 

                                             

                             
                                    

                             
                                 

                             
                                                   

                             
                        

                             
                                               

                             
                                              

                             
                                          

                             
                                             

                             
                                             

                             
                        
WEBVTT captioned by sachac

NOTE Introduction

00:00:36.000 --> 00:00:42.480
And so this little application--

00:00:42.480 --> 00:00:42.503
well, I'll skip that and just kind of

00:00:42.504 --> 00:00:49.142
jump right into my thesis for those of you

00:00:49.143 --> 00:00:53.360
that might be planning to duck out for the RMS talk,

00:00:53.360 --> 00:00:55.520
starting in a little bit.

00:00:55.520 --> 00:00:55.545
So essentially, my thesis here is really that

00:00:55.546 --> 00:00:59.378
the Emacs toolchain can easily be combined

00:00:59.379 --> 00:01:08.793
with other skills and used in kind of

00:01:08.794 --> 00:01:13.280
a Unix paradigm of having sort of different tools

00:01:13.280 --> 00:01:14.960
to do different steps.

00:01:14.960 --> 00:01:17.760
We might actually use the same tool

00:01:17.760 --> 00:01:19.240
to implement a couple of steps.

00:01:19.240 --> 00:01:22.080
But with that paradigm, each step

00:01:22.080 --> 00:01:22.086
is an individual item that can be sort of

00:01:22.087 --> 00:01:26.400
dropped in and replaced.

00:01:26.400 --> 00:01:26.420
So over the course of the talk,

00:01:26.421 --> 00:01:31.080
hopefully I'll come back to that thesis.

NOTE What is orgvm?

00:01:31.080 --> 00:01:31.086
But I'll now jump back and start walking through

00:01:31.087 --> 00:01:37.040
what is orgvm?

00:01:37.040 --> 00:01:39.560
So this is a very simple proof of concept program.

00:01:39.560 --> 00:01:39.586
We'll just jump over to perhaps

00:01:39.587 --> 00:01:45.520
a prettier view of the source code for it.

00:01:45.520 --> 00:01:49.200
This is implemented-- oops.

00:01:49.200 --> 00:01:53.160
There's some cruft, I think, in my local.

00:01:53.160 --> 00:01:56.560
All right, so this config block at the top...

00:01:56.560 --> 00:01:58.120
And we'll be jumping back and forth

00:01:58.120 --> 00:02:01.880
between the code and the documentation.

NOTE Nodejs

00:02:01.880 --> 00:02:04.080
So the first thing I want to point out

00:02:04.080 --> 00:02:05.960
is that this is written in Node.js,

00:02:05.960 --> 00:02:08.600
but I think you'll find it'd be pretty trivial to implement

00:02:08.600 --> 00:02:10.840
in any language.

00:02:10.840 --> 00:02:13.960
Certainly, you're more than welcome to use this.

00:02:13.960 --> 00:02:17.920
I'd be happy to accept your patches or feature requests

00:02:17.920 --> 00:02:20.080
and things like that.

00:02:20.080 --> 00:02:21.680
Of course, bug reports.

00:02:21.680 --> 00:02:25.760
But I'd also encourage others to roll their own.

00:02:25.760 --> 00:02:28.760
You might well come up with a different version of this

00:02:28.760 --> 00:02:29.600
that's even cooler.

00:02:29.600 --> 00:02:32.160
And we can learn from each other.

00:02:32.160 --> 00:02:34.200
If you heard one of my talks before,

00:02:34.200 --> 00:02:36.200
you probably recognize a common theme.

00:02:36.200 --> 00:02:40.320
I'm a big fan of head-first development

00:02:40.320 --> 00:02:40.336
as a way to get invested in both

00:02:40.337 --> 00:02:44.120
the tool chain and a culture.

00:02:44.120 --> 00:02:49.560
All right, so let's come back to orgvm.

NOTE The itch I was trying to scratch

00:02:49.560 --> 00:02:49.586
First of all, we'll start with

00:02:49.587 --> 00:02:52.840
the itch I was trying to scratch.

00:02:52.840 --> 00:02:58.240
I wanted to be able to quickly use a web browser

00:02:58.240 --> 00:03:00.680
to browse my Org documents.

00:03:00.680 --> 00:03:01.420
It's particularly handy when the documents

00:03:01.421 --> 00:03:05.640
are full of cross links to each other.

00:03:05.640 --> 00:03:10.080
That meant I wanted to automatically export,

00:03:10.080 --> 00:03:12.280
particularly to HTML.

00:03:12.280 --> 00:03:17.280
But it made sense for me to include Markdown, PDF,

00:03:17.280 --> 00:03:18.880
or whatever format I want.

00:03:18.880 --> 00:03:22.760
Because many times, I'm going to look at that file

00:03:22.760 --> 00:03:29.480
and then pop it into an email or upload it somewhere.

00:03:29.480 --> 00:03:33.240
And then finally, it should be, therefore,

00:03:33.240 --> 00:03:33.753
pretty easy to download the document

00:03:33.754 --> 00:03:38.320
rather than view it, once I'm done.

NOTE Demo

00:03:38.320 --> 00:03:42.200
So let's just run a quick demo.

00:03:42.200 --> 00:03:44.760
You'll see I'm still a Windows user.

00:03:44.760 --> 00:03:45.960
Yeah, I'm working on it.

00:03:45.960 --> 00:03:52.320
So all right, first thing that we're going to do

00:03:52.320 --> 00:03:53.320
is fire up the program.

00:03:53.320 --> 00:04:00.200
Actually, for simplicity, let's just

00:04:00.200 --> 00:04:01.760
admit we live in a DOS world.

00:04:01.760 --> 00:04:19.760
And as you can see, there's not much to it

00:04:19.760 --> 00:04:21.520
to get the application running.

00:04:22.680 --> 00:04:25.960
So with that done, then, I can run out to my localhost.

00:04:25.960 --> 00:04:36.780
And we'll just start by plugging in the name of an Org file.

00:04:37.560 --> 00:04:37.586
So I've got a little Org file that I prepared

00:04:37.587 --> 00:04:49.040
that just kind of provides a proof of concept to this.

00:04:49.040 --> 00:04:53.560
And you can see, as imagined, we're automatically

00:04:53.560 --> 00:04:54.640
turning that Org file...

00:04:54.640 --> 00:04:56.320
Let's just take a quick look at it.

00:04:56.320 --> 00:05:10.280
And here's that file now.

00:05:10.280 --> 00:05:11.960
You can see, nothing up my sleeve.

00:05:11.960 --> 00:05:11.961
This is a very basic Org file

00:05:11.962 --> 00:05:16.560
that I use for testing this program.

00:05:16.560 --> 00:05:17.640
Images work.

00:05:17.640 --> 00:05:21.836
We've got some nicely syntax-highlighted code blocks

00:05:21.837 --> 00:05:25.560
in a couple different languages,

00:05:25.560 --> 00:05:29.760
and not really that much going on there.

NOTE Needs a relatively recent version of Emacs

00:05:29.760 --> 00:05:33.760
All right, let's come back to the documentation.

00:05:33.760 --> 00:05:36.680
I pretty well covered this, I think.

00:05:36.680 --> 00:05:39.720
But you'll need a relatively recent version of Emacs.

00:05:39.720 --> 00:05:43.640
I haven't taken any pains to make this backward compatible.

00:05:43.640 --> 00:05:46.000
To be fair, I haven't tested it extensively.

00:05:46.000 --> 00:05:50.320
It may well work on Emacs 26 or older versions.

00:05:50.320 --> 00:05:55.120
I'm personally running 27.1 and 28,

00:05:55.120 --> 00:05:57.080
as well as recent builds of 29.

00:05:57.080 --> 00:06:02.560
There's some quick start instructions here,

00:06:02.560 --> 00:06:03.900
which I'm going to take as read.

00:06:03.900 --> 00:06:08.600
You probably saw the key element of this,

00:06:08.601 --> 00:06:11.920
which involves starting the program.

00:06:11.920 --> 00:06:13.520
You do-- I will call out Yale.

00:06:13.520 --> 00:06:15.320
If you're trying to play with this yourself,

00:06:15.320 --> 00:06:20.080
don't forget to run the npm install command.

00:06:20.080 --> 00:06:20.086
That'll bring in express.js,

00:06:20.087 --> 00:06:24.920
which the JavaScript we're about to look at is built on.

NOTE Usage patterns

00:06:24.920 --> 00:06:33.480
So let's just take a look at the usage patterns real quick.

00:06:33.480 --> 00:06:35.920
To use this, we're simply giving the document name

00:06:35.920 --> 00:06:42.760
without the .org extension in whatever file path--

00:06:42.760 --> 00:06:46.960
or I'm sorry, whatever we've configured the server

00:06:46.960 --> 00:06:50.800
to run on, in this case, port 3000.

00:06:50.800 --> 00:06:52.960
I also want to call attention to the fact

00:06:52.960 --> 00:06:55.880
that nothing in this program protects you

00:06:55.880 --> 00:06:57.240
from damaging yourself.

00:06:57.240 --> 00:07:00.560
This isn't meant as a production capability.

00:07:00.560 --> 00:07:00.586
This is something that's used to publish

00:07:00.587 --> 00:07:04.840
your own note files

00:07:04.840 --> 00:07:06.520
and roll them out to yourself.

00:07:06.520 --> 00:07:08.680
That's something I'll definitely look at adding,

00:07:08.680 --> 00:07:12.240
but I want people to be careful of it

00:07:12.240 --> 00:07:14.720
while this is in an alpha state.

00:07:14.720 --> 00:07:22.960
So the default response is HTML, and we saw that here.

00:07:22.960 --> 00:07:26.240
But we also can modify the response format.

00:07:26.240 --> 00:07:29.800
We're currently supporting HTML, Markdown, and PDF.

00:07:29.800 --> 00:07:34.280
And that's really enough to select a different format.

00:07:34.280 --> 00:07:48.040
That's really nothing more than adding type. Okay.

00:07:48.040 --> 00:07:50.680
Not sure what's going on there.

00:07:50.680 --> 00:07:57.080
Okay, well, there goes my demo.

00:07:57.080 --> 00:07:59.440
Shows me for doing my talk live.

00:08:03.920 --> 00:08:06.960
But this, fortunately, this error message

00:08:06.960 --> 00:08:08.840
is a nice segue to the part of the talk

00:08:08.840 --> 00:08:10.240
that I'd really like to focus on,

00:08:10.240 --> 00:08:13.520
hopefully bringing me back to that thesis.

NOTE Emacs Lisp

00:08:13.520 --> 00:08:17.760
So as we start to look at code, what we're looking for

00:08:17.760 --> 00:08:21.640
is really this Emacs Lisp that's getting generated here.

00:08:21.640 --> 00:08:24.000
And you'll notice that's the stuff

00:08:24.000 --> 00:08:27.600
I thought was important to produce as diagnostics

00:08:27.600 --> 00:08:29.840
for the programs running as well.

00:08:29.840 --> 00:08:34.000
So, spoiler, this Elisp is dynamically

00:08:34.000 --> 00:08:35.400
generated by the program.

00:08:35.400 --> 00:08:38.160
And that's really the core of the way

00:08:38.160 --> 00:08:42.680
orgvm or my orgvm works.

00:08:42.680 --> 00:08:47.360
So this should look pretty similar to the view of the code

00:08:47.360 --> 00:08:48.880
we had a moment ago.

00:08:48.880 --> 00:08:51.840
You can see I've got some bases.

00:08:51.840 --> 00:08:53.680
This is all hard-coded into the program,

00:08:53.680 --> 00:08:56.720
nothing fancy going on here.

00:08:56.720 --> 00:09:00.280
The debug is simply controlling that diagnostic output

00:09:00.280 --> 00:09:01.560
that we looked at.

00:09:01.560 --> 00:09:04.240
There's some other, hopefully fairly self-explanatory

00:09:04.240 --> 00:09:09.160
programs or properties, where to find Emacs and so forth.

NOTE Variables

00:09:09.160 --> 00:09:16.320
And then finally, we come in to the meat of it,

00:09:16.320 --> 00:09:16.336
the variables that are used to control what Elisp

00:09:16.337 --> 00:09:24.280
we can generate dynamically.

00:09:24.280 --> 00:09:27.400
So here, we're controlling the extension

00:09:27.400 --> 00:09:29.360
that it should look for Org files.

00:09:29.360 --> 00:09:31.560
Hopefully not too many people out there

00:09:31.560 --> 00:09:34.080
with a weird extension for the Org files,

00:09:34.080 --> 00:09:37.920
but this should support that.

00:09:37.920 --> 00:09:40.120
I'm afraid that is something I've been known to do.

00:09:40.120 --> 00:09:49.520
Then we define a list of additional export types.

00:09:49.520 --> 00:09:50.760
Here's one that ought to work.

00:09:50.760 --> 00:09:53.200
Let's take a look at type=org.

00:09:54.720 --> 00:09:59.320
And, aha, it's giving us the file.

00:09:59.320 --> 00:10:00.680
So I'm not going to open that up,

00:10:00.680 --> 00:10:02.420
but now we can see that that's definitely working,

00:10:02.421 --> 00:10:09.200
for certain versions of working.

00:10:09.200 --> 00:10:14.280
So this list of type parameters is

00:10:14.280 --> 00:10:15.720
controlling the supported types.

00:10:15.720 --> 00:10:18.550
Hopefully it should be fairly easy to add in different ones.

00:10:18.800 --> 00:10:21.480
The fancy footwork here is just a list

00:10:21.480 --> 00:10:23.480
of the types that we're going to be using.

00:10:23.480 --> 00:10:29.320
The fancy footwork here involves, first of all,

00:10:29.320 --> 00:10:32.240
there's the extension and the MIME type.

00:10:32.240 --> 00:10:32.253
That's, as you might guess, used to control

00:10:32.254 --> 00:10:38.720
the response content type.

NOTE Replace

00:10:38.720 --> 00:10:40.920
We also have this replace variable.

00:10:40.920 --> 00:10:44.000
This prevents-- there's an optimization

00:10:44.000 --> 00:10:48.836
to send an existing PDF or HTML file

00:10:48.837 --> 00:10:50.463
if that's already there,

00:10:50.464 --> 00:10:51.003
but only if the original source Org file

00:10:51.004 --> 00:10:56.240
hasn't been modified since.

00:10:56.240 --> 00:10:59.920
This `replace` effectively can turn that off.

00:10:59.920 --> 00:11:03.040
If I remove the `replace: true` attribute,

00:11:03.040 --> 00:11:07.600
then I'll be prevented from overwriting that.

00:11:07.600 --> 00:11:10.320
In other words, I'll always send a cached version.

00:11:10.320 --> 00:11:13.878
That might be helpful if, for example,

00:11:13.879 --> 00:11:15.065
you've got hand-tuned PDFs

00:11:15.066 --> 00:11:17.200
and you don't want to accidentally overwrite them.

NOTE Getting into the code some more

00:11:19.120 --> 00:11:23.480
All right, let's get into the code a little bit more.

00:11:23.480 --> 00:11:28.280
I'm going to skip past the really good stuff

00:11:28.280 --> 00:11:28.295
and jump into the boring parts

00:11:28.296 --> 00:11:34.240
so that we have them as context.

00:11:34.240 --> 00:11:37.160
Here's the default path.

00:11:37.160 --> 00:11:41.880
And it is going to send me the readme from the project--

00:11:41.880 --> 00:11:47.120
from the project repo if I don't specify a path.

00:11:47.120 --> 00:11:51.240
And then we have a couple of different endpoints

00:11:51.240 --> 00:11:52.480
that we support.

00:11:52.480 --> 00:11:55.560
We'll come back to this first one.

00:11:55.560 --> 00:11:55.586
For now, let's start with the more normal one,

00:11:55.587 --> 00:12:01.760
which is just giving us a file name.

00:12:01.760 --> 00:12:04.160
So we can see we start by figuring out

00:12:04.160 --> 00:12:08.520
what the physical file name should be called.

00:12:08.520 --> 00:12:10.280
And assuming that that exists--

00:12:15.600 --> 00:12:17.080
sorry, I've confused myself.

00:12:17.080 --> 00:12:23.000
So this is the caching or the optimization

00:12:23.000 --> 00:12:25.640
that I mentioned, sending the existing file.

00:12:25.640 --> 00:12:31.360
This file exists is where the optimization is

00:12:31.360 --> 00:12:38.680
that regenerates the file if the source

00:12:38.680 --> 00:12:41.840
or document for the HTML generator has changed.

00:12:45.080 --> 00:12:46.760
Again, this is a short talk, so I'm not

00:12:46.760 --> 00:12:49.320
going to go into all the nuances of this JavaScript code.

00:12:49.320 --> 00:12:52.800
It's pretty far from an Emacs-related thing.

00:12:52.800 --> 00:12:56.040
So with that said, then, the rest of this program

00:12:56.040 --> 00:12:59.360
is really mostly just handling the different errors:

00:12:59.360 --> 00:13:01.000
"I didn't understand that type."

00:13:01.000 --> 00:13:02.080
"I don't know the document."

00:13:02.080 --> 00:13:03.040
"I failed."

00:13:03.040 --> 00:13:06.480
Otherwise, there's the caching.

NOTE Generating Elisp

00:13:06.480 --> 00:13:14.520
And here's really where things get interesting,

00:13:14.520 --> 00:13:19.200
where we've generated some Elisp,

00:13:19.200 --> 00:13:22.280
and then we're calling Emacs with that Elisp.

00:13:22.280 --> 00:13:24.760
If everything works, we'll send the file.

00:13:24.760 --> 00:13:27.800
If it doesn't, we'll send the 500.

00:13:27.800 --> 00:13:30.920
And we've already seen the 500, so we know that works.

00:13:30.920 --> 00:13:33.760
All right, let's get to the interesting part.

00:13:33.760 --> 00:13:37.320
Sorry, one more footnote.

NOTE Org blocks

00:13:37.320 --> 00:13:39.320
There is a capability built in that will

00:13:39.320 --> 00:13:41.040
allow us to execute an Org block.

00:13:41.040 --> 00:13:42.840
Let's see if that's working in our local.

00:13:44.800 --> 00:13:47.200
I'll remind myself how to do it.

00:13:47.200 --> 00:13:49.560
It's run.

00:13:49.560 --> 00:13:53.320
I think it's called test.

00:13:53.320 --> 00:13:56.360
And that's returning a 500.

00:13:56.360 --> 00:13:58.400
I'm suspecting that's running because I'm running

00:13:58.400 --> 00:13:59.760
in command instead of bash.

00:13:59.760 --> 00:14:06.040
Oh, yeah, so the failure is happening

00:14:06.040 --> 00:14:07.720
after I generate the Elisp.

00:14:07.720 --> 00:14:10.280
I'm pretty confident that is what the actual problem is.

00:14:10.280 --> 00:14:12.760
If we have time, I'll jump back over there

00:14:12.760 --> 00:14:19.280
and relaunch it in mingw bash.

00:14:19.280 --> 00:14:21.440
And we can see it actually work.

00:14:21.440 --> 00:14:24.200
But this works pretty well for me on my work laptop.

00:14:24.200 --> 00:14:25.860
I didn't have to make any changes to it.

00:14:25.860 --> 00:14:28.120
So I have a fairly high amount of confidence,

00:14:28.120 --> 00:14:32.400
at least in trivial cases, this works pretty well.

NOTE Building some Lisp

00:14:32.400 --> 00:14:37.800
All right, so what I actually wanted to talk about today--

00:14:37.800 --> 00:14:41.730
and I'm going to be kind of hand-waving around

00:14:41.731 --> 00:14:46.480
this ES5 class that I've got and kind of the way that works.

00:14:46.480 --> 00:14:49.840
Hopefully, this will be pretty familiar to you

00:14:49.840 --> 00:14:53.440
if you are a JavaScript programmer.

00:14:53.440 --> 00:14:58.660
The interesting stuff comes when we want to build some Lisp.

00:15:01.960 --> 00:15:01.961
Here, you can see that I really don't have

00:15:01.962 --> 00:15:11.280
a whole lot of code around formatting LISP.

00:15:11.280 --> 00:15:14.360
You can see that I've special-cased

00:15:14.360 --> 00:15:19.840
whether the arguments that were passed

00:15:19.840 --> 00:15:20.880
happen to be a function.

00:15:20.880 --> 00:15:25.480
If they are, I'm going to call that function.

00:15:25.480 --> 00:15:31.720
And then the result will be formatted as Lisp.

00:15:31.720 --> 00:15:35.040
So this would be a recursive call here.

00:15:35.040 --> 00:15:40.960
Otherwise, I'm just going to return the arguments.

00:15:40.960 --> 00:15:48.440
Sorry, otherwise, I will slap a pair of parentheses

00:15:48.440 --> 00:15:57.878
around the result of walking that list if I get...

00:15:57.879 --> 00:15:57.880
formatting each element of the list of arguments

00:15:57.880 --> 00:16:02.600
that this `formatLisp` process calls

00:16:02.600 --> 00:16:04.920
and separating them with spaces.

00:16:04.920 --> 00:16:10.880
So in short form, this program walks through a list.

00:16:10.880 --> 00:16:14.000
If the list it receives is a function,

00:16:14.000 --> 00:16:16.080
it calls that function.

00:16:16.080 --> 00:16:19.320
Once that's handled or otherwise,

00:16:19.320 --> 00:16:22.720
we simply walk the list, taking the arguments,

00:16:22.720 --> 00:16:26.000
concatenating them on strings, and finally,

00:16:26.000 --> 00:16:28.560
wrap the results in parentheses.

00:16:28.560 --> 00:16:31.760
So what I didn't mention there but might be obvious

00:16:31.760 --> 00:16:36.120
is if I have a nested list, the inner list

00:16:36.120 --> 00:16:38.600
will be subjected to the same treatment.

00:16:38.600 --> 00:16:43.000
So this is a recursive sort of algorithm.

NOTE How Elisp gets encoded

00:16:43.000 --> 00:16:51.520
All right, so now when I go to export,

00:16:51.520 --> 00:16:53.520
actually, in the interest of time,

00:16:53.520 --> 00:16:55.800
I'm going to avoid walking through that piece of code

00:16:55.800 --> 00:16:58.840
and let's focus instead on the more interesting part

00:16:58.840 --> 00:17:02.360
of how that Lisp gets encoded.

00:17:02.360 --> 00:17:07.520
So coming back to the PDF is a good example here,

00:17:07.520 --> 00:17:10.320
because it's got a special case.

00:17:10.320 --> 00:17:10.336
You can see I've specified this `exportFun`

00:17:10.337 --> 00:17:15.320
or export function.

00:17:15.320 --> 00:17:19.560
That's a property none of these other types have.

00:17:22.400 --> 00:17:27.280
And you can see it contains some Elisp telling us

00:17:27.280 --> 00:17:29.760
how to call the export for it.

00:17:29.760 --> 00:17:32.680
Let's go see how that's used.

00:17:32.680 --> 00:17:35.720
At the very end of what I just skipped over,

00:17:35.720 --> 00:17:40.600
the detailed "how the Org export process works,"

00:17:40.600 --> 00:17:45.040
you'll see that I am ending with a step

00:17:45.040 --> 00:17:48.000
to call the export function.

00:17:48.000 --> 00:17:48.003
Here, I look to see whether I have

00:17:48.004 --> 00:17:55.400
an export function property.

00:17:55.400 --> 00:18:00.920
If I do, I call that function.

00:18:00.920 --> 00:18:00.920
And if I don't, I build this list with the default

00:18:00.921 --> 00:18:07.071
`org-export-to-file` function

00:18:07.072 --> 00:18:15.640
using the filename and an output filename.

00:18:15.640 --> 00:18:18.480
So this, hopefully, is pretty familiar to anybody

00:18:18.480 --> 00:18:18.503
that's manually messed around

00:18:18.504 --> 00:18:23.560
with calling `org-export-to-file`.

00:18:23.560 --> 00:18:25.800
If it isn't, you can pretty well trust me for it.

00:18:25.800 --> 00:18:28.280
There's nothing very special going on.

00:18:28.280 --> 00:18:30.760
This looks rather like...

00:18:30.760 --> 00:18:37.240
Poor example there.

00:18:37.240 --> 00:18:38.960
Let's go back to our markdown.

00:18:46.320 --> 00:18:47.720
And there, we can see--

00:18:47.720 --> 00:18:49.840
[Leo]: I'm going to make a quick announcement.

00:18:49.840 --> 00:18:50.760
Can you hear me?

00:18:50.760 --> 00:18:52.480
[Corwin]: Yes, go for it.

00:18:52.480 --> 00:18:54.280
[Leo]: OK, let me just show my face.

00:18:54.280 --> 00:18:55.400
Oh, I'm not showing my face.

00:18:55.400 --> 00:18:55.640
Damn it.

00:18:55.640 --> 00:18:57.000
OK, I'll make the announcement.

00:18:57.000 --> 00:18:58.600
You won't see my face quite yet.

00:18:58.600 --> 00:19:00.360
We are about to get started.

00:19:00.360 --> 00:19:02.440
Well, we actually just got started on dev

00:19:02.440 --> 00:19:06.040
with the talk by RMS.

00:19:06.040 --> 00:19:08.920
So if you want to hop over to watch the talk by RMS,

00:19:08.920 --> 00:19:09.760
feel free to do so.

00:19:09.760 --> 00:19:12.240
Otherwise, we will be continuing on Gen with Corwin

00:19:12.240 --> 00:19:12.253
to finish his talk and have a Q&A.

00:19:12.254 --> 00:19:16.080
Corwin, you can feel free to go now.

00:19:16.080 --> 00:19:18.560
[Corwin]: Okay, bye, everybody.

00:19:18.560 --> 00:19:22.795
And for those sticking around,

00:19:22.796 --> 00:19:25.040
I'm just going to keep pressing on with this.

NOTE How the export works

00:19:25.040 --> 00:19:30.240
In fact, I'm going to dive back into the part

00:19:30.240 --> 00:19:35.400
that I skipped here, which is the rest of how

00:19:35.400 --> 00:19:37.400
this export functionality works.

00:19:37.400 --> 00:19:41.400
So just to make sure the dot is tied together,

00:19:41.400 --> 00:19:44.440
the core of how this program works

00:19:44.440 --> 00:19:49.320
is generating some Elisp and then passing it

00:19:49.320 --> 00:19:51.680
to Emacs in batch mode.

00:19:51.680 --> 00:19:53.280
So if that wasn't perfectly clear,

00:19:53.280 --> 00:19:57.240
that's really what's going on with this program.

00:19:57.240 --> 00:19:59.240
The rest of the implementation is just

00:19:59.240 --> 00:20:01.840
a way to do that or certain features that

00:20:01.840 --> 00:20:08.440
are supported in that generated Elisp, if you will.

00:20:08.440 --> 00:20:11.720
So this is, you could say, the minimum implementation

00:20:11.720 --> 00:20:11.753
I could come up with to create a web server

00:20:11.754 --> 00:20:17.320
for my local Org documents.

00:20:17.320 --> 00:20:24.440
And I will also interrupt myself to just pull up

00:20:24.440 --> 00:20:28.040
the Etherpad real quick.

00:20:28.040 --> 00:20:29.600
Actually, if somebody is listening

00:20:29.600 --> 00:20:34.720
and can share a link to that, I closed my browser window

00:20:34.720 --> 00:20:36.400
with my links in it.

00:20:36.400 --> 00:20:44.520
But sure, I'm happy to take questions at any point, Leo,

00:20:44.520 --> 00:20:48.480
if there are any questions for me.

00:20:48.480 --> 00:20:49.720
Are you hanging out with me,

00:20:49.720 --> 00:20:53.360
instead of watching RMS? You can go.

00:20:53.360 --> 00:20:54.600
I'm teasing.

00:20:54.600 --> 00:20:58.840
[Leo]: No, I mean, we know that some people can

00:20:58.840 --> 00:21:00.000
have both streams open.

00:21:00.000 --> 00:21:01.560
It's fine.

00:21:01.560 --> 00:21:03.320
And right now, it's not the Q&A with RMS.

00:21:03.320 --> 00:21:04.640
It's just the presentation.

00:21:04.640 --> 00:21:07.040
So feel free to hang out a little longer

00:21:07.040 --> 00:21:09.080
if you just want the live stuff.

00:21:09.080 --> 00:21:09.960
Don't worry about it.

00:21:09.960 --> 00:21:10.760
You're fine.

00:21:10.760 --> 00:21:13.720
[Corwin]: Yeah, and forgive me, everybody,

00:21:13.720 --> 00:21:16.280
if you were hoping for a quick, succinct talk.

00:21:16.280 --> 00:21:18.960
I happen to know I was going to be opposite RMS,

00:21:18.960 --> 00:21:23.240
so I awarded myself the liberty of rambling.

00:21:23.240 --> 00:21:26.840
So if you do have a question, something that I alluded to

00:21:26.840 --> 00:21:29.800
and haven't come back to yet, you should, by all means,

00:21:29.800 --> 00:21:30.320
prompt me.

00:21:30.320 --> 00:21:33.800
[Leo]: Corwin, I might do--

00:21:33.800 --> 00:21:35.400
I'm just giving you a little heads up.

00:21:35.400 --> 00:21:38.640
I might need to go help at some point of dev.

00:21:38.640 --> 00:21:43.120
So if I need to do so, I will let you know right now

00:21:43.120 --> 00:21:44.280
inside the BBB room,

00:21:44.280 --> 00:21:46.160
and you'll be on your own to manage the chat.

00:21:46.160 --> 00:21:47.960
And you can just talk backstage to us

00:21:47.960 --> 00:21:50.240
to manage what we do with the stream, OK?

00:21:50.240 --> 00:21:52.160
[Corwin]: Yep, that should be no problem at all.

00:21:52.160 --> 00:21:53.760
I've got my pad up now.

00:21:53.760 --> 00:21:55.160
Thank you, ??.

00:21:55.160 --> 00:21:58.040
And I'm sorry about butchering your name there.

00:21:58.040 --> 00:22:03.360
And yep, I've got my chat open.

00:22:03.360 --> 00:22:06.400
And I think I'm pretty well set to self-manage.

00:22:06.400 --> 00:22:07.640
Oh, I don't have a camera on.

00:22:07.640 --> 00:22:09.360
So you can't see me giving you the thumbs up.

00:22:09.360 --> 00:22:09.860
[Leo]: Okay, good.

NOTE Walking through the code

00:22:09.860 --> 00:22:16.000
All right, so let's just walk through,

00:22:16.000 --> 00:22:18.400
because it's sort of an interesting code.

00:22:18.400 --> 00:22:20.560
Let's just take a look real quick

00:22:20.560 --> 00:22:24.720
at how we generated our Elisp here,

00:22:24.720 --> 00:22:26.520
because it is--

00:22:26.520 --> 00:22:27.640
there we go.

00:22:27.640 --> 00:22:29.240
It is a little bit interesting.

00:22:29.240 --> 00:22:32.040
So here is the method.

00:22:32.040 --> 00:22:34.080
So I didn't get into detail on this.

00:22:34.080 --> 00:22:34.086
But there's an ES5 class that represents

00:22:34.087 --> 00:22:38.920
an Org mode document.

00:22:38.920 --> 00:22:38.920
It has the static debug property that,

00:22:38.921 --> 00:22:42.400
as you might imagine,

00:22:42.400 --> 00:22:45.480
can be overridden by that debug setting

00:22:45.480 --> 00:22:48.440
we looked at in the defaults.

00:22:48.440 --> 00:22:51.440
We also have a static variable that--

00:22:51.440 --> 00:22:57.440
a static property that does nothing more than getting

00:22:57.440 --> 00:23:00.360
the path to Emacs out of those defaults.

00:23:00.360 --> 00:23:02.120
Similarly, we have a class method

00:23:02.120 --> 00:23:09.520
to spawn out an Emacs, as I mentioned, in batch mode,

00:23:09.520 --> 00:23:12.720
eval-ing some arbitrary Lisp that's passed in.

00:23:12.720 --> 00:23:20.480
All right, so the type--

00:23:20.480 --> 00:23:23.080
this is where things start to get interesting.

00:23:23.080 --> 00:23:26.480
So this is an implementation detail,

00:23:26.480 --> 00:23:30.040
but-- that it's written as a static method.

00:23:30.040 --> 00:23:32.160
But essentially, what's going on here

00:23:32.160 --> 00:23:34.840
is looking up from that type list

00:23:34.840 --> 00:23:37.480
to try to find a type that's passed in,

00:23:37.480 --> 00:23:41.240
and that's returning one of these blocks.

00:23:41.240 --> 00:23:44.800
Let's say I requested HTML, which would be the default.

00:23:44.800 --> 00:23:48.760
Then I'm going to get this set of properties back.

00:23:50.760 --> 00:23:51.260
All right.

00:23:51.260 --> 00:24:04.200
Essentially, this program generates a program

00:24:04.200 --> 00:24:10.840
or a little block of executable elisp.

00:24:10.840 --> 00:24:15.920
However, in some cases, where if the `load-path` has

00:24:15.920 --> 00:24:20.920
been customized in that type block,

00:24:20.920 --> 00:24:25.000
or I think that's the only case I supported.

00:24:25.000 --> 00:24:28.960
There was another complexity I removed.

00:24:28.960 --> 00:24:32.000
So in that case, then I can simply

00:24:32.000 --> 00:24:33.560
replace that program with a let.

00:24:33.560 --> 00:24:41.680
Either way, I'm going to have everything I generate

00:24:41.680 --> 00:24:45.840
be encapsulated in a single block.

00:24:45.840 --> 00:24:49.240
The-- then I'm calling that formatLisp process

00:24:49.240 --> 00:24:52.760
that we talked about, appending to that--

00:24:52.760 --> 00:25:01.680
or inserting into, you could say, the outer scope.

00:25:01.680 --> 00:25:05.000
And we start by finding the file.

00:25:05.000 --> 00:25:11.400
We then load any libraries that might be needed.

00:25:11.400 --> 00:25:13.520
In some cases, the type might not

00:25:13.520 --> 00:25:15.160
have any external libraries.

00:25:15.160 --> 00:25:18.440
So we just-- so that's a no-op.

00:25:18.440 --> 00:25:24.120
And then finally, we're going to execute

00:25:24.120 --> 00:25:27.160
that logic I mentioned before about selecting

00:25:27.160 --> 00:25:30.160
either the default org-export-to-file,

00:25:30.160 --> 00:25:36.200
or else whatever Elisp we've staged for exporting

00:25:36.200 --> 00:25:38.160
that particular file type.

00:25:38.160 --> 00:25:43.112
And again, in the case of PDF, there's a special function

00:25:43.113 --> 00:25:46.240
that's used to trigger that export.

00:25:46.240 --> 00:25:49.160
Or you may be aware that that's a little more complicated.

00:25:49.160 --> 00:25:50.840
There's intermediate forms there.

00:25:50.840 --> 00:25:56.760
All right.

00:25:56.760 --> 00:26:01.320
So just reminding myself if there's anything else

00:26:01.320 --> 00:26:03.760
I have to cover on background.

00:26:03.760 --> 00:26:07.440
And I think that pretty well covers the basics.

NOTE Executing the source block

00:26:07.440 --> 00:26:09.880
All right, let's look at that source block execute.

00:26:09.880 --> 00:26:14.600
This is the other use of the format list function.

00:26:14.600 --> 00:26:16.800
So here, rather than looking at the type

00:26:16.800 --> 00:26:24.720
and passing that through our Org export method,

00:26:24.720 --> 00:26:29.080
and then that type is used to get the list

00:26:29.080 --> 00:26:30.840
that we want to create.

00:26:30.840 --> 00:26:37.600
In the case of source block execute,

00:26:37.600 --> 00:26:40.520
we're kind of rolling it a lot more by hand.

00:26:40.520 --> 00:26:43.920
So this gives us a good chance to sort of unwind

00:26:43.920 --> 00:26:49.600
how that list looks when it's staged as JavaScript data.

00:26:49.600 --> 00:26:52.760
So here again, I wrap everything in a `progn`.

00:26:52.760 --> 00:26:58.480
I start by preventing an interactive prompt

00:26:58.480 --> 00:27:01.240
for the Babel execution.

00:27:01.240 --> 00:27:04.960
And then we load languages.

00:27:04.960 --> 00:27:12.240
This relates to another piece of our configuration

00:27:12.240 --> 00:27:17.600
where we've specified a set of languages

00:27:17.600 --> 00:27:19.920
that it's OK to execute.

00:27:19.920 --> 00:27:24.120
So if that type isn't in this list,

00:27:24.120 --> 00:27:28.800
then we won't be able to execute it in line

00:27:28.800 --> 00:27:32.720
through our trivial little web server.

00:27:32.720 --> 00:27:33.640
All right.

00:27:33.640 --> 00:27:40.600
With that done, then, loading the selected language,

00:27:40.600 --> 00:27:43.960
we then once again open the file.

00:27:43.960 --> 00:27:46.360
And we're-- whoops.

00:27:46.360 --> 00:27:51.800
Let-bind a return value, which is

00:27:51.800 --> 00:27:55.166
calculated by using Org source block execute [`org-sbe`]

00:27:55.167 --> 00:27:58.040
on the name of the block that's given.

00:27:58.040 --> 00:28:05.160
And then we use a temp buffer to write that out

00:28:05.160 --> 00:28:06.640
to a temporary file.

00:28:06.640 --> 00:28:08.440
This is actually a little clumsy,

00:28:08.440 --> 00:28:12.720
but I haven't put the effort in to have this written out

00:28:12.720 --> 00:28:17.480
to the standard output cleanly instead of using a temp file.

00:28:17.840 --> 00:28:20.480
So under-- this is another example of where it may not

00:28:20.480 --> 00:28:22.520
be production-- well, it definitely

00:28:22.520 --> 00:28:27.680
is not production-worthy code in that under heavy load,

00:28:27.680 --> 00:28:30.166
this would certainly break with collisions

00:28:30.167 --> 00:28:32.040
on the Babel file,

00:28:32.040 --> 00:28:34.120
the name of the Babel file.

00:28:34.120 --> 00:28:37.480
In any case, once we've staged up our Elisp, which is--

00:28:37.480 --> 00:28:42.560
this is basically variable interpolation,

00:28:42.560 --> 00:28:47.680
then we just call Emacs on that.

00:28:47.680 --> 00:28:49.720
And if we look down to where that's called,

00:28:49.720 --> 00:28:54.640
you can see that the Org Babel filename calculated here.

00:29:12.795 --> 00:29:15.000
[Leo]: Is there a problem?

00:29:15.000 --> 00:29:15.760
[Corwin]: No, I'm fine.

00:29:15.760 --> 00:29:18.000
I'm just lost in my code.

00:29:18.000 --> 00:29:19.040
[Leo]: OK, cool.

00:29:19.040 --> 00:29:21.160
Uh-oh means, oh, I need to intervene.

00:29:21.160 --> 00:29:22.240
What is going on?

00:29:22.240 --> 00:29:23.200
Carry on, please.

00:29:23.200 --> 00:29:24.120
[Corwin]: No, I'm fine, Leo.

00:29:24.120 --> 00:29:25.480
Thank you.

00:29:25.480 --> 00:29:27.280
All right, so then--

00:29:27.280 --> 00:29:28.680
so you can see we get--

00:29:28.680 --> 00:29:35.537
we send the Babel file here,

00:29:35.538 --> 00:29:41.640
which is calculated manually.

00:29:41.640 --> 00:29:45.440
A bit sloppy there, since I have essentially the same--

00:29:45.440 --> 00:29:47.000
I have two different places where

00:29:47.000 --> 00:29:52.480
I'm calculating the Org doc file in two different ways.

00:29:52.480 --> 00:29:54.720
Have I encouraged you to write your own yet?

00:29:54.720 --> 00:29:56.440
Or send patches.

00:29:56.440 --> 00:30:01.240
All right, so that's pretty much the nuts and bolts

00:30:01.240 --> 00:30:02.400
of this program.

00:30:02.400 --> 00:30:06.720
Let's go back to just seeing if we can't make it run.

00:30:22.120 --> 00:30:22.620
All right.

00:30:22.620 --> 00:30:45.880
All right, well, I apologize for not

00:30:45.880 --> 00:30:49.560
having taken the time to stage my demo this morning.

00:30:49.560 --> 00:30:52.680
I'm going to try to make it better for you.

00:30:52.680 --> 00:30:59.920
But apparently, it's going to be non-trivial

00:30:59.920 --> 00:31:04.520
to make the program work.

00:31:04.520 --> 00:31:07.160
Let's just-- before I completely give up,

00:31:07.160 --> 00:31:13.320
let's go ahead and try our Babel execute.

00:31:13.320 --> 00:31:14.800
And that, too, is failing.

00:31:14.800 --> 00:31:18.040
So there's something unhappy in my local world.

00:31:18.040 --> 00:31:19.040
There it goes.

00:31:19.040 --> 00:31:26.600
But in any case, let's go ahead and just take a look at

00:31:26.600 --> 00:31:28.000
that.

00:31:28.000 --> 00:31:30.640
Let's see.

00:31:30.640 --> 00:31:31.600
Control Enter.

00:31:36.628 --> 00:31:40.200
Let's take a look at that generated .el

00:31:40.200 --> 00:31:42.840
and compare it to-- whoa--

00:31:42.840 --> 00:31:44.000
and compare it to--

00:31:44.000 --> 00:31:52.400
I'm just going to format this manually,

00:31:52.400 --> 00:31:56.000
because I've forgotten my key bindings to auto-format it.

00:31:56.000 --> 00:32:02.240
There we go.

00:32:02.240 --> 00:32:07.960
All right.

00:32:07.960 --> 00:32:13.120
So now we can see, as promised, there's really

00:32:13.120 --> 00:32:16.200
nothing going on here other than the interpolation

00:32:16.200 --> 00:32:18.640
of the variables in.

00:32:18.640 --> 00:32:24.360
We're inserting-- we're using an insert and write file

00:32:24.360 --> 00:32:27.800
method, which is, again, rather sloppy,

00:32:27.800 --> 00:32:32.040
to generate the text file.

00:32:32.040 --> 00:32:32.880
All right.

00:32:32.880 --> 00:32:34.760
Let's come back to our documentation

00:32:34.760 --> 00:32:39.760
and see if we can put a bow on the project.

NOTE Conclusion

00:32:39.760 --> 00:32:43.760
So I hope I've convinced you that this was actually

00:32:43.760 --> 00:32:45.480
rather easy to do.

00:32:45.480 --> 00:32:52.440
The entirety of my index.js file is 262 lines,

00:32:52.440 --> 00:32:59.810
and that includes a good 40 of whitespace and configuration.

00:33:03.760 --> 00:33:06.505
It has only one dependency, the Express,

00:33:06.506 --> 00:33:08.240
which really builds the web server.

00:33:08.240 --> 00:33:11.520
Any language you'd rather implement this in

00:33:11.520 --> 00:33:14.120
will have a similar capability for building

00:33:14.120 --> 00:33:16.280
some type of trivial web server.

00:33:16.280 --> 00:33:18.400
And I think you may find--

00:33:18.400 --> 00:33:22.640
I certainly found that a large portion of the code base

00:33:22.640 --> 00:33:28.080
is really making the errors meaningful,

00:33:28.080 --> 00:33:32.420
in that, in some cases, sending an appropriate HTTP status

00:33:32.420 --> 00:33:34.360
based on what happened.

00:33:34.360 --> 00:33:38.002
In other cases-- let's see if

00:33:38.003 --> 00:33:42.640
I've got an explicit `throw` left in here--

00:33:42.640 --> 00:33:45.840
in other cases, just trapping different types

00:33:45.840 --> 00:33:47.440
of failure conditions.

00:33:47.440 --> 00:33:54.000
I'm going to look at my pad, and I do see a question here.

00:33:54.000 --> 00:33:55.120
So let me jump in here.

NOTE Questions and answers

00:33:58.880 --> 00:34:00.640
[Leo]: Corwin, just to make sure, are you switching to Q&A?

00:34:00.640 --> 00:34:02.380
Are you finished with your presentation?

00:34:02.380 --> 00:34:05.260
[Corwin]: Well, as I said, I'm happy to take Q&A throughout.

00:34:05.260 --> 00:34:08.420
But yes, let's say yes to that.

00:34:08.420 --> 00:34:10.900
[Leo]: Okay, so Corwin, what I'm going to need to do now--

00:34:10.900 --> 00:34:12.140
you are in charge of the room.

00:34:12.140 --> 00:34:14.060
We are going to open up the room so

00:34:14.060 --> 00:34:17.220
that if people have questions watching right now on Gen,

00:34:17.220 --> 00:34:18.700
feel free to come in.

00:34:18.700 --> 00:34:22.780
And there was something else I needed to say.

00:34:22.780 --> 00:34:24.620
Yes, Corwin, if there's any problem,

00:34:24.620 --> 00:34:25.700
whisper to us on Mumble.

00:34:25.700 --> 00:34:27.500
So you might want to unmute Mumble

00:34:27.500 --> 00:34:29.620
and be able to listen to us over there.

00:34:29.620 --> 00:34:32.480
[Corwin]: I can't do that, Leo.

00:34:32.480 --> 00:34:36.440
If I unmute, Mumble is going to bleed through.

00:34:36.440 --> 00:34:36.960
[Leo]: Okay, sure.

00:34:36.960 --> 00:34:39.416
Well, if you have any problem,

00:34:39.417 --> 00:34:41.160
type in #emacsconf-org channel,

00:34:41.160 --> 00:34:42.520
and we'll be with you, OK?

00:34:42.520 --> 00:34:43.520
[Corwin]: Or I'll PM somebody.

00:34:43.520 --> 00:34:45.760
But I don't anticipate having any problems.

00:34:45.760 --> 00:34:49.040
I'll put something in -org when I run out of steam here.

00:34:49.040 --> 00:34:50.400
How's that?

00:34:50.400 --> 00:34:51.160
[Leo]: Amazing, cool.

00:34:51.160 --> 00:34:53.320
So I will have to leave the room, though.

00:34:53.320 --> 00:34:56.800
I'm leaving the recording going so that we have your Q&A.

00:34:56.800 --> 00:34:58.080
And whenever you're available--

00:34:58.080 --> 00:35:02.180
[Corwin]: I'll shut off the recording when I close the room.

00:35:02.180 --> 00:35:02.980
[Leo]: Okay, great.

00:35:02.980 --> 00:35:04.460
Good luck, Corwin.

00:35:04.460 --> 00:35:06.500
[Corwin]: Thank you.

00:35:06.500 --> 00:35:09.780
All right, and if you're still with me, well, thanks.

00:35:09.780 --> 00:35:13.620
I appreciate that.

00:35:13.620 --> 00:35:16.740
I did offer to be opposite RMS.

00:35:16.740 --> 00:35:20.060
And I'm in no way offended if people do want to jump over,

00:35:20.060 --> 00:35:23.540
especially as that starts to shift over to Q&A.

00:35:23.540 --> 00:35:26.980
I'm taking Leo's leaving as a pretty good indication

00:35:26.980 --> 00:35:28.780
that that's happening now-ish.

00:35:28.780 --> 00:35:31.385
So I totally understand

00:35:31.386 --> 00:35:35.020
if folks are more excited to do that.

00:35:35.020 --> 00:35:37.940
Meanwhile, let me just jump over to the question

00:35:37.940 --> 00:35:38.660
that I received.

00:35:38.660 --> 00:35:46.460
I'll show the pad here so that I save myself

00:35:46.460 --> 00:35:47.860
reading the question out.

00:35:47.860 --> 00:35:48.940
But I'll paraphrase it.

NOTE Why am I not running the web server in Emacs?

00:35:48.940 --> 00:35:52.660
Why am I not running the web server in Emacs?

00:35:52.660 --> 00:35:54.380
That would be a great way to do it.

00:35:54.380 --> 00:35:56.340
I chose to build it in Node.js

00:35:56.341 --> 00:35:58.460
because that was trivially easy for me.

NOTE Is this using org-info-js?

00:36:22.140 --> 00:36:24.780
And then finally, am I using org-info-js?

00:36:24.780 --> 00:36:27.540
No, I learned about this essentially at this conference.

00:36:27.540 --> 00:36:30.660
So that's something I'll be learning more about.

00:36:30.660 --> 00:36:32.460
And it could well influence this project.

00:36:34.900 --> 00:36:56.180
All right, and thanks for the questions.

00:36:59.020 --> 00:37:02.820
All right, I'm going to slow my roll just a little bit here

00:37:02.820 --> 00:37:06.980
because I think I kind of have all the time in the world.

00:37:06.980 --> 00:37:11.540
I will be wrapping up within about 15 or 20 minutes

00:37:11.540 --> 00:37:15.620
at the latest just to avoid stressing out

00:37:15.620 --> 00:37:18.827
my fellow organizers, especially Leo and Sacha

00:37:18.828 --> 00:37:22.260
that have the bulk of the heavy lifting this year,

00:37:22.260 --> 00:37:26.820
and Amin, and really, thanks all to everybody.

00:37:26.820 --> 00:37:29.540
God, the nicest part of doing my own talk

00:37:29.540 --> 00:37:31.980
is that I get to say that.

00:37:31.980 --> 00:37:35.460
It's just so much fun to contribute to EmacsConf.

NOTE EmacsConf

00:37:35.460 --> 00:37:38.740
And if you're at all interested, there's

00:37:38.740 --> 00:37:43.100
plenty of completely backstage, behind the curtain role.

00:37:43.100 --> 00:37:45.340
Behind the curtain roles doesn't mean

00:37:45.340 --> 00:37:47.865
you have to be somebody that likes

00:37:47.866 --> 00:37:50.060
talking or being on webcam.

00:37:50.060 --> 00:37:52.300
Sorry that my camera isn't working this year.

00:37:52.300 --> 00:37:53.980
I spent quite a while fussing with that

00:37:53.980 --> 00:37:56.740
and lost all my time to get my prerec working.

00:37:56.740 --> 00:38:10.140
All right, so trying to think where I can take us

00:38:10.140 --> 00:38:11.540
without my demo working.

00:38:11.540 --> 00:38:14.540
I was really hoping to show the Org Babel piece.

00:38:14.540 --> 00:38:15.580
That's really fun.

NOTE How I'm using this at work

00:38:15.580 --> 00:38:20.420
So let me just mention briefly how I'm using this at work.

00:38:20.420 --> 00:38:25.980
So at work, I'll have some type of Org document.

00:38:25.980 --> 00:38:27.700
And usually, it's a project.

00:38:27.700 --> 00:38:32.900
So the title of the document is My Project.

00:38:32.900 --> 00:38:37.820
And then I'll have a requirements section.

00:38:37.820 --> 00:38:43.540
And I'll have a meeting notes section.

00:38:43.540 --> 00:38:44.980
That's probably the key thing.

00:38:44.980 --> 00:38:49.540
And then as the project goes on, I'll start having--

00:38:49.540 --> 00:38:50.740
I'm a solutions architect.

00:38:50.740 --> 00:38:55.420
So my job is formalizing design in large part.

00:38:55.420 --> 00:39:01.740
So then I'll have a design documents section.

00:39:01.740 --> 00:39:05.020
And this is where I'll be doing a lot of my work.

00:39:05.020 --> 00:39:07.220
So I'll start out saying--

00:39:26.620 --> 00:39:29.340
And maybe Bob is a subject matter expert

00:39:29.340 --> 00:39:32.460
whose buy-in I need to have on how we're going

00:39:32.460 --> 00:39:34.820
to do the high-level design.

00:39:34.820 --> 00:39:37.296
Maybe a lead engineer or a dev manager

00:39:37.297 --> 00:39:39.460
or something like that.

00:39:39.460 --> 00:39:42.653
All right, as my work goes on,

00:39:42.654 --> 00:39:47.620
then this will start getting into more detail.

00:40:16.620 --> 00:40:18.660
And things of this nature.

00:40:18.660 --> 00:40:20.180
As things get further and further,

00:40:20.180 --> 00:40:21.740
I'll actually have documentation

00:40:21.740 --> 00:40:22.820
that I'm adding in here.

00:40:22.820 --> 00:40:28.900
Oh, I see.

00:40:28.900 --> 00:40:29.740
It's a big mess.

00:40:29.740 --> 00:40:32.140
All right, well, we'll just reuse this.

00:40:32.140 --> 00:40:40.380
So I can insert those all in line.

00:40:40.380 --> 00:40:42.157
And now for the fun part,

00:40:42.158 --> 00:40:44.460
let's see if the most trivial case

00:40:44.460 --> 00:40:45.460
is working here.

00:40:49.940 --> 00:40:51.180
No.

00:40:51.180 --> 00:40:52.900
All right, completely broken.

00:40:52.900 --> 00:40:57.260
Let me drag.

00:40:57.260 --> 00:41:05.180
All right, well, apologies again for the poor quality

00:41:05.180 --> 00:41:06.260
of my demo today.

00:41:06.260 --> 00:41:13.900
And let me just look real quick at my Etherpad once more.

00:41:13.900 --> 00:41:16.820
And I'll glance at BBB to see if there's anybody

00:41:16.820 --> 00:41:18.140
jumping in with questions.

00:41:18.140 --> 00:41:23.740
And then I'll go back to IRC and look for questions there.

00:41:23.740 --> 00:41:33.180
OK, and I don't see any additional questions on the pad.

00:41:33.180 --> 00:41:35.780
I'm just going to scan IRC real quick.

00:41:35.780 --> 00:41:42.460
I suspect that the TreeSitter comment isn't for me.

00:41:44.900 --> 00:41:56.620
All right, and I'm not seeing a lot of questions there.

00:41:56.620 --> 00:42:04.340
So I'm just going to vamp for just a minute or two.

NOTE Volunteering for EmacsConf

00:42:04.340 --> 00:42:07.980
As I mentioned, I'm a conference volunteer.

00:42:07.980 --> 00:42:09.700
This is my third year volunteering

00:42:09.700 --> 00:42:11.940
with the conference.

00:42:11.940 --> 00:42:15.140
And probably if you take one thing away from my talk,

00:42:15.140 --> 00:42:17.740
it should be I really like volunteering

00:42:17.740 --> 00:42:18.500
for the conference.

00:42:18.500 --> 00:42:19.900
It's fun.

00:42:19.900 --> 00:42:23.500
It makes me feel sort of close to the pulse.

00:42:23.500 --> 00:42:27.296
And it gives me a chance to just interact with people

00:42:27.297 --> 00:42:30.106
that have very different perspectives on Emacs,

00:42:30.107 --> 00:42:32.740
which is something that I really value a lot.

00:42:32.740 --> 00:42:40.220
Emacs, like anything else sort of in the internet world,

00:42:40.220 --> 00:42:42.940
has a real echo chamber factor.

00:42:42.940 --> 00:42:46.504
If you do or don't like use-package,

00:42:46.505 --> 00:42:49.135
you probably interact with a lot of people

00:42:49.136 --> 00:42:53.500
that feel the same way about that.

00:42:53.500 --> 00:42:57.420
And so I really recommend volunteering for EmacsConf

00:42:57.420 --> 00:43:01.340
as a way to sort of mix it up and get

00:43:01.340 --> 00:43:03.858
to know people that may not use Emacs

00:43:03.859 --> 00:43:05.540
the same way that you do.

NOTE It's easy to build a program that uses Emacs in the pipeline

00:43:08.380 --> 00:43:10.420
Or perhaps more on topic, though,

00:43:10.420 --> 00:43:14.300
the log line for this talk is it's really quite easy

00:43:14.300 --> 00:43:20.760
to build a program that uses Emacs in a pipeline capability.

00:43:20.980 --> 00:43:23.780
I think there's a ton of opportunity in this space.

00:43:23.780 --> 00:43:27.700
This particular example is just a trivial web server

00:43:27.700 --> 00:43:30.780
written using Node.js.

00:43:30.780 --> 00:43:31.545
But as was pointed out, we could have used elnode

00:43:31.546 --> 00:43:40.060
as a web server

00:43:40.060 --> 00:43:44.060
and done the entire thing within Emacs Lisp.

00:43:44.060 --> 00:43:48.765
Or really, almost any technology

00:43:48.766 --> 00:43:52.900
would get us this capability.

00:43:52.900 --> 00:43:54.660
From an implementation standpoint,

00:43:54.660 --> 00:43:56.847
I had a lot of fun building

00:43:56.848 --> 00:43:59.580
this trivial little Elisp parser,

00:43:59.580 --> 00:44:03.220
and I'm rather pleased with the fact

00:44:03.220 --> 00:44:07.340
that the entirety of that--

00:44:07.340 --> 00:44:14.180
the entire algorithm for turning JavaScript or JSON data,

00:44:14.180 --> 00:44:20.420
we could say, into Elisp is really a one-liner,

00:44:20.420 --> 00:44:25.820
albeit a nasty one-liner. That was pretty cool

00:44:25.820 --> 00:44:28.180
to discover how simple that was.

00:44:28.180 --> 00:44:31.220
So in my mind, that opens up a lot of possibility.

00:44:31.220 --> 00:44:32.889
If it's this easy in JavaScript,

00:44:32.890 --> 00:44:34.708
I wouldn't expect it to be hard,

00:44:34.709 --> 00:44:36.860
any more difficult in your favorite language.

00:44:36.860 --> 00:44:41.140
Glance one more time to see if there

00:44:41.140 --> 00:44:42.940
happen to be any other questions.

00:44:42.940 --> 00:44:47.300
And not seeing any, I'm going to go ahead and start

00:44:47.300 --> 00:44:49.500
wrapping up my chat now.

00:44:49.500 --> 00:44:51.620
It will take me a couple of minutes to do that.

00:44:51.620 --> 00:44:54.580
So if you do have any other questions that you

00:44:54.580 --> 00:44:56.460
want to drop into the pad or any comments,

00:44:56.460 --> 00:44:59.740
you're more than welcome to hit me with those

00:44:59.740 --> 00:45:03.820
as I coordinate closing this chat, this talk,

00:45:03.820 --> 00:45:06.100
with the organizer team.