Here I send the old promised automaton for indenting in linear time... I looked in the code of emacs to the function scan_sexps_forward, because I want to write for myself a little web browser, and I saw that its automaton of changing the classes of syntax looks very closely to the automaton that I wrote about 1 year ago to indent the lisp code. That is the reason for which I decided to open the archives and to remember. This code indents a line of code and a whole region in O(n) time complexity; oups! no, sorry, in O(n+l) (the automaton in O(n) + O(l) to use its output to indent), where n is the number of bytes from the beginning of the function to the ending point, and l is the number of lines from the beginning of the function to the ending point. (in the code it's true that (current-column) is called very often, but I can insert a variable `column' that keeps the current column, and it is reset when we meet newline, and grows by 1 when the automaton passes to the next state, and I think that I will modify it to keep the idea of O(n)). This code is very compact; installing it will cut thousands of lines of old code from Emacs. And, besides, it is imcomplete! Here are just the most basics. I can complete it just after I speak with the emacs developers, in order to agree on its behaviour. I do not like to work on in vain. In this period I wish to work for this code, in order to finish it. If I do not work now, I do not know when I can work on. Besides, looking these days to write my web browser, I realised that it would be a good idea embedding this automaton in C. But, again, I do not want to work on it before asking you, because I want this job to have a practical utility, not just to spend time working on this. Here I give you just 2 very samples examples of how this automaton works. It's evident how it works, and these 2 examples are too much! There are a few new things in this code: for example, note the easyness to add indent for comments, constant symbols, and look at the easyness with which I made the indentation of a parameter of a function before the first parameter, not under the second (i.e. one makes now the difference between many kinds of list : not all the lists have the first parameter a function): (defun a (x y z t) ... and not the old behaviour: (defun a (x y z t) ... The problem of indentig of lisp code is a problem of... homotopy: however I deform the code (the spaces at the beginning of the lines), this automaton must always return the same result. Before calling (lisp-indent-automaton), one must have in the upper environment the variables `state' and `indents-lines' initialised with nil. It will return the result in indents-lines. The mapcar of car of indents-lines is a list that contains the correct answer to the homotopy problem. This result must be the same however I deform the code (spaces at the beginning of lines). The mapcar of the cdr is a list with the current indentation. Please, tell me your impressions and... give me to work in order to finish it well :) Alin Soare. ____________________________________________________ Sur le mail Voila, vous pouvez personnaliser l’anti-spam ! http://mail.voila.fr