PR #3227 <https://github.com/leo-editor/leo-editor/pull/3227> contains a draft implementation of issue #3121 <https://github.com/leo-editor/leo-editor/issues/3121>: headline numbers.
While working on this PR, several problems became apparent. This Engineering Notebook post will discuss my present thoughts. I encourage all comments. *Undo/Redo* My first thought was that undo/redo is not necessary. For example, delete-all-headline-numbers will undo add-all-headline numbers. And in fact, the PR passes this round-trip test. But my first thought was wrong: - It's easier to type Ctrl-Z than to invoke the command that would undo the previous command. - Undo/Redo methods for headlines will be valuable all by themselves. - These undo/redo methods won't depend on how the headlines change. Happily, FĂ©lix has volunteered to add these undo/redo methods. The following sections discuss several nasty problems with headline numbers. *The format of numbers* Should numbers be one-based or zero-based? One-based seems less nerdy, but there is another question. Should line numbers be local or global? At present, all numbers are global. Headline numbers are unique within the entire outline. But the (non-existent) number-headlines-locally or number-child-headlines-locally commands could create numbers relative to c.p. Alas, both these commands seem clumsy for various reasons. Details omitted. *Problems with clones* Clones appear in multiple places in an outline, but all clones have the same headline. Therefore the headline number for clones will be incorrect in some positions. This problem has no perfect solution. Leo could associate headline numbers with positions instead of vnodes. Details omitted. I'm not going to consider such an heroic solution. The numbering commands must use either the first or last number for all clones. But neither choice will be entirely satisfactory. *Headline numbers in @<file> trees* These commands must avoid numbering @<file> and section definitions nodes. The present code can mistakenly number section definition nodes. Avoiding this mistake is non-trivial. *Summary* I'm not sure that a fixed set of outline-numbering commands can overcome all these problems. Perhaps Leo should provide only the promised undo/redo routines for headlines. Otoh, the PR seems like a reasonable compromise. Please let me know your thoughts. Edward -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/631dbe10-bee8-404d-8fe6-3faf9ef3cadcn%40googlegroups.com.