+set_point (buffer, charpos)
+ register struct buffer *buffer;
+ register int charpos;
+{
+ set_point_both (buffer, charpos, buf_charpos_to_bytepos (buffer, charpos));
+}
+
+/* If there's an invisible character at position POS + TEST_OFFS in the
+ current buffer, and the invisible property has a `stickiness' such that
+ inserting a character at position POS would inherit the property it,
+ return POS + ADJ, otherwise return POS. If TEST_INTANG is non-zero,
+ then intangibility is required as well as invisibleness.
+
+ TEST_OFFS should be either 0 or -1, and ADJ should be either 1 or -1.
+
+ Note that `stickiness' is determined by overlay marker insertion types,
+ if the invisible property comes from an overlay. */
+
+static int
+adjust_for_invis_intang (pos, test_offs, adj, test_intang)
+ int pos, test_offs, adj, test_intang;
+{
+ Lisp_Object invis_propval, invis_overlay;
+ Lisp_Object test_pos;
+
+ if ((adj < 0 && pos + adj < BEGV) || (adj > 0 && pos + adj > ZV))
+ /* POS + ADJ would be beyond the buffer bounds, so do no adjustment. */
+ return pos;
+
+ test_pos = make_number (pos + test_offs);
+
+ invis_propval
+ = get_char_property_and_overlay (test_pos, Qinvisible, Qnil,
+ &invis_overlay);
+
+ if ((!test_intang
+ || ! NILP (Fget_char_property (test_pos, Qintangible, Qnil)))
+ && TEXT_PROP_MEANS_INVISIBLE (invis_propval)
+ /* This next test is true if the invisible property has a stickiness
+ such that an insertion at POS would inherit it. */
+ && (NILP (invis_overlay)
+ /* Invisible property is from a text-property. */
+ ? (text_property_stickiness (Qinvisible, make_number (pos))
+ == (test_offs == 0 ? 1 : -1))
+ /* Invisible property is from an overlay. */
+ : (test_offs == 0
+ ? XMARKER (OVERLAY_START (invis_overlay))->insertion_type == 0
+ : XMARKER (OVERLAY_END (invis_overlay))->insertion_type == 1)))
+ pos += adj;
+
+ return pos;
+}
+
+/* Set point in BUFFER to CHARPOS, which corresponds to byte
+ position BYTEPOS. If the target position is
+ before an intangible character, move to an ok place. */
+
+void
+set_point_both (buffer, charpos, bytepos)