aboutsummaryrefslogtreecommitdiffstats
path: root/src/marker.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/marker.c')
-rw-r--r--src/marker.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/marker.c b/src/marker.c
index a03a0b104ca..0d992c0abfa 100644
--- a/src/marker.c
+++ b/src/marker.c
@@ -499,11 +499,29 @@ set_marker_internal (Lisp_Object marker, Lisp_Object position,
499 { 499 {
500 register ptrdiff_t charpos, bytepos; 500 register ptrdiff_t charpos, bytepos;
501 501
502 CHECK_NUMBER_COERCE_MARKER (position); 502 /* Do not use CHECK_NUMBER_COERCE_MARKER because we
503 charpos = clip_to_bounds (restricted ? BUF_BEGV (b) : BUF_BEG (b), 503 don't want to call buf_charpos_to_bytepos if POSTION
504 XINT (position), 504 is a marker and so we know the bytepos already. */
505 restricted ? BUF_ZV (b) : BUF_Z (b)); 505 if (INTEGERP (position))
506 bytepos = buf_charpos_to_bytepos (b, charpos); 506 charpos = XINT (position), bytepos = -1;
507 else if (MARKERP (position))
508 {
509 charpos = XMARKER (position)->charpos;
510 bytepos = XMARKER (position)->bytepos;
511 }
512 else
513 wrong_type_argument (Qinteger_or_marker_p, position);
514
515 charpos = clip_to_bounds
516 (restricted ? BUF_BEGV (b) : BUF_BEG (b), charpos,
517 restricted ? BUF_ZV (b) : BUF_Z (b));
518 if (bytepos == -1)
519 bytepos = buf_charpos_to_bytepos (b, charpos);
520 else
521 bytepos = clip_to_bounds
522 (restricted ? BUF_BEGV_BYTE (b) : BUF_BEG_BYTE (b),
523 bytepos, restricted ? BUF_ZV_BYTE (b) : BUF_Z_BYTE (b));
524
507 attach_marker (m, b, charpos, bytepos); 525 attach_marker (m, b, charpos, bytepos);
508 } 526 }
509 return marker; 527 return marker;