cef@h.cs.cmu.edu (Charles Fineman) (12/31/85)
** NOTE, this is taken from a post I made at CMU. Hemlock is an emacs style ** editor built on top of Common Lisp. Markers in Hemlock differ from Gosling markers in that the Hemlock markers can be left or right inserting. For example, suppose you have the dot at a marker and you insert a character. If the marker is right-inserting, it will remain pointing to the same place as the text is inserted to the right of the marker. If the marker is left-inserting, it will move as the inserted characters are put to the left of the marker. Now, if you have any experience with mlisp, you will know that Gosling's markers are generally right-inserting (at least they are when returned by the dot and mark functions). To obtain a left-inserting marker at the dot, call the following function: (gen-ri-marker saved-mark result (setq saved-mark (mark)) (set-mark) (insert-character 32) (setq result (dot)) (erase-region) (save-excursion (goto-character saved-mark)(set-mark)) result ) This is all fine and dandy but you may be wondering what the use of left-inserting marks might be. Well, the real power comes into play when your dealing with regions (text between markers, not necessarily the mark and the dot). Say you have a region that's empty but you want to be able to insert characters into is and still have the markers delimiting the region. Obviously you cant represent it with two right-inserting marks pointing to the region's position, characters inserted at this point will not move the marker delimiting the end of the region. Another solution is to have the end marker point to the character after the region. This is fine except for at the end of the buffer where there is no next character; I could put one there but that's a BIG hack. Instead, I put left and right inserting markers down, and get *everything* automaticly. When I discovered this, I was surprised that Gosling never mentioned it, perhaps he never realized. Either way, James gets a gold star from me (now if we can only get a cons into mlisp).