as a marker, avoid call to buf_charpos_to_bytepos.
* window.c (Fset_window_point): Omit redundant type checking.
(Fset_window_start): Likewise. Format comment.
(window_scroll_pixel_based): Use set_marker_restricted_both
with character and byte positions obtained from an iterator.
(Fset_window_configuration): Use set_marker_restricted_both.
* xdisp.c (message_dolog): Likewise.
+2013-02-11 Dmitry Antipov <dmantipov@yandex.ru>
+
+ * marker.c (set_marker_internal): If desired position is passed
+ as a marker, avoid call to buf_charpos_to_bytepos.
+ * window.c (Fset_window_point): Omit redundant type checking.
+ (Fset_window_start): Likewise. Format comment.
+ (window_scroll_pixel_based): Use set_marker_restricted_both
+ with character and byte positions obtained from an iterator.
+ (Fset_window_configuration): Use set_marker_restricted_both.
+ * xdisp.c (message_dolog): Likewise.
+
2013-02-10 Eli Zaretskii <eliz@gnu.org>
* xdisp.c (move_it_vertically_backward, move_it_by_lines): When
{
register ptrdiff_t charpos, bytepos;
- CHECK_NUMBER_COERCE_MARKER (position);
- charpos = clip_to_bounds (restricted ? BUF_BEGV (b) : BUF_BEG (b),
- XINT (position),
- restricted ? BUF_ZV (b) : BUF_Z (b));
- bytepos = buf_charpos_to_bytepos (b, charpos);
+ /* Do not use CHECK_NUMBER_COERCE_MARKER because we
+ don't want to call buf_charpos_to_bytepos if POSTION
+ is a marker and so we know the bytepos already. */
+ if (INTEGERP (position))
+ charpos = XINT (position), bytepos = -1;
+ else if (MARKERP (position))
+ {
+ charpos = XMARKER (position)->charpos;
+ bytepos = XMARKER (position)->bytepos;
+ }
+ else
+ wrong_type_argument (Qinteger_or_marker_p, position);
+
+ charpos = clip_to_bounds
+ (restricted ? BUF_BEGV (b) : BUF_BEG (b), charpos,
+ restricted ? BUF_ZV (b) : BUF_Z (b));
+ if (bytepos == -1)
+ bytepos = buf_charpos_to_bytepos (b, charpos);
+ else
+ bytepos = clip_to_bounds
+ (restricted ? BUF_BEGV_BYTE (b) : BUF_BEG_BYTE (b),
+ bytepos, restricted ? BUF_ZV_BYTE (b) : BUF_Z_BYTE (b));
+
attach_marker (m, b, charpos, bytepos);
}
return marker;
{
register struct window *w = decode_live_window (window);
- CHECK_NUMBER_COERCE_MARKER (pos);
+ /* Type of POS is checked by Fgoto_char or set_marker_restricted ... */
if (w == XWINDOW (selected_window))
{
{
struct buffer *old_buffer = current_buffer;
+ /* ... but here we want to catch type error before buffer change. */
+ CHECK_NUMBER_COERCE_MARKER (pos);
set_buffer_internal (XBUFFER (w->buffer));
Fgoto_char (pos);
set_buffer_internal (old_buffer);
{
register struct window *w = decode_live_window (window);
- CHECK_NUMBER_COERCE_MARKER (pos);
set_marker_restricted (w->start, pos, w->buffer);
- /* this is not right, but much easier than doing what is right. */
+ /* This is not right, but much easier than doing what is right. */
w->start_at_line_beg = 0;
if (NILP (noforce))
w->force_start = 1;
}
/* Set the window start, and set up the window for redisplay. */
- set_marker_restricted (w->start, make_number (pos),
- w->buffer);
+ set_marker_restricted_both (w->start, w->buffer, IT_CHARPOS (it),
+ IT_BYTEPOS (it));
bytepos = marker_byte_position (w->start);
w->start_at_line_beg = (pos == BEGV || FETCH_BYTE (bytepos - 1) == '\n');
w->update_mode_line = 1;
{
/* Set window markers at start of visible range. */
if (XMARKER (w->start)->buffer == 0)
- set_marker_restricted (w->start, make_number (0),
- w->buffer);
+ set_marker_restricted_both (w->start, w->buffer, 0, 0);
if (XMARKER (w->pointm)->buffer == 0)
set_marker_restricted_both
(w->pointm, w->buffer,
wset_buffer (w, other_buffer_safely (Fcurrent_buffer ()));
/* This will set the markers to beginning of visible
range. */
- set_marker_restricted (w->start,
- make_number (0), w->buffer);
- set_marker_restricted (w->pointm,
- make_number (0), w->buffer);
+ set_marker_restricted_both (w->start, w->buffer, 0, 0);
+ set_marker_restricted_both (w->pointm, w->buffer, 0, 0);
w->start_at_line_beg = 1;
if (!NILP (w->dedicated))
/* Record this window as dead. */
bset_undo_list (current_buffer, Qt);
oldpoint = message_dolog_marker1;
- set_marker_restricted (oldpoint, make_number (PT), Qnil);
+ set_marker_restricted_both (oldpoint, Qnil, PT, PT_BYTE);
oldbegv = message_dolog_marker2;
- set_marker_restricted (oldbegv, make_number (BEGV), Qnil);
+ set_marker_restricted_both (oldbegv, Qnil, BEGV, BEGV_BYTE);
oldzv = message_dolog_marker3;
- set_marker_restricted (oldzv, make_number (ZV), Qnil);
+ set_marker_restricted_both (oldzv, Qnil, ZV, ZV_BYTE);
GCPRO1 (old_deactivate_mark);
if (PT == Z)