#summary TODOs. #labels Phase-Design,Phase-Implementation,Deprecated = ~~Use text properties instead of overlay~~ = Overlay creations are not recorded in undo list. Hard to deal with undoing. *NOTE* There can be multiple overlays over the same piece of text. This is essential to support overlapped snippet. We should explicitly keep a list in the text property of we want to simulate this. == What behavior of overlay need to be supported in our simulation? == * a `start` and a `end` marker. * be automatically extended when text is inserted (See text properties). * ~~`move-overlay`~~ only the operation of increasing the end-marker of overlay is needed. * `delete-overlay` * ~~`find-overlays-at-position`~~ `get-overlay-at-position` -- at most one overlay, as long as snippet *fields* can't overlap. * `insert` will not inherit text properties. We need to maintain this when user sometimes use `insert` (e.g. `hippie-expand`) directly. A ad-hoc way is to def-advice `insert` :p. msf-abbrev sucks this way. == What if two fields are put adjacently? == Like this "for ${1:foo}${2:bar}". What is the behavior if the user types in front of the 2nd field? (The common case is when the user type a character at 1st field to replace the field default value, then the cursor will at the very position.) Should the typed text belong to the 1st or the 2nd field? When use overlay, the default behavior is random, so I use a explicitly hook to make sure it belongs to 2nd since the point is in the range of 2nd overlay explicitly. I don't know the behavior of Textmate because I don't have one. But the E editor seems don't handle this situation -- it just exit the snippet when _collision_ is detected. I should follow my original idea. In insert-behind-hook: if point is inside a field, the hook do nothing (since there should have another hook), otherwise extend(enlarge) the overlay. = ~~Highlight only the focused fields (and its mirrors)~~ = Maybe listen move event? ~~Maybe look at the code how Emacs highlight parentheses.~~ See `point-entered` and `point-left` text properties. Convenient for text-property, but not for overlays. = (DONE)Delete snippet when undoing = Overlay creating isn't recorded and isn't undo-ed. So undo a snippet will end with some lonely overlays. Construct a proper undo behavior of snippet creation. = How to deal with multiple snippets ? = Traditional way is to make sure only one snippet can exist at a time. msf-abbrev allow multiple snippets. The problem is when multiple sippets overlaps. msf-abbrev merge the two snippets -- they'll have the same group id. If I follow the msf-abbrev way, I must care when merging two snippets, their fields with the same name won't mess up. Let's define some restrict rules: # Multiple snippets should behavior well if they don't overlap. # If the snippet being expanded is inside one of the fields of another snippet, the other snippet is exited firstly. Otherwise, they should behavior independently. = ~~Redo of snippet~~ = Emacs has a undo system which is very confusing. Redoing a snippet is possible but complicated. I think this is rarely used. If you really want to redo expanding a snippet, just expand it again. So I won't support redoing a snippet expansion.