[gnu.emacs] suggestion of new-type-marker

handa@etl.go.jp (Kenichi Handa) (11/30/89)

Currently, in Emacs, a marker does not move when insertion
occurs at the marker position.  We should explicitly call
insert-before-markers to move markers to a next of
inserted string.

This cuases a problem when we want to set some region
between two markers and delete or insert strings in the
region.  We should take care to call 'insert-before-markers'
(not 'insert') at the tail of the region.  We should not
delete whole string of the region.  It's because once we
delete the whole string, two markers point to the same
position and we should call set-marker to move the
tail-pointing marker when we again insert something to that
region of zero width.

These coding is very very annoying.

So, my colleague suggested another type of marker
(point-like-marker).  Insertion at a marker of such type
moves the marker to the next of inserted string just like a
point.  If we have this type of marker, all we should do is
to set old-type-marker at the head of a region and set
point-like-marker at the tail of the region.  We are
released from annoying checking descrived before.

It does not seem to be difficult to realize it.

1. At first, we should modify struct Lisp_Marker in lisp.h
like below:

struct Lisp_Marker
  {
    struct buffer *buffer;
    Lisp_Object chain;
    int bufpos;
    int modified;
    int move_after_insertion;   /* new field */
  }; /* Maybe unsigned char is enough for modified and move_after_insertion. */

2. Make new function adjust_markers_new () in insdel.c by
slightly modifying adjust_markers ().  adjust_markers_2 ()
only adjusts markers of the new type.

3. Modify tail of InsCStr () like below:

  bf_gap -= length;
  bf_p2 -= length;
  bf_s1 += length;
  point += length;
  adjust_markers_new (opoint - 1, opoint, lenght);  /* new statement */
}

4. Modify "set-marker" in marker.c so that it has the fourth
optional argument 'move-after-insertion-flag' and sets
'move_after_insertion' field of marker according to this flag.
Or, we should make new function "set-marker-new".

5. Modify "copy-marker" so that it correctly copy
'move_after_insertion' field.

That's all.

How about this idea?

---
Ken'ichi HANDA